All problems

Payment System

Move money exactly once — never drop it, never double-charge.

hard~24 min Pro Simulator · +130 ptsTheory +36 pts
The build

Process checkouts exactly once through a flash sale — losing no money as PSP callers die and the ledger gets slow.

Payments must be idempotent and never double-charge. Record the intent on a strongly-consistent ledger, then call the payment processor asynchronously through a queue with retries.

Components in play

  • API GatewayAuth + idempotency-key check on every request.
  • Payment serviceValidates and records the intent idempotently.
  • PSP queueDecouples the slow processor call, with retries.
  • PSP callersWorkers that call the bank / card network.
  • LedgerDouble-entry, strongly-consistent record of truth.

Graded on these SLOs

  • ≥ 99.00%Payments succeed
  • ≥ 6.0k rpsCheckout rate
  • ≤ 220 msCheckout p99
  • ≤ 90%Headroom
  • ≤ 13Lean footprint
Base 6,000 rps36s run 4 scripted failures

The brief

Design a payment system like Stripe: accept a charge, talk to banks / card networks, and record everything in a ledger. Correctness is everything — no lost payments, no double-charges — even when clients retry and downstream processors are slow or flaky.

Functional

  • Accept and authorize payments
  • Talk to external processors (PSPs)
  • Maintain a ledger + reconciliation

Non-functional

  • Exactly-once / idempotent processing
  • Strong consistency on the ledger
  • High availability — money can't just drop

Read the deep dive

17 min read

A payment system has one property every other system can live without: it has to move money exactly once. If a redirect service drops a request, the user hits refresh. If a payment service drops, double-fires, or half-commits a request, someone is out real money and a regulator eventually wants to know why. The hard part is that the failures you must survive are not exotic. A client retries after a timeout, a bank call hangs for four seconds, a worker process dies mid-charge, the ledger gets slow under contention. All of those happen on a normal Tuesday, and especially during a flash sale. This guide builds the design the way you should build it in an interview: start from the requirements, do the arithmetic, then assemble the architecture piece by piece and justify every capacity number. The target is the same reference the SysGym simulator grades you against: 6,000 checkouts per second spiking to 12,000 during a flash sale while PSP callers die and the ledger slows, with a hard floor of 99 percent of payments completing and zero double-charges. By the end you should be able to derive that design yourself, not memorize it.

Warm-up: design decisions

Optional theory to prime the calls a senior engineer would make before you build.

Pro

Solving is a Pro feature

Unlock the on-canvas AI design coach, per-run design reviews, the chaos simulator and all 12 problems for $15/month.

  • AI design coach on your canvas — pins failure points & over-engineering
  • Honest AI design review on every run
  • All 12 problems + unlimited chaos simulator
  • Points, levels & leaderboard
Get started