Engineering Decisions · Middle · Question 6 of 14
A payment request timed out, so you don't know whether the charge went through. Charging twice is unacceptable, but the sale shouldn't be lost. What do you build?
- 1Safe retries with one idempotency key per payment
- 2No retries: show an error and ask the user to retry
- 3Check the charge list first, then retry if it's absent
Show the answer
Correct answer: Safe retries with one idempotency key per payment
Explanation
With a key, the provider treats the retry as the same operation, so it can't charge twice even if the first call succeeded. Showing an error fits actions that are cheap to repeat, but the user may pay twice by pressing the button again. Checking first fits providers that have no keys, yet it leaves a race: the first charge may still be in flight during the check.