Skip to content

Case study: Payment system & ledger

Design a Stripe-grade payment system: end-to-end Idempotency-Key deduplication, immutable double-entry bookkeeping, transactional outbox sagas, and T+1 settlement reconciliation.

35 min9 steps

By the end you can
  • Estimate payment TPS, immutable ledger growth, idempotency store sizing, and external PSP latency bounds
  • Prevent double charges across network timeouts and retries using atomic Idempotency-Key state transitions
  • Model money movements as append-only double-entry ledger postings in integer minor units
  • Coordinate local ledger commits with external PSP calls via the transactional outbox, sagas, and reconciliation

Pin down what you are building

Authorize, capture, refund

  • Append-only double-entry ledger; T+1 reconciliation

Zero duplicate/lost payments

  • Integer minor units + currency; Idempotency-Key

Why must a payment system store monetary amounts as integer minor units (e.g. `1999` cents + `'USD'`) rather than IEEE-754 `float` or `double`?

Answer this step to continue.