Design Payment System

Hard

Design a payment processing platform like Stripe or Razorpay. Handle payment initiation, authorization, capture, refunds, webhook notifications, and reconciliation at the scale of millions of transactions per day with zero tolerance for double charges or lost payments.

What to design

  1. What are the core functional requirements for a payment processing platform?
  2. What are the non-functional requirements? Consider consistency, availability, latency, and compliance.
  3. Design the core APIs — payment initiation, status check, refund, and webhook management.
  4. How would you design the payment state machine to ensure no payment is ever lost or double-charged?
  5. How would you implement the double-entry ledger for tracking money flow?
  6. How would you handle communication with external payment gateways and banks reliably?
  7. How would you design the webhook delivery system to notify merchants reliably?
  8. How would you design settlements and reconciliation to ensure financial accuracy?
  9. How would you handle PCI DSS compliance and secure card data?