Giter VIP home page Giter VIP logo

gpwebpay-core's People

Contributors

dependabot-preview[bot] avatar edvordo avatar ondraondra81 avatar vhelmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gpwebpay-core's Issues

Uncaught Grifart\Enum\UsageException: You have forgotten to add @method annotations for enum 'Pixidos\GPWebPay\Enum\Currency'

Getting this error in my environment. This is the method I use:

/**
   * @param $order_id
   * @param $amount
   *
   * @return string
   * @throws \Pixidos\GPWebPay\Exceptions\InvalidArgumentException
   * @throws \Pixidos\GPWebPay\Exceptions\SignerException
   */
  public function get_payment_url( $order_id, $amount ) {
    $operation = new Operation(
      new OrderNumber( $order_id ),
      new Amount( $amount ),
      new Currency( \Pixidos\GPWebPay\Enum\Currency::CZK() )
    );
    $request   = $this->get_request_factory()->create( $operation );

    return $request->getRequestUrl();
  }

Any idea how to fix this? This happens only on one of my test environments for some reason, works fine on another staging.

Thanks!

Amount is dangerous to use

Default use of Amount is imprecise and generates incorrect transaction orders. I forked the repo and added failing test to a new branch imprecise-amount (https://github.com/robskr/gpwebpay-core/tree/imprecise-amount).

I don't see how this can be fixed without either requiring ext-bcmath or leaving user code to provide actual precise amount (non-float and already converted to cents).

So I'd suggest deprecating option to pass non-cents amounts (basically to avoid multiplying float) and removing it in next version. Introducing Amount interface and e. g. PreciseAmount or CentsAmount class to avoid BC break is also a possibility, but that seems like too much hassle just to preserve broken functionality. Nevertheless, I think BC break is more than justified here and maybe it would even be more sensible to just release new major version with changed constructor:

public function __construct(int $amount);

I'm indeed willing to help with the fix, just need to know the preferred way to fix it. Actually here's a draft with the changed constructor 👉 https://github.com/robskr/gpwebpay-core/tree/imprecise-amount-fix so I can make a PR right away.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.