Lesson 2 of 16
45. Design a Payment System (Stripe / UPI)

45.1 What do you ask first?

3 min read+10 XP

Step 1: Requirements (5 minutes)

LetterCandidate asksInterviewer answers
Scope"Accept payments, refunds, payouts to merchants? Which methods? Do we store card numbers? Subscriptions?""Payments and refunds by card and UPI, and a record of merchant balances for payouts. Card data goes to a certified vault; we keep tokens. Skip subscriptions."
Count"How many payments?""Up to about 2,000 payments a second at peak; tens of millions a day."
Access pattern"How do results come back?""Sometimes immediately, often seconds or minutes later by callback; sometimes never, and we must find out."
Latency"How fast must a payment complete?""A few seconds for the customer; callbacks can be later."
Exactness"Can we lose or double-charge a payment? Can balances be approximate?""Never. Every paisa must be accounted for and auditable."

Agreed requirements:

  • Functional (verbs): merchants create payments; customers pay by card or UPI; the system captures, refunds, records merchant balances, notifies merchants (webhooks), and reconciles with banks.
  • Non-functional (adjectives): exactly-once effect (no double charges), never lose a payment, correct and auditable money records, highly available, secure (no raw card data in our systems, signed callbacks), resilient to slow and silent banks.

Interviewer pushback:

  • "Why not just store a balance column per merchant and update it?" → Because a single number can't be audited: when it's wrong, you can't tell why. A ledger of balanced entries explains every change, and the balance is derived from it (45.7).

Memory code: "Ask how money moves, how results come back, and how you'll prove it later."