Synthesis and Self-Test
Synthesis
The key protects an HTTP request; the thing you actually care about is a business operation
An idempotency key's scope is precisely one request, from one API user, inside one retention window (see Idempotency: the contract). The invariant your business needs — "order 4471 is charged once, ever, by anybody" — has a different scope on all three axes: it spans your web client and your retry queue and a human in an admin panel, it must hold across API keys on a platform, and it must hold forever, not for a day. Every row of the double-charge taxonomy in the Money invariants part except the first one lives in that gap. This is why the key is necessary and not sufficient, and why the server-side defense is a uniqueness constraint on (order_id, operation) in your database — a constraint Stripe cannot enforce for you because only you know what "the same payment" means.
A recovery point is a saga log with one participant
The atomic-phases design (see Idempotency: the machinery) splits a request at every point where it touches foreign state, and commits each phase's local effects together with an advance of the recovery point, in one local transaction. A saga (see Sagas and compensation) splits a workflow at every service boundary and commits each step locally with a durable record of how far it got. These are the same construction: local transactions strung between irreversible external calls, with a persisted cursor that tells a crashed process where to resume. The only structural difference is whether the steps are compensatable — inside one service they usually aren't yet, so you resume forward; across services they are, so you can also unwind. Recognizing them as one pattern is what makes the transactional outbox (see Idempotency: the machinery) the obvious durability mechanism for the saga orchestrator (see Sagas and compensation) rather than a separate trick.
"why not capture immediately?" has exactly one general answer — capture is the pivot
Authorization is cheap to undo: cancel the intent, the hold releases, and in most cases the cardholder never sees anything on a statement. Capture is not: the reversal is a refund, which is a new, visible, fee-bearing money movement in the opposite direction (see Authorize vs capture, Card network). That makes capture the pivot transaction of the payment saga (see Sagas and compensation) — the step after which the flow can only go forward. Every business reason for manual capture is the same engineering move: take work that might fail — fraud review (see Radar), inventory confirmation, the final amount not being known yet — and put it on the compensatable side of the pivot. The two-phase charge is not a payments quirk; it is the card network having built the pivot into the protocol forty years before anyone wrote the word "saga."
Three organizations, three decades, one answer to the lost response
Your client cannot tell a lost response from a failed request, so Stripe gave it a replay contract: the idempotency key (see Idempotency: the machinery). Stripe's acquiring side cannot tell a lost authorization response from a declined one, so the card network gave it a reversal message and an advice mechanism (see Card network). Stripe cannot tell a lost webhook from an unprocessed one, so it retries and requires your consumer to dedupe on event.id (see Webhooks). Three independent systems, built decades apart by parties with nothing in common, all reached the identical conclusion: exactly-once delivery is not available, so make the receiver idempotent and retry. If you find yourself designing the fourth link in this chain, you already know what the answer is.
Anything synchronous in the money path is an availability multiplier, so the design pushes work outward
Radar scores before the authorization leaves for the network, so its latency is additive to the customer's wait and its availability multiplies into the payment's (see Radar). A rate limiter and load shedder sit in front of everything, so their failure mode has to be graded rather than binary (see Rate limiters and load shedding). The consistent response across both is to degrade instead of failing — a risky payment goes to review rather than being blocked, non-critical traffic is shed before critical traffic is — and to move everything that can possibly be asynchronous off the request path entirely, which is what webhooks are for (see Webhooks). Read in this order, webhooks stop looking like an awkward callback mechanism and start looking like the thing that keeps the synchronous path short enough to be reliable.
A stable ID is what converts an ambiguous state into a query
The window between "I sent the request" and "I recorded the result" is the only genuinely ambiguous state in the entire system (see Idempotency: the machinery, Money invariants). It cannot be eliminated — but it can be made resolvable, and the thing that resolves it is a durable object with an ID you wrote down before you called (see PaymentIntent state machine). This is why replacing POST /charges with a PaymentIntent was not an API-aesthetics decision: a verb leaves you guessing after a timeout, a noun leaves you with a GET. The same reasoning produces the ledger in the Money invariants part — an append-only record of every irreversible thing you did, so that the question "what is true?" is always answerable by reading, never by inferring.
Self-Test
Question 1
Two requests carrying the identical Idempotency-Key arrive at the same instant. Trace exactly what each one gets, explain why the loser is not simply made to wait for the winner's result, and say what a correct client does next.
Show answer
The key's row is written before any other work, in its own local transaction, and that write is the arbiter — the database serializes the two attempts and one of them loses the race for the row (see Idempotency: the machinery). The winner proceeds through its atomic phases. The loser gets 409 Conflict — Stripe's API reference lists exactly this cause: "The request conflicts with another request (perhaps due to using the same idempotent key)." Note also that a 409 is not cached under the key (see Idempotency: the contract), because execution never began for that request; only requests that actually entered execution get their status and body saved.
Why not wait? Because waiting would mean holding an inbound HTTP connection open for the entire duration of a foreign call to a card network — seconds, sometimes — with no upper bound, which converts every retry storm into a connection-pool exhaustion event, and still leaves you needing a timeout-and-answer path. Worse, the winner may have crashed, in which case the waiter would block until the lock's expiry window elapsed. Returning immediately hands the decision back to the client, which is the only party that knows how long it is willing to wait.
What a correct client does: back off briefly and retry with the identical key and body — never a fresh key. That either returns the winner's now-cached response (with Idempotent-Replayed: true), or another 409 if it is still running, or lets you take over the lock if the original process died and the lock expired (see Idempotency: the machinery). The failure mode to avoid is treating 4xx as terminal: mark the order failed on a 409 and the winner still succeeds seconds later, leaving a succeeded PaymentIntent at Stripe with no matching order in your database — a mismatch only reconciliation will ever surface (see Money invariants).
Question 2
A customer was charged twice. Every call your system made carried an idempotency key, and the key logic is provably correct. Name three structurally different ways this still happened, and give the actual defense for each.
Show answer
The key's scope is one caller, one key, one retention window (see Idempotency: the contract). Every double-charge lives outside one of those three boundaries (see Money invariants):
(a) A fresh key for the same logical operation. Either the client mints uuid4() at retry time — which makes every "retry" a first-ever request by contract — or the retry happens after the key was pruned (Stripe's wording is a floor: keys are removable once at least 24 hours old, and a reused pruned key generates a new request). A dead-letter queue drained the next morning hits this exactly. Defense: derive the key from business identity — charge-order-{id}-v{pricing_version} — generated once, stored with the attempt row, reused verbatim.
(b) Two different callers. A retry worker and a human in an admin panel both act on order 4471, each generating a perfectly correct key of their own. Stripe cannot deduplicate these because from its side they are two different operations. Defense: a uniqueness constraint at the business layer — UNIQUE (order_id, operation) in your database — which is the only place the invariant "this order is charged once, by anybody, ever" can be expressed.
(c) The crash window. The charge succeeded at Stripe, the worker died before recording it, and recovery re-charged instead of asking. Defense: write intent before you act — persist (order_id, idempotency_key, status=pending) in its own committed transaction before the call, so recovery can retry the same key or GET the PaymentIntent by its stable ID (see PaymentIntent state machine) rather than guessing. The window cannot be eliminated; it can only be made resolvable by a query.
The unifying line: the idempotency key closes exactly one row of the taxonomy — the network-level retry. It was never the whole defense, and a system that treats it as such has six open holes (see Money invariants).
Question 3
Your architect proposes wrapping reserve-inventory → authorize-card → create-shipment → capture in a distributed transaction so it's all-or-nothing. Give the one reason that ends the discussion immediately, two more that would end it anyway, and name what you lose by using a saga instead.
Show answer
The reason that ends it: one of the participants is a card network, and it will never vote. 2PC requires every participant to implement prepare/commit/abort and to hold its prepared state until a coordinator decides. Visa has no such API, will not hold a lock on the issuer's behalf for your coordinator, and is not going to add one (see Sagas and compensation). You cannot run a protocol that a mandatory participant does not speak.
Two more that would end it anyway: (1) Blocking. If the coordinator dies between prepare and commit, a participant that voted yes can neither unilaterally commit nor unilaterally abort — it holds locks until the coordinator returns. (2) The availability and latency math. A 2PC transaction's availability is the product of its participants' and its latency is the max plus two round trips; holding a row lock across a multi-second call to an issuer caps that row's throughput at well under 1 tx/s.
What a saga gives up: isolation and observer-atomicity. There is no point at which the whole flow becomes visible at once, so another transaction can observe the intermediate state — an order that exists but isn't paid. You buy that back with semantic locks (a status field), commutative updates, or re-read-and-verify — never with a real lock. And compensation is not rollback: a refund does not erase the charge, it appends an opposing, externally visible money movement, with fees that in Stripe's current schedule are not returned (see Authorize vs capture, Sagas and compensation, Money invariants).
The design move that follows: identify the pivot — the step after which the saga can only go forward. In this flow it is capture (see Authorize vs capture). Once you know that, the whole ordering question answers itself: put everything that can fail on the compensatable side of the pivot, and put the pivot as late as you can.
Question 4
Your webhook endpoint has started double-fulfilling orders, and Stripe's dashboard shows delivery failures for the same endpoint. Explain how one cause produces both symptoms, and why adding "check if we already processed this event" to the top of the handler does not fix it.
Show answer
One cause, both symptoms: the handler does the fulfilment work synchronously before returning 2xx. As that work slows — a downstream call degrades, a queue backs up — the handler's response time crosses Stripe's acknowledgement window. Stripe records a delivery failure and retries with exponential backoff (see Webhooks). The retry re-runs the same non-idempotent work, and because the first execution never aborted, the two now run concurrently: two fulfilments, one event. Continued failures also march the endpoint toward being disabled, at which point you stop learning about payments entirely. The delivery failures and the double fulfilment are the same bug seen from two sides.
Why the "already processed?" check doesn't fix it: it is the identical check-then-act race from the Idempotency: the machinery part. Two deliveries of the same event.id both read "not processed" before either writes, both proceed, both fulfil. A SELECT followed by a branch is not atomic with the work it guards, and webhook retries are precisely the concurrency that breaks it.
The actual fix, in two parts. (1) Make the handler fast: verify the signature, persist the raw event, return 200, process asynchronously — so the ack no longer depends on your downstream's latency. (2) Make the consumer idempotent for real: INSERT the event.id against a unique constraint in the same transaction as the effect, and let the conflict — not a prior read — be what stops the duplicate. Then, because Stripe guarantees no ordering, treat the event as a trigger to re-read the object rather than as a state delta, and have your state machine reject backwards transitions (see Webhooks). Note the shape: this is the same three-layer defense as the Idempotency: the machinery part's closing table — key, consumer dedup, unique constraint — each covering what the others don't.
Question 5
Radar must return inside a sub-100ms budget in the authorization path. Say what that budget forces architecturally, then explain why a team whose chargeback rate dropped after tightening their block rules has not demonstrated that the change was good.
Show answer
What the budget forces: scoring sits inline and before the authorization message leaves for the network, so its latency is additive to the customer's wait and its availability multiplies into the payment's (see Radar, What a payment is). That rules out anything unbounded at request time — no cross-service joins, no scans of a card's history, no synchronous model training. Features must be precomputed and retrievable in a single-digit-millisecond lookup from a hot, globally shared store; the model must be bounded-compute; per-merchant rules must evaluate as a pass over an in-memory representation. It also forces a defined behavior for "couldn't answer in time," because failing the payment is not an acceptable timeout policy for a money path. Note the structural split that makes this work: the model is a shared global asset, the rules are per-merchant configuration over its output — so one merchant can be aggressive and another permissive with nothing retrained.
Why a falling chargeback rate proves nothing: it measures only one of the two errors, and the cheaper one. A false negative costs a chargeback, a fee, and the goods. A false positive costs a rejected legitimate customer — usually the larger number, and structurally invisible, because a blocked transaction generates no complaint, no dispute, and no row anywhere that says "this was a good customer." Tighten the threshold far enough and chargebacks approach zero while revenue quietly follows. Worse, there is a feedback loop: labels arrive weeks to months later (the Card network part's dispute window), so today's model is trained on last quarter's disputes, and a blocked transaction never produces a label at all — the model cannot learn from its own blocks (selection bias / rejected inference). The only way to measure the invisible error is to deliberately let a small holdout of risky traffic through and pay for the fraud you find, which is a real cost that has to be budgeted rather than discovered.
What to instrument instead: decline rate and authorization rate alongside chargeback rate, segmented by risk band — and the revenue of the blocked cohort, estimated from the holdout.
Question 6
A dispute arrives on a charge from 85 days ago. Trace what breaks in a system whose payment model is a status column, explain why the authorize/capture split offers no protection here, and say what the money looks like at each of the three record-keeping layers.
Show answer
What breaks: the row was marked succeeded and treated as closed — no further writes expected (see Money invariants). The dispute webhook now mutates a row that downstream systems already read as final: inventory was released, a monthly revenue report went to finance, a loyalty tier was computed including this payment. The UPDATE also destroys the pre-dispute state unless a separate audit log happened to capture it, so "what did we believe on day 30, and why?" becomes unanswerable. In a ledger the problem doesn't arise: the dispute is a new pair of entries, the original charge entries stay exactly as true as they were, and the report that already ran is still correct for the data available when it ran — a timing fact, not a data-integrity failure.
Why authorize/capture doesn't help: the split postpones irreversibility only up to the pivot (see Authorize vs capture, Sagas and compensation). Once captured, the funds have cleared and settled (see Card network), and the reversal mechanism is no longer "cancel the hold" — it is a chargeback initiated by the cardholder with their issuer, reversed through the network, with you as a respondent rather than a participant. The pivot bought you the window before capture; it buys nothing in the ~120-day window after it. This is exactly why succeeded is not a terminal state and why the What a payment is part's Myth/Reality table puts that claim in the myth column.
The three layers: (1) Your ledger — a new debit against revenue and credit to a dispute reserve for the disputed amount, plus a separate entry for the dispute fee, which under Stripe's current schedule is charged regardless of outcome. (2) Stripe's balance transactions — the funds are withdrawn from your balance immediately on dispute creation, booked as type: adjustment with reporting_category: dispute, distinct from the original charge's own balance transaction. (3) Your bank — nothing happens today; the effect appears as a smaller future payout, batched with everything else in that window, which is precisely why reconciling on amount rather than on the stable object ID produces silent false matches (see Money invariants).