When I doing Paypal Checkout with multi-currency like Taiwan or Japanese Yen , suddenly I get this error :
1 | ‘Order total is invalid.’ (Error Code: 10401) |
Wait a seconds, I try with other currencies like USD or GBP, everything is works well!
Then I realize that some currencies in Paypal can’t handle comma in Decimal (cent).
Example:
1 | NT 9833.33 |
So, we should send them round up number to solve this problem, like:
1 | NT 9834 |
If you want to round UP whatever cent behind the amount, then you can use this :
1 2 3 4 | from math import ceil from decimal import Decimal amount = Decimal(‘33.144’) round_amount = Decimal(str(ceil(amount))).quantize(Decimal(‘0’)) |
When you sending this round amount, you will not see “‘Order total is invalid.’ (Error Code: 10401)” again! 🙂
Note:
I using https://github.com/duointeractive/paypal-python/ in my Django application.