How would you design a payment/ledger system for correctness under failure?
Reviewed by Gurusankar M.
Short Answer
Correctness over availability (lean CP). Use idempotency keys so retries don't double-charge, a double-entry immutable ledger (every movement is balanced debits/credits, append-only) as the source of truth, strong consistency / transactions on the ledger, sagas for multi-step flows, and reconciliation jobs to catch drift.
On this page
Concept Made Simple
Coffee Chat Question
“How would you design a payment/ledger system for correctness under failure?”
Remember It Faster
Mind Map Answer
- Idempotency
- keys → no double charge on retry
- Double-entry ledger
- balanced, append-only, source of truth
- Consistency
- strong/transactional on money
- Safety net
- reconciliation + audit
Think Beyond the Expected
What If?
A payment request times out and the client retries — how do you guarantee they aren't charged twice?
The client sends an idempotency key with both attempts. The server records the key with the outcome atomically; on the retry it detects the key and returns the ORIGINAL result instead of charging again. Combined with the append-only ledger, this makes the charge exactly-once from the user's perspective.
Real World
Real payment systems (Stripe-like) are built on idempotency keys + an immutable double-entry ledger + strong consistency + reconciliation; they deliberately trade some availability for correctness because money must never be wrong.
Interviewer's Expectation
Keywords they're listening for:
- correctness over availability (CP)
- idempotency keys
- double-entry immutable ledger
- strong consistency/transactions
- saga for multi-step
- reconciliation/audit
Common Mistakes
- Mutable balance field instead of an append-only ledger
- No idempotency (double charges on retry)
- Choosing availability over correctness for money
Best Practices
- Idempotency keys + immutable double-entry ledger
- Strong consistency on money; sagas for flows
- Reconciliation + audit trails
Follow-up Questions
- Why a double-entry ledger instead of a balance column?
- How do sagas handle a multi-service payment flow?
- What does reconciliation catch?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Databases (System Design) Interview question: "How would you design a payment/ledger system for correctness under failure?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair