Jump to content

HELP! PayPal Rejection Error due to rounding - non decimal currency !


Recommended Posts

If I use nice whole numbers like

 

Price 100 JPY

Tax %5

Total 105 JPY

 

then PayPal Standard accepts my order just fine

 

But if I change the amount to something like:

Price 103 JPY

Tax %5

Total 108.15 JPY (as per calculation)

 

PayPal rejects the order with the following message

  1. PayPal response:
  2. TIMESTAMP -> 2012-05-17T02:14:25Z
  3. L_ERRORCODE0 -> 10401
  4. L_ERRORCODE1 -> 10426
  5. L_ERRORCODE2 -> 10413
  6. L_ERRORCODE3 -> 10431
  7. L_SHORTMESSAGE0 -> Transaction refused because of an invalid argument. See additional error messages for details.
  8. L_SHORTMESSAGE1 -> Transaction refused because of an invalid argument. See additional error messages for details.
  9. L_SHORTMESSAGE2 -> Transaction refused because of an invalid argument. See additional error messages for details.
  10. L_SHORTMESSAGE3 -> Transaction refused because of an invalid argument. See additional error messages for details.
  11. L_LONGMESSAGE0 -> Order total is invalid.
  12. L_LONGMESSAGE1 -> Item total is invalid.
  13. L_LONGMESSAGE2 -> The totals of the cart item amounts do not match order amounts.
  14. L_LONGMESSAGE3 -> Item amount is invalid.
  15. L_SEVERITYCODE0 -> Error
  16. L_SEVERITYCODE1 -> Error
  17. L_SEVERITYCODE2 -> Error
  18. L_SEVERITYCODE3 -> Error
  19. PayPal returned error

 

Japanese Yen is a non-decimal currency of course.

My guess is that somewhere in the PayPal module the PHP code needs

to have a round(price,0) function applied to the value that gets passed over.

 

Any suggestions? Need help urgently !

 

I am using PrestaShop 1.4.7.3

PayPal Module 2.8.6

Link to comment
Share on other sites

OK, maybe I have fixed this myself.

 

In the /classes/Cart.php file

 

I searched for every instance of the ps_round function e.g.

 

$row['total'] = Tools::ps_round($row['price'] * (int)($row['cart_quantity']), 2);

 

This function takes two parameters, the variable to be rounded, and the "precision" to apply, which by default is set to 2

 

So I found every instance of the function and changed the 2 to a zero like this:

 

$row['total'] = Tools::ps_round($row['price'] * (int)($row['cart_quantity']), 0);

 

It's a quick fix. Best practice of course is to put this into an override file so it's future proofed.

If somebody can explain the details of how to do that for the Cart.php Class I would be grateful.

Link to comment
Share on other sites

I do have the rounding problem you described before, and I do not what exactly the problems.

I guess the shopping amount is rounded when exchanged to another currency for clearing so it does not match the original shipping amount.

 

Maybe you can try switching between different rounding mode at Backoffice > Preferences> Round mode

 

Choose the rounding method: always superior,

always inferior, or classic rounding.

Edited by miskey (see edit history)
Link to comment
Share on other sites

I do have the rounding problem you described before, and I do not what exactly the problems.

I guess the shopping amount is rounded when exchanged to another currency for clearing so it does not match the original shipping amount.

 

Maybe you can try switching between different rounding mode at Backoffice > Preferences> Round mode

 

Choose the rounding method: always superior,

always inferior, or classic rounding.

 

I havent tried but I dont think those option would make much difference. Prestashop is clearly hard coded to use two decimals, which is strange because many of the world's currencies (Japanese Yen, Korean Won, Thai Baht) are zero decimal currencies.

Link to comment
Share on other sites

  • 5 months later...

Hi,

Did you find a solution for this issue ?

I am having the same problem with ps1.4.9.0 and paypal v3.0.9

 

Regards

 

Hugo

I havent tried but I dont think those option would make much difference. Prestashop is clearly hard coded to use two decimals, which is strange because many of the world's currencies (Japanese Yen, Korean Won, Thai Baht) are zero decimal currencies.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...