Design a Payment System
A full case study of a payment backend, covering idempotency, double-entry ledgers, unknown outcomes from banks and daily reconciliation.
Requirements
A payment system lets a customer pay a merchant, moves the money through a payment provider or bank, and records every step so the books balance.
Functional:
- Create a payment (card, UPI, wallet) for a merchant order.
- Report its status: pending, success or failed.
- Refund a payment, fully or partly.
- Settle money to merchants and produce statements.
Non-functional:
- Correctness first: never charge twice, never lose a payment, always explain every rupee.
- Auditable: nothing is silently edited or deleted.
- Available, but a safe error beats a wrong success.
- Secure: card data is handled under PCI DSS (Payment Card Industry Data Security Standard), usually by delegating it to a provider.
1 of 11