Found this when a merchant selling in Japan reported that orders cost 100x too much. Most cards were declined on amount. The few that passed were charged ¥100,000 for a ¥1,000 item.
Our amount helper did what most tutorials do: Math.round(price * 100). That works for USD, EUR and GBP. It breaks for JPY and KRW, which have zero decimals in ISO 4217. It also breaks the other way for BHD, KWD and JOD, which have three. A dinar price of 1.500 sent as 150 reaches the gateway as 0.150.
Sandbox accepted everything, because every test amount was in USD. The first signal was an approval rate drop on a single currency. We read it as an issuer problem for a full day.
What we changed:
- The exponent lives in one table keyed by ISO code, not in a constant.
- Amounts are integers in minor units from the cart onward, with no floats after the first conversion.
- One test pushes the same price of 10 through USD, JPY and BHD and asserts 1000, 10 and 10000.
- If the input has more decimals than the currency allows, we reject it instead of rounding silently.
Do you validate the exponent on your side, or do you rely on the gateway to reject a bad amount?
Payneteasy handles this kind of payment flow for merchants and PSPs — see how it works.
Top comments (0)