Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Security, Auth & Payment Systems
RELIABILITY, SECURITY & CASE STUDIES · SUBTOPIC

Idempotent Payments & Double-Entry Ledgers

Prevent double charges, race conditions, and silent drift in financial systems.

AdvancedPart of Security, Auth & Payment Systems
Practice in AI HLD
Subtopics in Security, Auth & Payment Systems (2)
OverviewOAuth, JWT & AuthPayments & Ledgers

In plain words

Every payment gets a unique tracking sticker (idempotency key) so flaky Wi-Fi retries never charge twice, and every dollar moved writes a matching "-$50 from Alice" and "+$50 to Bob" receipt that can never be erased.

Think of it like…

Pen-written checkbook ledger where mistakes are fixed with a new adjustment entry, never white-out.

Loading interactive diagram
Loading interactive exercise

Theory & how it works

Always use integer minor units (cents), NEVER floating point

In IEEE-754 floating point, 0.1 + 0.2 === 0.30000000000000004. Store $19.99 as 1999 (BIGINT in cents) plus an explicit ISO currency code (USD).

Key points & practical guide

Summary checklist

  • Store money as integer minor units (1999 cents) + currency
  • Enforce idempotency keys end-to-end (Client → API → Stripe)
  • Run daily settlement reconciliation against PSP reports

When to use it

  • E-commerce checkout, wallets, marketplaces, billing

Watch out for

  • Using FLOAT/DOUBLE for prices or updating balances without row locking / optimistic version checks

Quick check

Loading quiz
Previous subtopic
OAuth 2.0, JWTs & Revocable Sessions
Back to overview
Full Security, Auth & Payment Systems Lesson