Sub topic 1
Clarifying requirements and scope
Payment 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.
Prerequisites
This chapter assumes you know:
- Basic HTTP and REST API concepts.
- Relational database basics, including transactions and unique constraints.
- What timeouts and retries are in a distributed system.
You do not need payments knowledge yet. Later chapters cover each actor and step in detail.
Why scope comes first
A system that "accepts payments" could be a checkout page that forwards requests to a provider. It could also be a full processor that connects to card networks. These have very different costs, risks, and compliance duties. Fix the scope first, because every later choice depends on it.
Functional requirements
For this tutorial, assume a platform that accepts card payments for merchants. It must:
- Create a payment and authorize it.
- Capture, void, or refund a payment.
- Return the current status of a payment.
- Notify merchants of status changes.
- Provide records for finance and reporting.
Non-functional requirements
The non-functional requirements shape the architecture more than the feature list does.
| Requirement | Typical target | Design consequence |
|---|---|---|
| Correctness | No double charge, no lost money | Idempotent API, double-entry ledger |
| Durability | An acknowledged payment is never lost | Write to a transactional database before replying |
| Availability | Checkout works when one dependency fails | Retries, multiple providers |
| Latency | A few seconds, mostly spent on external networks | Asynchronous steps where possible |
| Compliance | PCI DSS (the card industry security standard) | Tokenization keeps raw card numbers out of most services |
| Auditability | Every money movement is explainable | Append-only records |
Questions to ask
- Which payment methods are in scope: cards only, or also bank transfers and wallets?
- Do we connect to a payment service provider (PSP) or directly to card networks?
- Which currencies and countries do we support?
- What is the expected peak volume, in payments per second?
- Do we need refunds, chargebacks, and payouts in version one?
Common errors
- Treating correctness as one requirement among many. In payments it outranks speed. A slow payment is an annoyance. A duplicate charge is a loss of money and trust.
- Leaving compliance for later. Storing raw card numbers puts the whole system in PCI DSS scope.
- Ignoring failure behavior. Decide early what happens when a provider times out.
- Building everything at once. Chargebacks and multi-provider routing can wait until the core flow is correct.
Exercise
A teammate says, "Our target is 99.99% availability, so we can skip idempotency and just retry fast." Which requirement does this ignore, and why does it matter?
Show answer
It ignores correctness. Retrying without idempotency can charge a customer twice when the first request succeeded but its response was lost. Availability and correctness must be met together, and correctness takes priority.