Hard👤 8-15 years 1 min read

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

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

Idempotencykeys → no double charge on retry
Double-entry ledgerbalanced, append-only, source of truth
Consistencystrong/transactional on money
Safety netreconciliation + 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 keysdouble-entry immutable ledgerstrong consistency/transactionssaga for multi-stepreconciliation/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.
Open inChatGPTGeminiClaude

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