01Chapter 1: Clarifying requirements and scopePayment designs usually go wrong because nobody agreed on what to build. This chapter shows how to turn "build a payment system" into a scope you can design against.2 min read
02Chapter 2: Who takes part in a card paymentThis chapter assumes you know basic HTTP and REST ideas and can read short Python snippets. It names the parties in a card payment and shows who talks to whom. Later chapters build on these roles when they cover authorization, capture, and settlement.2 min read
03Chapter 3: Authorization, capture, and settlementThis chapter assumes you know the five actors in a card payment (merchant, PSP, acquirer, card network, issuer) and basic HTTP and database concepts. Here you will see the three steps that move a payment from "customer clicked pay" to "merchant has the money".2 min read
04Chapter 4: Representing money correctlyThis chapter assumes you know basic Python and SQL, and that you know why floating-point numbers are imprecise. It covers how a payment system should store and move amounts.2 min read
05Chapter 5: Designing the payment APIThis chapter assumes you know basic HTTP and REST, and that you can read short Python snippets. The API is the contract between merchants and your system. Mistakes here are hard to undo, because merchants build on every field you publish.2 min read
06Chapter 6: Making payments idempotentThis chapter assumes you know basic HTTP and REST, relational transactions and unique constraints, and how timeouts and retries behave in distributed systems. You should also be able to read short SQL and Python snippets.2 min read
07Chapter 7: Modeling payments as a state machineThis chapter assumes you know relational database basics, including transactions, and can read short Python and SQL snippets. It also assumes you know the authorization, capture, and settlement steps from the earlier chapters.2 min read
08Chapter 8: Recording money movement in a double-entry ledgerThis chapter assumes you know relational transactions and unique constraints. It also assumes you have read the chapters on the payment state machine and on representing money as integer minor units.2 min read
09Chapter 9: Handling timeouts, failures, and retriesThis chapter assumes you know basic HTTP, relational transactions and unique constraints, and the idempotency-key pattern from the previous chapters. You should also be able to read short Python snippets.2 min read
10Chapter 10: Keeping state consistent: outbox and sagasThis chapter assumes you know database transactions, the retry and idempotency ideas from earlier chapters, and short Python and SQL snippets. It covers two patterns that keep a payment service consistent when one action touches the database and something else.2 min read
11Chapter 11: Webhooks and asynchronous status updatesThis chapter assumes you know HTTP basics, idempotent APIs, and the payment state machine from earlier chapters. It covers how a payment system learns about, and reports, status changes that happen after the original API call returns.2 min read
12Chapter 12: Tokenization, encryption, and PCI DSS scopeThis chapter assumes you know basic HTTP APIs, relational databases, and how to read short Python snippets. It explains how to keep card data out of most of your system.2 min read
13Chapter 13: Integrating and routing across PSPsThis chapter assumes you know how authorization and capture work, how idempotency keys protect against duplicate charges, and how retries and timeouts behave. Here we look at connecting your system to more than one payment service provider (PSP) and choosing which one handles each payment.2 min read
14Chapter 14: Refunds, voids, and chargebacksThis chapter assumes you know the authorization, capture, and settlement steps, the payment state machine, and the double-entry ledger from earlier chapters. It covers the three ways a payment can be undone.2 min read
16Chapter 16: Fraud and risk checksThis chapter assumes you know the payment lifecycle, idempotent APIs, and the payment state machine from earlier chapters. It also assumes you can read short Python snippets. Fraud checks decide whether a payment attempt should proceed, be challenged, or be refused, before money moves.2 min read
17Chapter 17: Scaling and availabilityThis chapter assumes you know HTTP APIs, relational transactions and unique constraints, and how timeouts and retries work. It builds on idempotency, the outbox pattern, and PSP routing from earlier chapters.2 min read
18Chapter 18: Monitoring and observabilityThis chapter assumes you know the payment lifecycle, idempotent APIs, retries, and the outbox pattern from earlier chapters. It covers how to see what a payment system is doing, so you can find problems before merchants do.2 min read