Sub topic 2
Who takes part in a card payment
This 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.
The five actors
A card payment involves more parties than the customer and the shop. Each one holds a different piece of the truth, and your system must keep its own records of what each one told it.
| Actor | Role | What it knows |
|---|---|---|
| Merchant | Sells goods or services and asks to be paid | The order and the customer's intent |
| PSP (payment service provider) | Gives the merchant one API to accept payments | Merchant account, tokens, payment status |
| Acquirer | The merchant's bank. It receives funds on the merchant's behalf | Merchant settlement account |
| Card network | Routes messages and sets rules (for example Visa or Mastercard) | Which issuer owns a card number range |
| Issuer | The cardholder's bank. It approves or declines and holds the cardholder's funds or credit | Cardholder balance, limits, fraud signals |
When you design a payment system, you are usually building the PSP role, or the merchant-side service that calls a PSP. Some large merchants also connect to an acquirer directly.
How a request travels
The card details move forward through the chain. The decision comes back along the same path.
Money does not move during this exchange. The issuer only agrees to the payment and usually places a hold on the cardholder's funds. The actual transfer happens later, during settlement.
What this means for your design
- Several parties can fail independently. A timeout between you and the PSP says nothing about whether the issuer approved. Your system must be able to ask again and get the true state.
- Each party reports in its own format. A PSP may use its own status names and error codes. Map them to your internal states instead of leaking them to merchants.
- Responsibility is split. The PSP typically handles card data and routing. The issuer handles approval and fraud decisions on its side. The acquirer handles paying out the merchant.
- Your records are separate from theirs. Later you will compare your records with PSP and bank reports. That is only possible if you store each external reference, such as the PSP's transaction ID.
A small record of the parties for one payment might look like this:
from dataclasses import dataclass
@dataclass(frozen=True)
class PaymentParties:
merchant_id: str
psp_name: str
psp_reference: str # ID assigned by the PSP, kept for reconciliation
acquirer_id: str | None = None
card_network: str | None = None # often learned from the PSP response
parties = PaymentParties(
merchant_id="m_123",
psp_name="example-psp",
psp_reference="psp_tx_98765",
card_network="visa",
)
print(parties)Common mistakes
- Treating the PSP's "approved" response as money received. Approval is a promise, not a transfer.
- Not saving the PSP reference, which makes disputes and reconciliation hard.
- Exposing the PSP's raw status values directly in your public API.
Exercise
A request to the PSP times out. Which actor's decision is unknown, and what should you keep so you can find out the real result later?
Show answer
The issuer's decision (relayed through the network, acquirer, and PSP) is unknown, because the timeout hides the response. Keep your own payment record with an idempotency key and, when available, the PSP reference, so you can retry safely or query the PSP for the actual status.