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?

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.

Further reading

Problem with a question

Engineering Decisions · Middle · question 6

Test yourself

Take the Engineering Decisions · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz