Case study: design a payment system
Interview question: design the payment system for an online marketplace. Buyers pay by card, sellers get paid, the marketplace keeps a fee, and an outside provider moves the actual money. A payment must never be charged twice or lost, even when calls time out. Where do you start?
In this lesson you'll learn to
- Turn the payment question into requirements and rough numbers, and explain why correctness, not scale, drives the design.
- Record money movements in an append-only double-entry ledger, with amounts in integer minor units.
- Run each payment through a state machine with the provider, using idempotency keys and verified, deduplicated webhooks.
- Get exactly-once effects from idempotency and the outbox, recover stuck payments, and reconcile against the provider's reports.
Create a free account to open this lesson
It's free. You'll get every free lesson, quizzes that save your progress, daily flashcards and streaks.