techdiagrams.net
← All templates

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.

Open in editor — free, no login Download JSON
ONE BLAST RADIUS — EVERYTHING AT-LEAST-ONCE INSIDEPOST /checkout · Idempotency-Keyorder + outbox, one txnpoll new eventspublish OrderPlacedconsumechargereserve stockafter N failuresPaymentFailed → releaseStorefrontweb + mobileCheckout APIidempotency-key dedupeOrders DBorders + outbox tableOutbox Relaypolls outbox → publishesOrderPlacedat-least-oncePayment Servicesaga step · compensablePSP / Gatewayexternal — Stripe/AdyenInventoryreserve → release on failureDead letterspoison events → humanswhy no double charge:1. retry hits the same Idempotency-Key → same response2. outbox means the event exists iff the order exists3. consumer dedupes on event id before charging

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

Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.