01Chapter 1: Clarifying requirements and scopeA payment system is easy to describe and hard to bound. "Let merchants take card payments" can mean a two-week integration with a hosted provider or a multi-year build with its own bank connections. This chapter shows how to turn that sentence into a scope you can design against.6 min read
02Chapter 2: Who takes part in a card paymentThis chapter assumes you know basic HTTP APIs, relational database concepts such as transactions and unique constraints, and how timeouts and retries behave in distributed systems. You do not need prior payments knowledge. Here you learn who the parties in a card payment are, what each one owns, and5 min read
03Chapter 3: Authorization, capture, and settlementThis chapter assumes you know the actors in a card payment (merchant, PSP, acquirer, card network, issuer), basic HTTP APIs, and relational database transactions. It covers the three phases that move a card payment from "the customer clicked pay" to "the merchant has money." Each phase has different5 min read
04Chapter 4: Representing money correctlyYou should be comfortable reading short Python and SQL snippets. You should know what a relational database column type is, and what an HTTP JSON payload looks like. Nothing else is needed. The chapter covers how a payment system stores, moves, and calculates money so that no cent is created or lost5 min read
05Chapter 5: Designing the payment APIThis chapter covers the public API of a payment service: its resources, its endpoints, and how it reports results and errors. It assumes you know basic HTTP and REST, can read short SQL and Python snippets, and understand timeouts and retries. Idempotency, the state machine, and the ledger each get 6 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 Python and SQL snippets.5 min read
07Chapter 7: Modeling payments as a state machineA payment changes over time. It is created, authorized, captured, and sometimes refunded or voided. A state machine makes those changes explicit. This chapter shows how to model a payment as one, how to enforce the allowed transitions safely under concurrency, and which edge cases cause real bugs.5 min read
08Chapter 8: Recording money movement in a double-entry ledgerThis chapter assumes you know relational transactions and unique constraints, can read short Python and SQL snippets, and have read the chapters on money representation and the payment state machine. Here you will build the ledger, the record of where every unit of money is.5 min read
09Chapter 9: Handling timeouts, failures, and retriesThis chapter assumes you know HTTP timeouts, the idempotency key pattern from the previous chapters, and the payment state machine (created, authorized, captured, and so on). It covers what to do when a call to a PSP (payment service provider) or to your own service does not return a clear ans5 min read
10Chapter 10: Keeping state consistent: outbox and sagasThis chapter assumes you know relational transactions, the payment state machine and idempotency keys from earlier chapters, and basic message queues. You should also be able to read short Python and SQL.6 min read
11Chapter 11: Webhooks and asynchronous status updatesThis chapter assumes you know the payment state machine, idempotency keys, and the transactional outbox from earlier chapters. It also assumes basic HTTP and SQL. It covers how a payment system receives status changes from PSPs and how it reports them to merchants.4 min read
12Chapter 12: Tokenization, encryption, and PCI DSS scopeThis chapter assumes you have read the earlier chapters on the payment actors, the idempotent API, and the payment state machine. You should also be comfortable with TLS, symmetric encryption, and short Python snippets. The goal is to decide where card numbers may exist in your system, and to keep t4 min read
13Chapter 13: Integrating and routing across PSPsThis chapter assumes you know the payment lifecycle (authorize, capture, settle), idempotency keys, and the payment state machine from earlier chapters. You should also be comfortable reading short Python snippets.5 min read
14Chapter 14: Refunds, voids, and chargebacksThis chapter covers the flows that move money backwards or cancel it before it moves. It assumes you know the authorization, capture, and settlement steps. It also assumes you have seen the payment state machine, idempotency keys, and the double-entry ledger from earlier chapters.5 min read
15Chapter 15: Reconciling with PSP and bank reportsReconciliation compares your own records with the reports that outside parties send you, then investigates every difference. This chapter assumes you know the payment lifecycle (authorization, capture, settlement), the double-entry ledger, and idempotency keys from earlier chapters. It also assumes 5 min read
16Chapter 16: Fraud and risk checksThis chapter assumes you have read the earlier chapters on the payment lifecycle, idempotency, and the payment state machine. You should be comfortable reading short Python snippets and thinking about latency in a request path.5 min read
17Chapter 17: Scaling and availabilityThis chapter assumes you have read the earlier chapters on idempotency, the payment state machine, retries, the transactional outbox, and PSP routing. It also assumes you know basic database replication and load balancing.5 min read
18Chapter 18: Monitoring and observabilityThis chapter assumes you have read the earlier chapters on idempotency, the payment state machine, the ledger, retries, webhooks, and reconciliation. It also assumes you know what a metric, a log line, and a distributed trace are in general terms. Here we apply those tools to a payment platform, whe5 min read