HardπŸ‘€ 8-15 years 1 min read

How would you design a payment/ledger system for correctness under failure?

Reviewed by Gurusankar M.

Asked inAmazonMicrosoftbankingStripe-like
#payments#ledger#idempotency#double-entry#consistency
Report issue

⚑ 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.

β˜•Coffee Chat Question

Concept Made Simple

β€œHow would you design a payment/ledger system for correctness under failure?”

🧠Mind Map Answer

Remember It Faster

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

πŸ”₯What If?

Think Beyond the Expected

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

  • 1Why a double-entry ledger instead of a balance column?
  • 2How do sagas handle a multi-service payment flow?
  • 3What does reconciliation catch?

🧩Related Technologies

idempotencydouble-entry ledgersagareconciliation

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?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission β€” at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions