Code RoomPaymentIntent lifecycle and idempotency
HardPrep Room Coding #3494

PaymentIntent lifecycle and idempotency

System designNetworking & APIsSenior–Staff~45 min

Design a PaymentIntent object that models the full lifecycle of a single payment (created → requires_action → processing → succeeded/failed) and stays correct under aggressive client and network retries. The same client may call `confirm` 5 times because of timeouts, a webhook from the bank may arrive before the synchronous response, and a `cancel` can race a late `authorize`. ~30,000 confirms/sec at peak. Requirement: a given PaymentIntent must never result in two authorizations or a charge after a successful cancel, and every API call must be safely replayable. How do you model the state, transitions, and concurrency control so the object is the single source of truth?

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts (data model, bottlenecks, consistency, failure modes) and name the trade-offs you are making.

Clarify5:00 left
Estimate5:00 planned
Design15:00 planned
Deep dive12:00 planned
Failure8:00 planned
0:00
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.