Sylius / PayPalPlugin

Official integration with PayPal Commerce Platform
37 stars 56 forks source link

create-pay-pal-order route fails when using promotion code #165

Closed LaskeJu closed 3 years ago

LaskeJu commented 3 years ago

When I perform a payment, while i using an discount code. The create-pay-pal-order route fails and i cant pay my order.

LaskeJu commented 3 years ago

I have added the following code to fix the error: File: "Api/CreateOrderApi.php" => "public function create(string $token, PaymentInterface $payment, string $referenceId): array"

                        'tax_total' => [
                            'currency_code' => $order->getCurrencyCode(),
                            'value' => $payPalItemData['total_tax'],
                        ],

                        //added this:
                        'discount' => [
                            'currency_code' => $order->getCurrencyCode(),
                            'value' => abs($order->getOrderPromotionTotal()) / 100,
                        ]

This is how it works for me.

romainguerrero commented 3 years ago

@LaskeJu we have the problem too. Are you able to propose your fix in a PR as it can be shared to everyone ?

LaskeJu commented 3 years ago

@romainguerrero added PR #175

Zales0123 commented 3 years ago

I believe it can be closed due to #175 🖖