Design PhonePe's UPI Payment Switch

Problem

Design the UPI payment switch — the core routing layer that processes UPI transactions between payer PSP, NPCI, and payee PSP.

Requirements

Functional:

  • Initiate, route, and confirm UPI transactions
  • Handle collect and pay flows
  • Callback / webhook to merchant
  • Transaction history query

Non-functional:

  • 1M TPS at peak (festival sales)
  • p99 latency < 1.5s (NPCI mandate)
  • Zero fund loss — atomicity across ledger entries
  • Regulatory audit log retention: 7 years

Discussion points

  1. NPCI protocol constraints and timeouts
  2. Idempotency across retries with bank failures
  3. Double-entry ledger design
  4. Saga pattern for distributed transaction across PSPs
  5. Horizontal scaling of stateful switch nodes
added …
LeaderboardSalaryAccount