The idea: a promise now, the money later

When you pay $100 with a card, the shop does not get $100 at that moment. It gets a promise from your bank that the money is there. The money itself moves a day or two later, in a separate step, and a few cents of it are kept by each bank on the way. The page follows one payment through all of this.

Six boxes in a row: cardholder, merchant, payment gateway, acquirer, card network, issuer. Blue arrows above them carry the authorization request from the merchant to the issuer and the answer back, in seconds. Green arrows below carry the money from the issuer to the network ($98.20), to the acquirer ($98.00) and to the merchant ($97.50), a day or two later
Messages go from the shop to the cardholder's bank and back in seconds; the money flows the other way later, and each hop keeps a fee.

Six parties take part. The cardholder owns the card. The merchant is the shop. The payment gateway is the service the shop's website talks to. The acquirer is the shop's bank: it accepts card payments for the shop. The card network connects all acquirers with all issuers and sets the rules. The issuer is the cardholder's bank: it gave out the card and decides yes or no. On the canvas the test card is 1234 5678 9012 3456 with a credit limit of $1,000.00; all names are roles, not real companies.

1. Authorization: a yes or no, and a hold

The shop sends an authorization request. Between banks it is an ISO 8583 message: 0100 for the request and 0110 for the answer. The gateway sends it to the acquirer, the acquirer to the network, and the network reads the first six digits of the card number (the BIN, here 123456) to find the issuer. The issuer checks that the card is real, not blocked and not expired, and that the amount fits in the available credit.

If it says yes, it returns an authorization code (here 4F7K2A) and puts a hold on the account: the available credit drops from $1,000.00 to $900.00. Nothing is on the statement yet and no money has moved (Demo: authorization only puts a hold). All of this takes a second or two.

response codemeaning
00approved
05do not honour (a general no)
51insufficient funds or credit
54expired card

A $1,200 order is more than the $1,000 available, so the issuer answers with code 51. The decline goes back along the same path, nothing is held and nothing moves later (Demo: declined, $1,200 is over the limit).

2. Capture: "now charge it"

An authorization is only a promise. To be paid, the shop must capture it, usually when the goods ship. The capture goes to the acquirer, which puts it in the day's batch. The issuer is not asked again; its hold just stays. A shop that sells something it charges at once (a download, a coffee) can authorize and capture in one request.

A capture can be smaller than the authorization, never larger. If only $80 of a $100 order ships, the shop captures $80 and the $20 left of the hold is released later (Demo: ship part, capture $80 of $100). If the order is cancelled before it ships, the shop sends a void instead: a reversal (0400) that goes all the way to the issuer and removes the hold at once, with no fee (Demo: order cancelled, void the hold). Without a void the hold simply expires after some days.

3. Clearing and 4. Settlement: the money moves

At the end of the day the acquirer sends its batch to the network as a clearing file. The network splits it by issuer. Each issuer matches every record with its authorization, drops the hold and posts the captured amount: now it is on the cardholder's statement.

Then comes settlement. The network works out, for each bank, how much it owes or is owed for the whole day, and the money moves in one transfer per bank, not one per payment. The issuer pays the network, the network pays the acquirer, and the acquirer pays into the shop's account (Demo: one $100 payment, all four steps). The cardholder pays the issuer later, when the monthly bill is due.

Four rows down time. Authorization at second 0: shop to issuer and back, a hold of $100, no money. Capture when the goods ship: shop to acquirer, added to the batch, no money. Clearing at end of day: acquirer to network to issuer, the hold becomes a posted $100. Settlement a day or two later: issuer to network to acquirer to shop, $98.20, $98.00, $97.50 move
Only the last step moves money; the first three only pass messages and change records.

Fees: who keeps what

The shop pays for taking cards. On the canvas the total is 2.50 % of the amount, the merchant discount rate, split three ways. Each party takes its share out of the money as it passes, so the shop simply receives less:

feeratekept byon $100on $80
interchange1.80 %issuer$1.80$1.44
network fee0.20 %card network$0.20$0.16
acquirer markup0.50 %acquirer$0.50$0.40
paid to the shop97.50 %merchant$97.50$78.00

Interchange is the biggest part and goes to the issuer, which carries the risk and pays for card rewards. Real rates depend on the card type, the country and whether the card was present; the gateway usually adds its own small fee per payment too.

Tokenization: the shop never sees the card number

A shop that stores card numbers must protect them under the PCI DSS rules, and a leak is costly. So the checkout page uses a payment field that the gateway hosts. The card number goes from the browser straight to the gateway. The gateway keeps it in its token vault and gives the shop a token (tok_7Q2X) plus the last four digits. The token is just a random name for a vault entry: it means nothing to anyone else, and it cannot be turned back into the card number without the vault.

When the shop sends an authorization, it sends the token; the gateway looks it up and puts the real number in the request to the acquirer. A returning customer can pay with the saved card: the shop sends the same token again and nothing is typed (Demo: saved token, two orders in one batch). That demo also shows net settlement: two orders, $100 and $50, clear in one file and settle as one transfer of $147.30 from the issuer.

See also HTTPS for the encrypted channel that carries the card number to the gateway, Idempotency Keys for retrying a charge without charging twice, Encryption vs Hashing for why a random token is different from an encrypted card number, Digital Signature for the kind of signature a chip card uses to prove it is genuine, and Saga vs Two-Phase Commit for the same "reserve first, confirm later" pattern between services.

What the page leaves out

Debit cards (the hold is on the bank balance), refunds and chargebacks (disputes that pull money back from the shop), 3-D Secure (the issuer asking the cardholder to confirm in an app), chip and contactless cryptograms, fraud scoring at the issuer, currency conversion, the network's own tokens for phone wallets, authorization expiry times, the gateway's own fee, and the exact settlement timetable, which is different for each network and country. Three-party networks, where one company is both issuer and acquirer, also skip the separate acquirer.

On the mind map

Open the Distributed Systems mind mapDistributedSystemsReplication: copies of data ยท what reads seeReplicationPartitioning: split data over nodesPartitioningTime and membership: order events, know who is aliveTime and membershipConsensus: agree on one value or logConsensusTransactions: one change across many servicesTransactionsMessaging: send events between systemsMessagingKafka internals: a replicated append-only logKafka internalsRedis internals: one thread, data in memoryRedis internalsKubernetes: reconcile desired stateKubernetesResilience and speed: stay up and fast under loadResilience and speedTwo-phase commitTwo-phase commitall vote yes, then commit; can blockSaga vs 2PCSaga vs 2PCsaga: local steps plus compensationOrchestration vs choreographyOrchestration vs choreographyorchestrator commands vs reacting to eventsOutbox and inboxOutbox and inboxwrite event in same DB transactionEvent sourcing and CQRSEvent sourcing and CQRSstore events, build read views from themDistributed lockDistributed lockTTL can expire; fencing token saves youIdempotency keysIdempotency keysSame key twice = one chargeCard payment flowAuthorize holds; settlement moves moneyOpen the Distributed Systems mind mapDistributed Systemsone change across many servicesTransactionsTwo-phase commitTwo-phase commitall vote yes, then commit; can blockSaga vs 2PCSaga vs 2PCsaga: local steps plus compensationOrchestration vs choreographyOrchestration vs choreographyorchestrator commands vs reacting to eventsOutbox and inboxOutbox and inboxwrite event in same DB transactionEvent sourcing and CQRSEvent sourcing and CQRSstore events, build read views from themDistributed lockDistributed lockTTL can expire; fencing token saves youIdempotency keysIdempotency keysSame key twice = one chargeCard payment flowAuthorize holds; settlement moves money
This page on the Distributed Systems mind map · 85 pages in 10 branches · open it to see the whole map and test yourself in recall mode.