Question presented to candidate:
"Design the payment system for a marketplace like Etsy or Airbnb: buyers pay by card, the platform keeps a commission, and sellers are paid out to their bank accounts. We process about 10 million payments a day. Walk me through the components, how money is recorded, and how you make sure nothing is ever lost or paid twice."
What a strong answer should cover:
The two money flows: pay-in (buyer card to platform through a payment service provider, PSP) and payout (platform to seller bank), and why the platform never touches raw card numbers (tokenization, hosted fields, smaller PCI DSS scope)
A double-entry ledger as the source of truth: append-only entries that sum to zero, amounts in integer minor units, balances derived from entries
The payment lifecycle: authorize, capture, settle, refund, chargeback, with each state change written durably and driven by PSP webhooks
Correctness under concurrency and retries: idempotency keys end to end, conditional or versioned balance updates so payouts cannot overdraw
Reconciliation of the ledger against PSP settlement reports, and what to do with mismatches
Scale numbers: payment TPS is modest; the hard parts are correctness, auditability and integration with slow external systems
Clarifying questions expected:
Are we the merchant only, or a marketplace holding money for sellers (which changes the ledger and the regulation)?
Which payment methods, currencies and countries? Do we need multi-currency payouts?
Can we use a PSP such as Stripe or Adyen, or are we building card network connectivity ourselves?
Code / implementation expected: Optional โ the example runs a double-entry ledger for a marketplace order: an idempotent charge, a refund, a payout race and a reconciliation.
system-design
case-study
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Backend engineers preparing for system design rounds at fintech, marketplace and e-commerce companies, and anyone who wants to understand where money actually lives inside a payment system.
Difficulty: Hard
Verified with: Node 22.22 and Python 3.12 (identical output). Stripe behaviour (amounts in minor units, a 7-day authorization window for most online card payments, shortened to 5 days for Visa online merchant-initiated transactions from April 2024) is from the Stripe docs pages "Supported currencies" and "Place a hold on a payment method". PCI DSS dates are from the PCI Security Standards Council.
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the words an interviewer expects. Every number in the worked example comes from running the program; the Verified section quo
The solution is hidden so you can try first
20 min read ยท 16 sections
4
Read the code
Marketplace payment on a double-entry ledger: integer cents, an idempotent charge, a refund, a payout race and daily reconciliation