magento2: With certain currencies invalid amount is sent to Paypal
Preconditions
- Magento 2.1.6
- php 5.6
Steps to reproduce
- [ADMIN] Select
HUF(Hungarian forint) as base & display currency - [ADMIN] Turn on Paypal Express checkout
- [FRONTEND] Start checkout flow
- [FRONTEND] Try paying with Paypal
Expected result
User can successfully pay
Actual result
Paypal error is thrown, user is unable to pay via Paypal
Error message:
PayPal gateway has rejected request. Item total is invalid (#10426: Transaction refused because of an invalid argument. See additional error messages for details). Tax total is invalid (#10429: Transaction refused because of an invalid argument. See additional error messages for details).
Logs:
Here’s the relevant part of the array:
main.DEBUG: array ( 'url' => 'https://api-3t.paypal.com/nvp', 'SetExpressCheckout' => array ( 'PAYMENTACTION' => 'Sale', 'AMT' =>'2990.00', 'CURRENCYCODE' => 'HUF', 'SHIPPINGAMT' =>'0.00', 'ITEMAMT' =>'2354.33', 'TAXAMT' => '635.67',
Compare this with Paypal’s official Currency Code advice for developers:
Hungarian Forint | HUF Note: Decimal amounts are not supported for this currency. Passing a decimal amount will throw an error.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (7 by maintainers)
Why would this be a feature request and not a bug?
@zzvara @simonattilahun this is how I’ve been working around this for now: (Depending on which Paypal payment method you use the actual file and methods to modify might be different. I’ve had to set up express checkout, so that’s what you find covered below.)
In
vendor/magento/module-paypal/Model/Api/Nvp.phpupdate the public funcallSetExpressCheckout():Then you have to add rounding to a different function as well –
callDoExpressCheckoutPayment()I added both just above the function calling the response.
@magento-engcom-team Is this a feature request not a bug?
This is a blocker for us as well.
So, are there any solution for the HUF rounding problem? We try to implement a store on Community Edition 2.2.1 This seems to be a blocking issue preventing us to go live with PayPal payments as PayPal is sending an error message assumably because of the tax calculation rounding issue. (Zero digit rounding is needed)