core practice · coding problem
Idempotent charge
Double-click Pay sends two POST /charge with same Idempotency-Key. How many charges?
The mechanism
Payment systems are several systems agreeing about money: the card network, the processor, your database, and accounting. Treat every state change like a ledger entry, use idempotency keys on every request, and reconcile against the processor daily.
Expected evidence
One charge; second returns same receipt.
Try this drill in the practice workspace →
Hints when you need them
- Store key → result mapping 24h.
- Network retries are normal.