sonata-project / sandbox

[Abandoned] Sonata Project's sandbox
https://sonata-project.org
MIT License
268 stars 198 forks source link

Paypal payment issue #401

Closed danvbe closed 6 years ago

danvbe commented 10 years ago

I tried to setup Paypal Payment method and I had some issues:

  1. The documentation is not updated with current config. The index file seems to be fine, but the Paypal specific file is not updated (the default configuration). This is not so important, but I thought I should mention it.
  2. The Paypal class in the ecommerce bundle was not working well. In the public function sendbank(OrderInterface $order) function, where we are setting up the fields to be sent to paypal, we have:

    ... ...
    'amount'        => $order->getTotalInc(),
    'currency_code' => $order->getCurrency(),
    .... ....

The $order->getTotalInc() returned the value with 3 decimals (I assume it does this because we have bcscale(3); set in AppKernel::init()), but this is generating an error on Paypal (it expects 2 decimal values). The $order->getCurrency() was returning a serialized object... this is from the output:

   [currency_code] => Sonata\Component\Currency\Currency Object
      (
          [label:protected] => EUR
      )

I have managed to fix this by creating in ApplicationPaymentBundle my custom Paypal class (extended from Sonata\Component\Payment\Paypal, overwriting the sendBanck(...) function by fixing amount and currency_code and changing the sonata.payment.method.paypal.class parameter to point to this new class.

As solution... I would suggest to implement these changes directly in the ecommerce bundle (in Paypal class) as they are directly related and specific to Paypal (and do not really require to be done at Application level, via extending).

danvbe commented 10 years ago

Since I had some requests on how I fixed this... here is a gist to point you in right direction. It is the way to bypass this issue and the one related to the send confirmation receipt part (calback from your site to validate Paypal payment).

jordisala1991 commented 6 years ago

Since the issue is already on ecommerce, I am closing this one