Engineering
A payment bug nobody could reproduce
You
Since Tuesday's deploy, about 1 checkout in 40 fails with “amount mismatch”. We can't reproduce it. Repo and the last 2,000 log lines attached. Find it and fix it.
- checkout-service (repository)
- payments.log, 2,000 lines
What it did
- LogsGrouped the 51 failures: every one is in KWD, BHD or OMR.
- CodeThose currencies use 3 decimals. Tuesday's commit rounds every amount to 2.
- TerminalWrote a test that fails with 12.345 KWD, then fixed roundAmount().
- TerminalFull test suite: 214 passing. Opened a pull request.
SunuXel
Found it. The failures are not random: they are every order paid in Kuwaiti dinar, Bahraini dinar or Omani rial. Those currencies have three decimal places, and Tuesday's change rounds all amounts to two. The processor receives 12.35 when the cart says 12.345, so it rejects the charge.
The fix reads the number of decimals from the currency code instead of assuming two. I added a test for each three-decimal currency so this cannot come back silently.
Delivered · Pull request #318 · 214 tests passing