Scope
Functional
- Merchants create payment orders; customers pay via UPI (collect, intent/QR), cards, netbanking.
- Status updates to merchants (API + webhooks); refunds; daily settlements to merchants.
Non-functional
- No double charges, no lost payments: correctness over availability.
- Auditability: every state change traceable.
- p99 < 300 ms for our own APIs (bank latency is outside our control).
- Compliance: PCI-DSS for cards, RBI data localisation.
Size
- 20M transactions/day → ~230/s average; festival sales peak at 5–10k/s.
- Each transaction generates ~5–10 ledger entries and several events.
APIs
POST /v1/orders {amount, currency, merchant_ref} Idempotency-Key: ...
POST /v1/payments {order_id, method: upi_intent|card|...} → {payment_id, action: {upi_uri | redirect}}
GET /v1/payments/{id}
POST /v1/refunds {payment_id, amount} Idempotency-Key: ...
Webhooks → merchant: payment.captured, payment.failed, refund.processedThe architecture
The 30-second summary
Say it in the interview
"Payments are a strict state machine in a relational store, with idempotency keys on every inbound API, stable references on every outbound call, and deduplicated callbacks. Timeouts leave payments PENDING until a callback or status poll resolves them, never assumed failed. Money movements are recorded in an append-only double-entry ledger, events go out through an outbox to signed, retried webhooks, and daily reconciliation against bank files catches anything that slipped."
Follow-up questions the interviewer may ask
- How do you guarantee a customer is charged once?
- The gateway times out. Did the payment happen?
- How do you design the ledger?
- How do you handle refunds?
Model answers to each of these are in the book.