Learning on Web Dev Open is free for all.

Interview Prep · System DesignDesign a payment system
← System Design

Design a payment system

Hard50 minFree, no account

Money, a third party that times out ambiguously, and a ledger that must balance forever.


The question

Design the service that charges a customer when they place an order: authorise, capture, refund.

It talks to an external payment provider. Assume the provider sometimes times out without telling you whether the charge happened.

Functional
  • Charge a customer for an order; handle success, decline and failure.
  • Full and partial refunds.
  • A complete, auditable record of every money movement.
Non-functional
  • 10k payments/sec at peak.
  • Never double-charge, under any retry or crash.
  • Totals reconcile exactly with the provider, daily.
50:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Idempotency keys recorded before the external call, and forwarded30
  • Treated a timeout as unknown, with asynchronous resolution20
  • An append-only double-entry ledger in integer minor units25
  • A saga with real compensations, durably driven15
  • Daily reconciliation against the provider10

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only