Design a Payment System
HardSystem design · Payments · Stripe · Airbnb · DoorDash
Design a payment system for an online marketplace that takes card payments through an external payment processor (PSP). Buyers pay; the platform authorises, captures, refunds, and later pays out sellers, while keeping a correct double-entry ledger. Focus on idempotency, the payment state machine, PSP webhooks, ledger design, reconciliation and PCI scope. Out of scope: fraud model internals and building a card network or bank connection.
Requirements
- Require idempotency keys on every money-moving operation, with a durable key store
- Model the payment state machine and tolerate late, duplicate and out-of-order PSP webhooks
- Keep an append-only double-entry ledger in integer minor units; split buyer payment into fees and seller payable
- Reconcile against settlement files, handle refunds and payouts, and keep raw card data out of scope