Checkout that never double-charges
An e-commerce checkout composing idempotency keys, a transactional outbox and a compensating saga so retries can never charge twice.
What this design does
The classic money-path problem: a payment call times out, the client retries, and the customer is charged twice. This design makes that impossible by construction — an idempotency key dedupes retries at the API, the outbox pattern removes the fatal dual-write between the database and the queue, and every downstream step is either idempotent or compensated. Import it, declare the 'never charge twice' guarantee, and verify it against injected crashes.
The patterns it composes
- Idempotency key — client retries collapse into one logical request at the API
- Transactional outbox — order row and OrderPlaced event commit atomically — no dual-write
- Saga + compensating transaction — payment failure unwinds reservation and order safely
- Dead-letter channel — poison events park for humans instead of blocking the stream
- Retry with budget + timeout — the PSP call is retried, but boundedly, under a deadline
Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.