HardExperience level: 8-15 years1 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.

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

  1. Why a double-entry ledger instead of a balance column?
  2. How do sagas handle a multi-service payment flow?
  3. 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.
Open inChatGPTGeminiClaude

Was this answer helpful?

Affiliate links

Equipment for a comfortable, productive setup.

As an Amazon Associate I earn from qualifying purchases.