Design a Payment System
Design the payment backend for an e-commerce marketplace: charge buyers through external payment processors, keep an accurate ledger, pay out sellers, and handle refunds. Plan for 5,000 payments per second at peak. Money must never be lost or double-charged.
How the interview goes
Five phases, and questions the interviewer is likely to ask in each.
1. Requirements
- What does 'never lose money' require of the design?
- Which operations must be strongly consistent?
Show a hintHint
Ask which numbers must always add up, and who audits them.
2. High-level design
- What is stored before you call the processor, and why?
- How do other services learn a payment succeeded?
Show a hintHint
Record your intent durably before talking to the outside world.
3. Deep dive
- Walk me through a retry after a timeout.
- How do you represent a partial refund in the ledger?
Show a hintHint
A timeout means 'unknown', not 'failed'.
4. Scaling
- How do you shard the ledger without breaking balanced entries?
- What happens when the processor is down for 10 minutes?
Show a hintHint
Some data must never be updated in place, only appended.
5. Trade-offs
- Synchronous versus asynchronous confirmation to the buyer?
- Build your own ledger or use an external one?
Show a hintHint
Consider what the buyer sees while the outcome is still unknown.
Practice this with an AI interviewer
Write your design doc with live diagrams while the interviewer asks one question at a time and pushes on your choices. Get a scored debrief with what to study next.
Start this interview