aimeos / aimeos-core

Aimeos PHP e-commerce framework for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce
https://aimeos.org
Other
3.4k stars 118 forks source link

[Bug] PayPal: Invalid shipping total #199

Closed krausandre closed 4 years ago

krausandre commented 4 years ago

https://github.com/aimeos/aimeos-core/blob/9a0d3f94291fe0f7e2ec450098ad9dc6f36b67d6/lib/mshoplib/src/MShop/Service/Provider/Payment/PayPalExpress.php#L725

After debugging I found this message from PayPal: Invalid shipping total; it should equal the shipping amount of the selected shipping option.&L_SEVERITYCODE0=Error

After checking the code, it seems that $deliveryCosts at line 725 is never initialized.

Therefore, I changed that line from $values['L_SHIPPINGOPTIONAMOUNT' . $lastPos] = number_format( $deliveryCosts, 2, '.', '' );

to $values['L_SHIPPINGOPTIONAMOUNT' . $lastPos] = number_format( $service->getCosts(), 2, '.', '' );

Now everything works fine for me.

This error only appears, if you have shipping costs. If shipping is for free, there is no problem.

What do you think about that?

aimeos commented 4 years ago

Thanks for your hint! $service->getCosts() doesn't exist but $service->getPrice()->getCosts() should yield the correct result. Can you create a PR with that change?

krausandre commented 4 years ago

Well, it seems that both solutions are working. Let us take your suggestion.