CARDS · BANKS · NETWORKS · SETTLEMENT · TOKENS · SECURE CHIPS · NFC · TRANSIT · APPS

Card payments, part 1:
how Apple Pay pays for a coffee

Apple Pay lets your iPhone pay with a card from your bank, using a stand-in card number that only works from that phone. Underneath, it is the ordinary card system (your bank, the café’s bank and a card network between them), so that comes first.

You hold your iPhone near the card terminal at Harbor Coffee to pay $12.40 for a flat white and a croissant. The card behind it is a Visa credit card from Northbank. The terminal beeps, the café gets paid two days later, and Northbank’s app shows the charge as pending, then posted. That evening you ride the metro three times without unlocking the phone. The next morning you order ahead in the café’s app. Each chapter adds the part that makes one of these possible. The banks, numbers and fees are an illustrative worked example.

Here is every part involved. Most boxes won’t mean much yet; each chapter explains one of them.

MapSolid frames are companies and devices. Solid arrows travel during the tap, and dashed ones travel later or once.

You need to know what an HTTP request and an encrypted connection are. No banking knowledge is assumed. Rules, caps and Apple’s documented behaviour are as of 2026-11-20, in the US where noted; the banks, card numbers and fees are invented, and labelled illustrative. Code samples are Python, JavaScript and JSON. Tap any figure to open it full screen and zoom. are tappable. This is part 1 of 2; part 2 follows the same coffee inside the card network.

The card: an account with a number

You have a plastic Visa card from Northbank in your pocket. Harbor Coffee wants $12.40 for a flat white and a croissant, and the café has never dealt with Northbank. Before any phone or network comes in, look at the card itself: a number, an expiry date, a printed code, a magnetic stripe and a chip. None of them holds any money. What does a card number actually name, and what makes credit and debit different?

STEP 01 / 04

THE MAP SO FAR

Fig 1.1The two accent boxes are the whole card: a number in your pocket and an account at Northbank.

A card is a pointer to an account that one bank keeps. That bank is the : it gives you the card, lends you the money or holds it, and decides every payment made with the card. Here the issuer is Northbank, and its ledger holds your $2,000.00 credit line.

The plastic stores no balance and no credit. It carries the number that names the account, plus a few things that show you have the card in hand. Everything else on the map is faint for now; each later chapter adds one part.

STEP 02 / 04

A CARD NUMBER IS A BANK’S ADDRESS AND AN ACCOUNT NUMBER

Fig 1.2The accent slice is the BIN; everything after it except the last digit is your account.

The 16-digit number on the front is the , the primary account number. Its first 8 digits, 40001234, are the : they name the issuer and the card product, and the network routes on them. The leading 4 says the card is a Visa.

The next 7 digits pick your account at Northbank. The last digit, 7, is a check digit computed from the other 15 with the Luhn algorithm. A terminal or a checkout form runs the same arithmetic to catch a mistyped number before it sends anything.

THE LUHN CHECK ON NORTHBANK’S CARD NUMBER
def luhn_ok(number: str) -> bool:
    total = 0
    for i, ch in enumerate(reversed(number)):
        d = int(ch)
        if i % 2 == 1:  # double every second digit from the right
            d = d * 2 - 9 if d > 4 else d * 2
        total += d
    return total % 10 == 0  # the check digit makes the sum end in 0


print(luhn_ok("4000123456789017"))  # True
print(luhn_ok("4000123456789917"))  # False: one digit mistyped, 8 → 9
# Anyone can compute a valid check digit: it catches typos, not fraud.
STEP 03 / 04

CREDIT LENDS, DEBIT SPENDS WHAT YOU HAVE

Fig 1.3Read across the accent row: whose money pays the café is the real difference.

The same plastic can front three products. With credit, Northbank lends you the money for each purchase and you repay it from a monthly statement; your limit is the credit line. With debit, the money leaves your checking account within days, and your limit is the balance. Prepaid spends a balance loaded in advance.

At the café counter the three look the same. The differences sit behind the issuer: who is out of pocket while a payment is disputed and, in the US, the fee. Debit cards from banks with $10 billion or more in assets carry a capped fee, and credit cards carry no cap. Chapter 04 puts numbers on it.

STEP 04 / 04

A STRIPE REPEATS ITSELF, A CHIP COMPUTES A NEW CODE

Fig 1.4The accent column is the only one where two payments send different data.

The magnetic stripe stores the card number and expiry, and every swipe sends the same data, so a copy of the stripe pays like the card. The printed security code, 123, protects online payments and is just as fixed: anyone who has read it once can type it again.

The chip holds a secret key that never leaves it. For each payment it computes a , a short code made from that key and the payment’s details, such as 8E4C1A7B33D0F925, and Northbank (or the network on its behalf) checks it. A recorded cryptogram is useless for a second payment. Chapters 05 and 07 show how a phone also hides the fixed card number.

COMMON QUESTIONS

Does Visa lend me the money?
No. Visa carries messages between banks and settles between them. Northbank lends the money and carries the risk, and Visa never holds your account.
Are all card numbers 16 digits long?
No. ISO/IEC 7812 allows 8 to 19 digits. American Express uses fifteen, and some debit cards use more than sixteen. The BIN and the check digit work the same way at any length.
Is the expiry date a secret?
No. It and the printed code only show that someone has seen the card, which is weak proof once a shop’s database leaks.

WHAT YOU NOW KNOW

  • A card names an account at its issuer: Northbank holds the $2,000.00 credit line and decides every payment.
  • The PAN’s first 8 digits, 40001234, say which bank to ask; the last digit is a Luhn check.
  • Credit spends Northbank’s money and debit spends yours; stripe and printed code repeat, and only the chip computes a new code per payment.
DEEP DIVE: card number formats, three-party networks, charge and commercial cards, co-badged debit

Card number formats

ISO/IEC 7812-1 allows card numbers of 8 to 19 digits. The first digit is the major industry identifier, and it is 4 on every Visa card. The BIN, which the standard calls the issuer identification number, used to be six digits and is 8 now; numbers issued under older six-digit ranges keep working.

Because a BIN names an issuer and a product, BIN tables are sold as data. They map ranges to the bank, its country, debit or credit, and the card level, so a checkout can tell a debit card from a credit card before it charges.

Three-party networks

American Express usually issues the card, signs the merchant and runs the network itself, so one company sits on both sides of the payment. Discover was built the same way. Visa and Mastercard do neither job: they issue no cards and sign no merchants, which is why this tutorial needs both an issuer and an acquirer.

Charge and commercial cards

A charge card has no revolving credit: you pay the full statement each month. Corporate and purchasing cards, issued to companies, carry their own interchange tables, usually higher than consumer ones, and sit outside the EU’s consumer caps that chapter 04’s deep dive covers.

Co-badged debit

A US debit card usually carries two networks: a global one such as Visa, and a PIN network such as Star, NYCE or Pulse. Both can carry a payment for the same card number. Chapter 03’s deep dive shows who picks between them.

The café’s side: terminal and acquirer

Northbank knows your card. Harbor Coffee doesn’t know Northbank, and thousands of other banks issue the cards the café will see at its counter. It can’t sign a contract with every one of them, and no bank signs with a single café. The café needs one company that takes every card payment it makes and passes it on. How can a café accept cards from thousands of banks with one contract?

STEP 01 / 04

THE MAP SO FAR

Fig 2.1The accent arrow is the only line the café runs: from its terminal to its acquirer.

The café signs one contract, with an : a bank, or a processor working for one, that takes card payments for merchants, sends them on and pays the merchant. The card terminal on the counter belongs to that contract. It reads the card and sends each payment to the acquirer, and to no one else.

The acquirer also carries the café’s risk. If Harbor Coffee closes owing refunds, the acquirer pays them, which is why it checks a business before signing it. The card and Northbank’s account from chapter 01 stay on the map in grey.

STEP 02 / 04

ONE CONTRACT GIVES THE CAFÉ THREE IDENTIFIERS

Fig 2.2Each row is one field the acquirer gave the café; the accent row is the one every bank reads.

The merchant agreement gives the café a merchant ID, 000418822001, that travels on each of its payments, and a terminal ID per device, HC0002 for the one at the counter. It also names the settlement account the payouts go to and the price the café pays per payment.

The third identifier is the , the merchant category code: 5814, fast food restaurants, the code most coffee counters get. Every issuer reads it. It sets some fees, and banks and cardholders can block whole categories by it.

STEP 03 / 04

THE TERMINAL BUILDS THE REQUEST, THE ACQUIRER SENDS IT

Fig 2.3Follow hop 1: the chips under it are the fields the terminal fills in.

Insert the plastic card and the terminal reads the card number, the expiry and the chip’s cryptogram. It adds the amount, $12.40, the currency as the number 840 (US dollars), its merchant ID, its terminal ID and the time. Then it sends the request over its own internet or cellular connection.

The acquirer checks that the terminal is one of its own, adds its own identity and forwards the request; chapter 03 follows it from there. Your card did no networking at all: at a counter, the terminal is the device that goes online.

STEP 04 / 04

SMALL SHOPS OFTEN SIGN WITH A PAYMENT FACILITATOR

Fig 2.4Compare the two columns; the accent row is why a facilitator can freeze a new shop’s payouts.

Many cafés never sign with an acquirer directly. A , such as Square or Stripe, holds one master merchant account at an acquirer and signs up small shops under it as sub-merchants, in minutes and at one flat rate.

A direct acquirer contract takes underwriting, days or weeks, and prices each fee separately. Either way, every payment travels the same path from terminal to acquirer to network. What changes is who signed the café, and who receives its money first.

COMMON QUESTIONS

Does the café see my card number?
With a plastic card, yes: the terminal reads the full PAN, which is why terminals and acquirers fall under the PCI DSS security standard. Chapter 05 changes what a phone gives it.
Who owns the terminal?
Usually the acquirer or the facilitator leases or sells it, with keys loaded so that only that acquirer can read its traffic.
Is an acquirer the same as a processor?
Not always. The acquirer is the bank that signs the merchant and carries its risk; a processor may run the acquirer’s systems for it.

WHAT YOU NOW KNOW

  • Harbor Coffee signs one contract, with its acquirer, and carries one identity on every payment: merchant ID 000418822001, MCC 5814.
  • The terminal builds each request and sends it over its own connection; the acquirer forwards it toward every bank.
  • A payment facilitator sits between small shops and the acquirer, trading fast sign-up for its own rules on holding payouts.
DEEP DIVE: PCI DSS scope, encrypted terminals, underwriting and reserves, card-present and card-not-present

PCI DSS scope

PCI DSS is the card industry’s security standard. Any system that stores, processes or transmits card numbers is in scope, along with every system connected to it. A café whose terminal encrypts the card number before it reaches the café’s own network keeps its systems out of scope. A shop that writes card numbers to its database pulls that database, its backups and the laptops that administer it into scope.

Encrypted terminals

Point-to-point encryption encrypts the card data inside the terminal’s tamper-resistant hardware, and only the acquirer or its processor can decrypt it. The keys are usually managed with DUKPT (derived unique key per transaction): a base key is injected at a secure facility, and each transaction uses a new key derived from it, so one recovered key opens one transaction only.

Underwriting and reserves

The acquirer pays for a merchant’s refunds and chargebacks (chapter 04) when the merchant can’t. So it underwrites: it checks the business, its expected sales and its refund history before signing. For a risky business it keeps a rolling reserve, a share of each payout held back for a period and released later.

Card-present and card-not-present

A payment made with the card or phone at a terminal is card-present; one typed into a website or made in an app is card-not-present. Card-not-present payments carry more fraud, so they get different interchange rates and different rules on who pays for fraud. Chapter 10 shows how Apple Pay sends a payment from an app.

The card network: one question, routed to your bank

The café’s acquirer now holds a $12.40 request for card 40001234…, but it has no line to Northbank. Thousands of acquirers and thousands of issuers can’t each run a connection to every other one. Something has to sit between the banks, find the right issuer for each card number and carry the answer back while you wait at the counter. How does the café’s acquirer reach your bank, and what does your bank check before it says yes?

STEP 01 / 04

THE MAP SO FAR

Fig 3.1Follow the accent arrows: every card payment crosses Visa’s switch to reach Northbank’s host.

A , Visa here, connects every acquirer to every issuer. Each bank keeps one connection, to the network, and the network carries messages between them. This is the four-party model: you, Northbank, Harbor Coffee and its acquirer, with Visa between the two banks.

On Northbank’s side the request reaches its authorization host, the system that answers each : the question “will you pay $12.40?” asked while you wait, and its yes or no. Visa never lends money or keeps your account.

STEP 02 / 04

THE NETWORK ROUTES BY THE FIRST DIGITS

Fig 3.2The accent row is the one this payment matched; the others belong to other banks’ cards.

Visa’s switch reads the BIN, the first 8 digits, and looks it up in a routing table where every issuer registers its ranges. 40001234 falls in Northbank’s range, so the request goes to Northbank’s authorization host. The neighbouring BIN, 40001235, can belong to a different bank entirely.

The switch routes on digits alone, and it never sees your name or your balance. A card number whose BIN matches no row is declined with code 14, invalid card number, before any bank is asked.

STEP 03 / 04

ONE REQUEST, ONE ANSWER, BOTH ISO 8583

Fig 3.3Follow 1 to 3 out and 4 to 6 back; the chip on hop 4 is Northbank’s answer.

The request and its answer are messages, a bank format older than the web. Hops 1 to 3 carry message type 0100, an authorization request, from the terminal through the acquirer and Visa to Northbank. Hops 4 to 6 carry the 0110 response back: code 00, approved, and authorization code TG7Q2K.

Each message is a list of numbered fields. The sample writes the 0100’s content as named JSON fields: the amount as 12 digits in cents, 000000001240, the merchant category, and entry mode 05, which says the chip was read in a terminal. Real ISO 8583 packs the same fields into a binary format.

THE 0100 REQUEST, WRITTEN AS NAMED FIELDS
{
  "mti": "0100",
  "pan": "4000123456789017",
  "processingCode": "000000",
  "amount": "000000001240",
  "currency": "840",
  "posEntryMode": "05",
  "mcc": "5814",
  "merchantId": "000418822001",
  "terminalId": "HC0002",
  "iccData": "chip data, with the cryptogram 8E4C1A7B33D0F925"
}
STEP 04 / 04

APPROVED MEANS A HOLD, NOT A PAYMENT

Fig 3.4Read the checks top to bottom; the accent row is the answer and the hold it creates.

Northbank’s host runs its checks: the card is active and not reported lost, the chip cryptogram is valid, $12.40 fits within the available $1,412.60, and the fraud score is under its threshold. All of them pass, so it answers 00 and places an .

The hold reserves $12.40: your available credit drops to $1,400.20, and Northbank’s app shows the charge as pending. No money has moved. When a check fails, the answer is a decline code instead: 05 do not honour, 51 insufficient funds or 54 expired card.

COMMON QUESTIONS

How are Visa, Mastercard and American Express different?
Visa and Mastercard only connect banks and set the rules. American Express usually issues the card, signs the merchant and runs the network itself. Part 2 compares them, along with Discover and the domestic networks.
Does Visa see my balance?
No. The balance check happens only at Northbank. Visa sees the request and the answer.
What if Northbank’s host is down?
Visa can answer for it, under limits Northbank set in advance. This is stand-in processing, and the deep dive covers it.

WHAT YOU NOW KNOW

  • Visa’s switch routes the request to Northbank using only the BIN, 40001234.
  • Question and answer are ISO 8583 messages 0100 and 0110; response code 00 means approved.
  • Northbank checks the card, its cryptogram, the $1,412.60 available and fraud, then holds $12.40; no money has moved.
DEEP DIVE: how big the networks are, ISO 8583 messages, stand-in processing, US debit routing, holds and tips

How big the networks are

Visa processed 257.5 billion transactions in the fiscal year that ended 2025-09-30, according to its annual report. Mastercard’s annual report puts its growth in switched transactions at 10% for calendar 2025. Part 2 of this series opens the network itself: the switch, the data centres it runs in, and what it does with that traffic.

ISO 8583 messages

A message opens with a four-digit message type. Its digits name the version of the standard, the message class (authorization), the function (request or response) and who sent it, so 0100 and 0110 differ in one digit. A bitmap follows, a set of bits saying which numbered data elements are present, and then the elements themselves: card number, amount, entry mode.

Chip data travels in a data element of its own, as tag-length-value records, which is where the cryptogram sits. Each network publishes its own variant of the standard, so an acquirer speaks Visa’s version to Visa and Mastercard’s to Mastercard.

Stand-in processing

When Northbank’s host doesn’t answer in time, Visa can answer for it. Northbank sets the stand-in rules in advance, such as approving up to an amount per card type or merchant category, and Visa sends it a record of every answer once the host is back. A stand-in approval can’t see your real balance, so it can later post as a charge you can’t afford.

US debit routing

Regulation II requires every US debit card to carry at least two unaffiliated networks, for example Visa and a PIN network such as Star or NYCE. The merchant or its acquirer, not the bank, picks which one carries each payment, usually the cheaper one. The Fed has since made clear that the rule covers online and in-app payments too.

Holds, tips and incremental authorizations

A restaurant authorizes the bill, then clears the bill plus the tip, so the posted charge is larger than the hold. Hotels and car rentals authorize an estimate and add incremental authorizations during the stay. A fuel pump authorizes a fixed amount before you pump and clears the real total. A hold that is never cleared expires after a period the network’s rules set.

ERRORS THIS CHAPTER EXPLAINS

05 do not honour
an issuer risk rule or a block on the card
call the bank; the café can’t see the reason
51 insufficient funds
the balance or the credit line is too low
use another card or pay the balance down
54 expired card
a wrong or old expiry date
use the expiry from the newest card
14 invalid card number
the card number fails the Luhn check or matches no BIN
check the number for a typo

Clearing and settlement: the money moves later

Northbank said yes and holds $12.40 against your credit line. Harbor Coffee handed over the coffee and holds nothing but an approval code, TG7Q2K. The authorization moved messages, not money. Two banks that have never dealt with each other still have to settle up, minus fees that someone sets. When does the money actually move, and who keeps how much of the $12.40?

STEP 01 / 04

THE MAP SO FAR

Fig 4.1The dashed arrows from clearing run after the café closes, not while you stand at the counter.

is the network’s second job. Clearing collects each day’s completed sales from the acquirers and tells each issuer what to post. Settlement then moves the net money between the banks, and each acquirer pays its merchants.

Visa runs both, with settlement banks that hold the money. Its arrows on the map are dashed because they run hours after the tap, in batches, while nobody waits at a counter.

STEP 02 / 04

THE CAFÉ SENDS THE DAY’S SALES AS ONE BATCH

Fig 4.2Follow 1 to 3: the same $12.40 travels again, this time as a record, not a question.

At closing, the terminal or the acquirer submits the day’s batch: every approved sale, the $12.40 among them. The acquirer turns each sale into a clearing record and sends it to Visa, which sorts the records by BIN and passes each one to its issuer.

Northbank matches the record to its hold by the authorization code, TG7Q2K, and posts the charge, so “pending” becomes posted. The cleared amount can differ from the hold: a restaurant authorizes the bill and clears it with the tip.

STEP 03 / 04

BANKS SETTLE NET AMOUNTS, ONCE A DAY

Fig 4.3The accent leg is the one payout the café sees; every other line is a net total.

Visa totals every bank’s position for the day. Northbank owes for everything its cardholders bought, and the café’s acquirer is owed for everything its merchants sold. Each bank then pays in or receives one net amount through Visa’s settlement bank, instead of one transfer per coffee.

The acquirer pays Harbor Coffee into its settlement account, typically one or two business days after the sale, and 2 in this example. The deposit is the day’s sales minus fees, and $11.97 of it is your coffee. The next step shows where the other $0.43 went.

STEP 04 / 04

THE CAFÉ KEEPS $11.97 OF $12.40

Fig 4.4The accent line is the biggest cost, and it goes to your bank, not to Visa or the acquirer.

The receipt splits the $12.40 three ways, at illustrative rates. , 1.65% + $0.10, is $0.30 and goes to Northbank. Visa’s network fee, 0.14%, is $0.02. The acquirer’s markup, 0.25% + $0.08, is $0.11. Each line is rounded to whole cents, and the café receives $11.97.

The network sets interchange rates by card type, merchant category and channel, and the issuer keeps the money, which pays for rewards and fraud losses. The three lines together are the café’s . On a Northbank debit card, today’s US cap (21¢ + 0.05% + 1¢, as of 2026-11-20) makes interchange $0.23.

COMMON QUESTIONS

Why does a refund take days?
A refund is a new clearing record in the other direction. It follows the same batch and settlement cycle as a sale.
Why did the pending amount change?
The hold was the authorized amount. The posted charge is the cleared amount, which can include a tip or a final fuel total.
Who sets interchange?
The network publishes rate tables by card type, merchant category and channel. Regulators cap some of them: US debit from large banks, and EU consumer cards.

WHAT YOU NOW KNOW

  • The café’s batch turns Northbank’s $12.40 hold into a posted charge; without clearing, nothing moves.
  • Banks settle one net sum a day through Visa; the café is paid about 2 business days after the sale.
  • Of $12.40 the café keeps $11.97 in this illustrative receipt; the $0.30 interchange goes to Northbank.
DEEP DIVE: chargebacks, the US debit cap in court, EU caps, other money rails

Chargebacks

A chargeback is the issuer taking a cleared payment back. You dispute the $12.40 with Northbank, which files it through Visa with a reason code, such as fraud or goods not received, and the café’s acquirer debits the café. The café can answer with evidence, such as a receipt, and the network’s rules decide who wins.

Each network’s rules set the deadlines, counted in days from the date the payment was processed, and the deadline depends on the reason code. If the merchant can’t repay a lost dispute, the acquirer carries the loss, which is why chapter 02’s underwriting exists.

The US debit cap in court

Regulation II caps interchange on debit cards from banks with $10 billion or more in assets at 21¢ + 0.05% + 1¢; the last 1¢ is only for banks that meet the Fed’s fraud-prevention standard. Smaller banks are exempt, and their debit interchange follows the network’s rates. The Fed proposed lowering the base to 14.4¢ and has never finalised it.

Corner Post, a North Dakota truck stop, sued over how the Fed set the cap. A district court vacated the cap and paused its own order while the Fed appealed. On 2026-10-26 the Eighth Circuit affirmed: the Fed had counted costs the statute doesn’t allow and must set a new fee standard.

The ruling takes effect only when the court issues its mandate, after the window to ask for a rehearing closes, which can’t be before mid-December. As of 2026-11-20, no rehearing petition had been reported, so banks still charge under the cap. A similar challenge is pending in the Sixth Circuit.

The accent bar is the only one a regulator sets; the other two follow network rates.

EU caps

In the EU, the Interchange Fee Regulation caps interchange on consumer cards at 0.2% of the amount for debit and 0.3% for credit. Commercial cards are uncapped. The UK kept its own version of the rules after leaving the EU, overseen by its Payment Systems Regulator. Neither cap limits the acquirer’s markup or the network’s own fees.

Other money rails

ACH, wire transfers and instant payment systems such as FedNow in the US and SEPA Instant in Europe move money directly between two bank accounts. No card network sits in the middle, so there is no interchange, and disputes follow each system’s own rules, which give the payer far less protection than a chargeback. Cards are the rail built for paying a stranger on the spot.

Tokens: a card number that works in one place

In chapters 02 to 04 the full card number, 4000 1234 5678 9017, passed through Harbor Coffee’s terminal, its acquirer, Visa and Northbank. Any of them could store it, and a number copied from one of them pays at every other shop that takes Visa. A breach at one café puts your card at risk everywhere. Your iPhone never sends that number. How can your phone pay with a card number that is useless if someone copies it?

STEP 01 / 04

THE MAP SO FAR

Fig 5.1The accent arrow is a detour every token payment takes inside Visa before it reaches Northbank.

A issues a second card number for the same account and keeps each pairing in a token vault. That second number is a . Visa’s token service is the Visa Token Service; Mastercard’s is MDES, and it works the same way.

The token service sits inside the network, beside the switch from chapter 03. Every payment already passes through that switch, so a token payment needs no new connection: the switch hands it to the token service on its way to Northbank. The café, its acquirer and Northbank keep the links they had.

STEP 02 / 04

A TOKEN IS A SECOND NUMBER FOR THE SAME ACCOUNT

Fig 5.2The accent row is what makes the token different from your card: where it is allowed to work.

Your iPhone’s token is 4895 3700 1122 3341. In Visa’s vault it points at 4000 1234 5678 9017, the plastic card in your wallet. The same row records who asked for the token (Apple Pay, the token requestor), its status (active) and its domain: this iPhone’s Secure Element, for contactless and in-app payments only.

The token has a card number’s shape: 16 digits, Visa’s leading 4 and a valid Luhn check digit. Terminals, acquirers and the switch handle it with the code they already run for card numbers. Apple calls this token the Device Account Number.

STEP 03 / 04

THE NETWORK SWAPS THE TOKEN BACK ON THE WAY TO THE BANK

Fig 5.3Hop 3 is the only place the two numbers meet; left of it, only the token exists.

At the counter the terminal reads the token, •••• 3341, and sends it to the acquirer, which forwards it to Visa (hops 1 and 2). Visa’s switch recognises the token’s number range and hands the request to the token service (hop 3). The token service checks that the token is active and inside its domain, then swaps in the card number.

Northbank receives •••• 9017 with a note that the token checks passed (hop 4), and decides exactly as in chapter 03. On the way back Visa replaces the card number with the token again (hops 5 to 7). Harbor Coffee and its acquirer never hold your card number.

STEP 04 / 04

A TOKEN WORKS ONLY WHERE IT WAS ISSUED

Fig 5.4Compare the two columns; the accent row is where Visa’s token service says yes or no.

The token service checks the token’s domain on every payment; these checks are called domain restriction controls. A tap from your iPhone arrives from a contactless terminal and carries a cryptogram that only this iPhone’s Secure Element can compute. Both match the vault row, so the token service swaps in the card number and asks Northbank.

Now suppose a thief copies 4895 3700 1122 3341 from a breached shop and types it into a website. The payment arrives with the card not present and no cryptogram, because no chip computed one. It is outside the token’s domain, so the token service declines it before Northbank sees it.

COMMON QUESTIONS

What happens when Northbank sends me a new plastic card?
Northbank tells Visa’s token service, which updates the card number behind the token. The iPhone keeps the same token and keeps paying; you don’t add the card again.
Can a shop still recognise me across my cards and devices?
Visa gives each card account a Payment Account Reference (PAR), a 29-character code shared by all its tokens. A shop can link payments with it, but it can’t pay with it or turn it back into a card number.
Do online shops use tokens too?
Yes. Network tokens replace stored card numbers for subscriptions and saved cards, with the shop as the token requestor. Chapter 10 shows Apple Pay’s version, the merchant token.

WHAT YOU NOW KNOW

  • The iPhone pays with token 4895 3700 1122 3341; the card ending 9017 stays between Visa and Northbank.
  • Visa’s token service swaps the token for the card number on hop 3, after checking its status and domain.
  • A copied token is declined anywhere but this iPhone, tapped or in an app.
DEEP DIVE: the EMVCo roles, Payment Account Reference, network tokens for merchants, tokens and PCI scope

Who does what in EMVCo tokenisation

The EMV Payment Tokenisation Specification names three roles. The token requestor asks for tokens: Apple Pay for Wallet, or a merchant for its saved cards. Each one registers with the network and gets a token requestor ID, which the vault stores with every token it asked for. The token service provider, usually the network, issues tokens and runs the vault. The issuer approves each token and can suspend it.

With each token the provider also records how the cardholder and card were checked when it was issued, the token assurance method. Chapter 06 shows those checks for Apple Pay. Issuers can weigh that record when they score later payments on the token.

Payment Account Reference

A PAR is 29 characters long. The first four name the BIN controller, the organisation that manages the card’s number range, and the rest are unique to the account. The card number and every token for it share one PAR. A PAR can’t be turned back into a card number and can’t authorize a payment, so a shop can keep it to match loyalty or fraud records across a phone tap, a watch tap and the plastic card.

Network tokens for merchants

A shop that keeps cards on file for subscriptions can ask the network for a token for each card instead of storing the card number. When the issuer replaces a card with a new number or expiry date, the vault updates the card behind the token, so the shop’s next charge goes through without asking you. That update is the main reason network tokens raise approval rates on repeat charges.

Tokens and PCI scope

PCI DSS applies to every system that stores, processes or sends card numbers. A network token in your database is not a card number, so storing tokens shrinks that scope; the vault that maps them back sits fully in scope, at the network.

A payment gateway’s own token is different. It is a reference that only that gateway can use, the card number stays in the gateway’s vault, and moving to another gateway means migrating the card data. A network token works with any acquirer on that network.

Adding the card: Wallet and Apple Pay servers

Visa’s token service can issue a token for Northbank’s card, but nobody has asked for one yet. The request has to come from your phone, and it has to be hard to fake: anyone who has seen your card number could otherwise ask for a token on their own phone and pay as you. What happens between scanning your card and its appearing in Wallet?

STEP 01 / 04

THE MAP SO FAR

Fig 6.1The accent arrow runs once, when you add the card, and never during a tap in a shop.

Two new parts add the card. The Wallet app on your iPhone collects the card’s details, and Apple Pay servers pass them to the network’s token service and pass the answer back. Adding a card to a device this way is called .

This path runs once per card per device, when you add it. It never carries a payment in a shop, which is why the map draws it dashed. Apple’s servers also keep track of which cards are on which device; the token itself stays in the phone.

STEP 02 / 04

APPLE PASSES THE CARD ON, THE BANK DECIDES

Fig 6.2Follow 1 to 6; the accent message, hop 4, is Northbank’s decision, and the other hops only carry it.

You point the camera at the card or type it in; the photo is never saved. Wallet sends the details, encrypted, to Apple Pay servers over TLS 1.2 or later (hop 1). Apple forwards them to Visa with signals about your device and account: the model, your phone number, your App Store activity and, if Location Services is on, your rough location (hop 2).

Visa asks Northbank (hop 3), and Northbank decides (hop 4). Apple’s side of this runs as three server calls, Required Fields, Check Card, Link and Provision: Check Card verifies every detail except the security code, and Link and Provision sends the security code and the terms you accepted.

On approval, Northbank’s side creates the token: here Visa’s token service, acting for Northbank. The token reaches the phone encrypted so that Apple can’t read it (hops 5 and 6), and is stored in the Secure Element.

STEP 03 / 04

THE BANK CAN ASK FOR ONE MORE PROOF

Fig 6.3The accent column is the step that stops a thief with your card number and their own phone.

Northbank scores each request from what hop 2 carried and its own records, then gives one of three answers: approve at once, ask for one more proof, or decline. The extra proof is a one-time code by text or email to contact details Northbank already holds, a call, or a sign-in to Northbank’s app.

Adding the card from Northbank’s own app skips typing, because the app already knows you. On iOS 18 and later you can also hold the plastic card to the back of the iPhone instead of typing (Tap to Add Card). On iOS 26 and later Northbank can then check your card’s PIN.

STEP 04 / 04

EACH DEVICE GETS ITS OWN TOKEN

Fig 6.4Each row is one device; the accent row can be switched off without touching the others.

Add the same card on your Apple Watch and the whole flow runs again: Northbank approves, and the Watch gets its own token, 4895 3700 5566 7718. Both tokens point at •••• 9017 in Visa’s vault, and each lives in its own device’s Secure Element.

Remove the card from the Watch, or erase the Watch, and only that token stops; the iPhone keeps paying. The token number is never stored on Apple Pay servers or backed up to iCloud, so a new phone means adding the card again, and it gets a new token.

COMMON QUESTIONS

Does Apple see my card number?
The details pass through Apple’s servers, encrypted, on their way to Visa. Apple says the full number is stored neither on its servers nor on the device, and the token reaches the phone encrypted so Apple can’t read it.
Why does Wallet say “contact your card issuer”?
Northbank declined, or asked for a check Wallet can’t run itself. Only Northbank can say which; Apple and Visa only pass its answer on.
Do I need internet to add a card?
Yes. Adding is the one step that needs the phone, Apple, Visa and Northbank online at once. Paying in a shop doesn’t, as chapter 09 shows.

WHAT YOU NOW KNOW

  • Wallet sends the card to Apple Pay servers, which pass it to Visa; only Northbank decides.
  • Northbank approves, asks for a code by text or email, or declines; the code is what stops a thief.
  • The iPhone gets token •••• 3341 and the Watch •••• 7718: two tokens for one Northbank card.
DEEP DIVE: the three server calls, adding from a bank’s app, what Apple is paid, lost and erased devices

The three server calls

Apple’s Platform Security guide names three calls between Apple Pay servers and the card issuer or its network: Required Fields, Check Card, Link and Provision. Wallet fills in what it can read from the card (the name, number and expiry date) and you type the rest. Check Card verifies every field except the security code. Link and Provision then sends the security code and the ID of the terms you accepted, and the token comes back from it.

With the request Apple sends risk signals: your App Store account activity, the device’s model, name and phone number, any companion device used in setup, and your approximate location if Location Services is on. The sessions use TLS 1.2 or later.

Adding from a bank’s app

An issuer can put an Add to Apple Wallet button in its own app, with a PassKit entitlement that Apple grants. The bank’s app encrypts the card data with keys the iPhone itself can’t read, so it passes straight through to the network. Because you are already signed in to the bank’s app, the bank can approve without the printed code or a one-time password.

Tap to Add Card (iOS 18 and later) and the PIN check (iOS 26 and later) do a similar job for cards added in Wallet: they show that you hold the plastic card. Neither is available in every country or region.

What Apple is paid

Apple has never published its fee to issuers. Litigation and press coverage report 0.15% of each US credit purchase and 0.5¢ per debit purchase, paid by the issuer out of the interchange it earns, not by the café. On the $12.40 coffee that would be 1.86¢: illustrative arithmetic on a reported rate.

Card issuers have sued Apple over the fee in a class action, and a US court has certified the class. Treat the rates as reported, not confirmed.

Lost and erased devices

Put the iPhone in Lost Mode with Find My and its cards are suspended; when you find it, they work again. Erase All Content and Settings makes the phone tell the Secure Element to mark every card terminated at once, before Apple Pay servers remove them fully.

You can also ask Northbank to suspend or remove the card from Apple Pay. Northbank and Visa then suspend the token in the vault, which works even while the phone is switched off: its next payment fails at the token service.

The Secure Element and the Secure Enclave

The token has reached your iPhone. The same phone runs iOS and thousands of apps, and one of them could be malware. If any app could read the token’s key, it could compute payments; if any app could approve, it could pay without you. Two chips keep both jobs away from iOS. Where do the token and its key live, and how does Face ID approve exactly one payment?

STEP 01 / 04

THE MAP SO FAR

Fig 7.1The accent pair sit beside iOS, not inside it; the link between them is the only way to approve.

Two chips in the iPhone are not part of iOS. The is a separate chip, certified to EMVCo and Common Criteria standards, that runs the Java Card platform. It holds one payment applet per card: a small program with that card’s token, its key and its counter.

The is a walled-off part of the main chip. It checks Face ID, Touch ID or the passcode, and only it can tell the Secure Element that you approved a payment.

STEP 02 / 04

iOS CAN ASK FOR A PAYMENT, NOT MAKE ONE

Fig 7.2The accent path carries the approval, encrypted; iOS sits on the grey line and can only ask.

The Secure Enclave and the Secure Element don’t connect directly. They talk over a serial interface. The Secure Element’s only other link is the NFC controller, which routes traffic to it from the application processor and from a card terminal’s radio.

At the factory each of the two chips is given the other’s long-term public key. At runtime they work out a shared secret from those keys, the pairing key, and encrypt everything between them with it. Anything in between can pass their messages on but can’t read or forge them.

So iOS and Wallet can ask for a payment, but the key never leaves the Secure Element, and the approval can only come from the Secure Enclave.

STEP 03 / 04

FACE ID APPROVES ONE PAYMENT, NOT THE PHONE

Fig 7.3The accent hop is the approval itself: one signed message, good for one payment.

You double-click the side button and look at the phone (hop 1). The Secure Enclave matches your face, or checks the passcode (hop 2). Unlocking the phone earlier doesn’t count: Apple Pay asks again for every payment.

The Secure Enclave then sends the Secure Element signed data saying how you were checked and what kind of payment this is, contactless or in an app (hop 3). It is tied to the Authorization Random (AR) value, a secret the Secure Enclave made when you added your first card. The Secure Element then lets the card’s applet make one payment (hop 4).

Turn off the passcode or sign out of iCloud, and the Secure Enclave marks its copy of the AR value invalid, so every card stops working. When the Secure Element receives a new AR value, it marks every earlier card terminated.

STEP 04 / 04

EVERY PAYMENT CARRIES A ONE-TIME CODE

Fig 7.4Every row goes into the code; the accent counter is the input the chip moves itself, by one per payment.

The applet computes the cryptogram from its key and the payment’s data: amount $12.40, currency 840, the date, the terminal’s unpredictable number 9A3F21C4, the result of the Face ID check, and the , which goes from 41 to 42. The result is 8 bytes: 8E4C1A7B33D0F925.

The key was loaded into the applet when the card was added, and Visa’s token service or Northbank, or both, hold the same key. Either one recomputes the code from the same inputs and compares. A payment replayed later fails: the counter and the unpredictable number have moved on.

The sample below shows the idea with AES: a session key from the card key and the counter, then a MAC over the payment’s data. Its key is made up, so it prints different bytes from the example’s cryptogram, and a new code for the next counter value.

A SIMPLIFIED CRYPTOGRAM WITH A MADE-UP KEY
from cryptography.hazmat.primitives.ciphers import algorithms
from cryptography.hazmat.primitives.cmac import CMAC

# Simplified: each network’s kernel defines the exact data and key derivation.
def mac(key: bytes, data: bytes) -> bytes:
    c = CMAC(algorithms.AES(key))
    c.update(data)
    return c.finalize()

card_key = bytes.fromhex("0123456789ABCDEF0123456789ABCDEF")  # made up; the real one stays in the chip
for atc in (42, 43):  # the counter: this payment, then the next one
    session_key = mac(card_key, atc.to_bytes(2, "big"))  # a new key per payment
    # amount 000000001240 · currency 0840 · date 261120 · unpredictable number · counter
    data = bytes.fromhex("000000001240" "0840" "261120" "9A3F21C4") + atc.to_bytes(2, "big")
    print(atc, mac(session_key, data)[:8].hex().upper())
# → 42 2E856849F76EABC9, then 43 3350F22BCE5307AA: same coffee, new code

COMMON QUESTIONS

Can a jailbroken phone read the token’s key?
Not from iOS. The key sits in the Secure Element, which runs only signed applets and never hands the key out, so breaking into iOS doesn’t reach it.
How do Android phones do it?
Most use host card emulation: the payment app keeps short-lived, limited-use keys in software and fetches new ones from the network while the phone is online.
Does my face data go to the bank?
No. It stays in the Secure Enclave. Northbank only learns that the phone checked you, and how, from the verification result inside the cryptogram’s data.

WHAT YOU NOW KNOW

  • The token •••• 3341, its key and its counter live in the Secure Element, which iOS can’t read.
  • The Secure Enclave matches your face and sends one signed approval, which enables one payment.
  • Each payment carries a cryptogram over the amount, unpredictable number 9A3F21C4 and counter 42, checked by Visa or Northbank.
DEEP DIVE: certification, the pairing key and the AR value, host card emulation, the NFC and SE platform for other apps

Certification

The Secure Element is certified hardware, the same class of chip as the one in a bank card: EMVCo evaluates it for payments and Common Criteria for security, and it runs the Java Card platform. That certification is why networks and issuers treat a token in a phone like a chip card, and why they load keys into it.

The pairing key and the AR value

The pairing is set up at manufacture: each chip gets the other’s long-term public key, and at runtime they work out the shared secret that encrypts their messages. The Secure Enclave makes the AR value when the first card is added and sends it to the Secure Element over that channel. It keeps its own copy, protected against being rolled back.

Three things end every card at once. Turning off the passcode and signing out of iCloud make the Secure Enclave mark its AR copy invalid. Erase All Content and Settings tells the Secure Element to mark every card terminated. Lost Mode in Find My only suspends the cards, so they work again when you find the phone.

Host card emulation

Most Android phones run the payment applet in software, an approach called host card emulation (HCE). Instead of one long-lived key in a secure chip, the phone holds a few limited-use keys from the network’s token service, each good for a few payments or a short time. While online it fetches more; offline for long enough, it runs out and can’t pay until it reconnects.

Apple added an HCE API of its own in iOS 17.4, in the European Economic Area only, so a bank’s app can pay by tap without the Secure Element.

The NFC and SE platform for other apps

Since iOS 18.1, a second framework lets approved developers use the NFC controller and the Secure Element themselves, for payments, transit, keys and IDs. It started in countries such as the US, the UK, Canada, Japan and Australia; the list grows, so check Apple’s NFC & SE Platform page.

The tap: NFC and the terminal

Your iPhone’s Secure Element now holds the token •••• 3341, its key and a counter, and Face ID has approved one payment. Harbor Coffee’s card terminal shows $12.40 and is waiting for a card. No data has passed between the two yet, and the terminal runs the same software it uses for plastic cards. What do the phone and the terminal say to each other, and what reaches your bank?

STEP 01 / 04

THE MAP SO FAR

Fig 8.1The accent arrow is the only wireless hop; everything right of the terminal is the path from chapter 03.

The controller is the iPhone’s short-range radio. When the terminal’s field reaches the phone, the controller carries the exchange straight to the Secure Element, past iOS and its apps. NFC, near-field communication, runs at 13.56 MHz and works within about 4 cm (ISO/IEC 14443), so a payment happens only when you hold the phone to the reader.

The card terminal is back in accent because its contactless reader is the other end of that radio link. Everything to its right is the path from chapter 03: the acquirer, Visa and Northbank. The tap adds one hop at the start and changes little after the terminal: the token and two fields of the request.

STEP 02 / 04

THE TERMINAL ASKS FOUR TIMES, THE PHONE ANSWERS

Fig 8.2Read top to bottom; the accent exchange is where your amount goes in and the one-time code comes out.

The terminal drives the exchange and the phone only answers, exactly as a plastic card would. The rules are EMV’s, the chip-card standard the card networks publish together. First the terminal selects 2PAY.SYS.DDF01, a directory every contactless card carries, and the phone lists one payment app: Visa’s, application ID A0000000031010. The terminal selects that app, and the phone returns the fields the next command must fill in.

The third command, GET PROCESSING OPTIONS, carries $12.40, currency 840, the date and the terminal’s unpredictable number 9A3F21C4. The Secure Element feeds them into chapter 07’s and answers with 8E4C1A7B33D0F925 and counter 002A; for a Visa card both come back in this one answer. READ RECORD then returns the token and its expiry, and the phone can leave the field.

STEP 03 / 04

FACE ID REPLACES THE PIN AND THE LIMIT

Fig 8.3The accent row explains why the phone never gets a PIN prompt at the counter.

A plastic contactless card can’t tell who is holding it. So each country’s networks, and in some places its regulators, set a contactless limit, and above it the terminal asks for a PIN. That keeps a stolen card to small amounts.

The phone has already checked you. Face ID or the passcode is , CDCVM, and the phone reports it in its answer to GET PROCESSING OPTIONS: the device-verified flag from step 2. The terminal reads the flag and skips the PIN, at any amount the café accepts.

STEP 04 / 04

THE WHOLE TAP, END TO END

Fig 8.4Follow 1 to 8; the accent hop is the only step a plastic card’s payment doesn’t have.

From the terminal on, the tap is chapter 03’s payment. The terminal builds the same 0100 request for $12.40 with two differences: the card number field holds the token, and the entry mode is 07, contactless chip, instead of 05. The chip-data field carries the cryptogram, the counter, the unpredictable number and the device-verified result (hops 1 to 3).

At Visa the token service swaps •••• 3341 for •••• 9017 (hop 4). The cryptogram is checked there or at Northbank, whichever holds the token’s key. Northbank then decides as in chapter 03 and answers 00 with authorization code TG7Q2K. On the way back Visa puts the token in again, so the café’s side only ever sees •••• 3341 (hops 5 to 8).

THE 0100 REQUEST FOR THE TAP, AS NAMED FIELDS
{
  "mti": "0100",
  "pan": "4895370011223341",
  "processingCode": "000000",
  "amount": "000000001240",
  "currency": "840",
  "posEntryMode": "07",
  "mcc": "5814",
  "merchantId": "000418822001",
  "terminalId": "HC0002",
  "iccData": {
    "9F26": "8E4C1A7B33D0F925",
    "9F36": "002A",
    "9F37": "9A3F21C4",
    "9F34": "device verified (CDCVM)"
  }
}

COMMON QUESTIONS

Can someone skim my phone in a crowd?
Not for a payment. Without Face ID or your passcode the payment app returns no cryptogram, and the radio reaches a few centimetres. Express Mode transit cards are the exception, which chapter 09 explains.
Does the terminal know it is Apple Pay?
It sees a token, entry mode 07 and a device-verified flag, not a brand. Visa knows from the token’s number range.
Can an iPhone be the terminal?
Yes. Tap to Pay on iPhone lets a merchant’s phone read cards, sending the same commands from the other side.

WHAT YOU NOW KNOW

  • The terminal sends four EMV commands over NFC, within about 4 cm, and the Secure Element answers each one.
  • The answer to GET PROCESSING OPTIONS carries cryptogram 8E4C…F925 and counter 002A; the terminal sends both on with entry mode 07.
  • Visa swaps •••• 3341 for •••• 9017, Northbank answers 00, and no PIN is asked because Face ID already checked you.
DEEP DIVE: contactless kernels, relay attacks, contactless limits, Tap to Pay on iPhone

Contactless kernels

Each network wrote its own contactless rules, run in the terminal as a kernel: the software that sends the commands and decides what goes into the request. EMVCo numbers them: C-2 is Mastercard’s, C-3 is Visa’s, and others cover the other networks. A terminal carries several kernels and picks one from the payment app the card or phone lists first. EMVCo has since published C-8, one kernel meant to replace the per-network ones over time.

Relay attacks

A relay attack forwards the radio exchange over a longer link: one device near your phone and one near a terminal, joined by a fast link. The cryptogram is genuine and is accepted. The defences are timing limits, since newer kernels measure how long each answer takes, and on a phone the need for Face ID before any cryptogram exists. Researchers have shown relays against Express Mode transit cards, which answer without Face ID.

Contactless limits

Each country’s contactless limit is set by the networks and, in some places, by regulators, and it changes: the UK’s rose more than once during the 2020s. Above it a plastic card needs a PIN or is declined. Many cards also count taps in a row, or a running total, and ask for a PIN after a set number. A phone using CDCVM isn’t bound by the limit; the merchant’s own maximum still applies.

Tap to Pay on iPhone

Tap to Pay on iPhone turns a merchant’s iPhone into the terminal. A payment provider’s app supplies the kernels, and the iPhone’s NFC controller reads the customer’s card or phone with the same commands as in step 2. Where a card needs a PIN, the customer types it on the merchant’s screen, which is called PIN on glass. No extra card reader is needed.

Why a tap works without signal

In chapter 08 every network hop started at the terminal. The phone sent nothing to the internet: its key, its counter and your approval were already inside it. That evening you ride the metro 3 times, and each gate opens before any bank could have answered. What actually has to be online for a tap to work, and how does a metro gate let you in before your bank answers?

STEP 01 / 04

THE MAP SO FAR

Fig 9.1The dashed arrow from the metro’s back office runs after you are already through the gate.

A metro’s transit gate and fare back office pay differently from a café terminal. The gate decides on its own, in a fraction of a second, whether to open. The back office asks your bank afterwards, through an acquirer, which is why its arrow on the map is dashed: it carries traffic later, not while you stand at the gate.

With on, the gate’s reader gets an answer from the phone with no Face ID. You turn it on in Wallet for one card per transit network: a transit card, or a credit or debit card used to pay fares. A café terminal still needs Face ID, Touch ID or the passcode.

STEP 02 / 04

IN A SHOP, ONLY THE TERMINAL GOES ONLINE

Fig 9.2Read the online column; the accent row is your phone, and it says no.

Go back over the $12.40 coffee and ask which part needed a network. Your phone didn’t. The token, its key and the counter live in the Secure Element, your approval came from the Secure Enclave, and NFC is a radio link to the terminal, not to the internet. NFC stays on in airplane mode.

The terminal did: it sends the request to its acquirer over its own internet or cellular link, and the acquirer, Visa and Northbank all have to answer. Apple’s servers weren’t involved at all. Your phone needs a connection only to add a card, to pay in an app, and for Wallet to show the receipt afterwards.

STEP 03 / 04

SOME TERMINALS APPROVE ON THE SPOT AND SEND IT LATER

Fig 9.3The accent row is the answer that lets a terminal approve with no network.

Some terminals have no network at the moment you pay: on a plane, or at a market stall. EMV lets them decide locally. The terminal asks the card for one of three answers, each a cryptogram of its own type: an ARQC asks to go online, an AAC declines, and a TC, a transaction certificate, approves the payment there and then.

A TC is possible only below the terminal’s floor limit, the amount it may approve alone, and only after the terminal checks the card’s data offline against the network’s keys. It stores the sale and sends it when it is back online. Whether a card ever gives a TC is set by its issuer in the card’s settings, and many terminals are set to always go online.

STEP 04 / 04

A METRO GATE OPENS FIRST AND ASKS LATER

Fig 9.4Follow 1 to 6; only the accent hop happens while you stand at the gate.

A gate can’t wait for a bank while a queue builds behind you. So it checks only what it can check alone (hop 2): that the code is well formed, and that the token isn’t on the deny list it downloads from the back office. Then it opens. This is .

The back office asks Northbank afterwards with a small authorization that checks the account (hops 3 to 5). If Northbank declines, the token goes on the deny list and the next tap fails. The next morning the back office adds up the day: 3 rides at $2.90 each become one $8.70 charge (illustrative, hop 6).

Express Mode keeps working on power reserve after the battery runs down: up to 5 hours on supported iPhones, according to Apple Support. It covers only Express Mode transit cards and keys, so it won’t pay for a coffee, and it isn’t available if you shut the phone down yourself.

COMMON QUESTIONS

Does Apple Pay work in airplane mode?
In a shop, yes. Airplane mode leaves NFC on, and the terminal carries the request. Paying in an app needs a connection.
Will a phone with a dead battery pay for coffee?
No. Power reserve covers only Express Mode transit cards and keys, and not after you shut the phone down yourself.
Why was I charged for yesterday’s rides this morning?
The back office totals a day’s taps, applies any fare cap, then clears one charge afterwards.

WHAT YOU NOW KNOW

  • At the café only the terminal goes online; the phone makes the code from its own key and counter, with no signal.
  • An offline terminal can approve with a TC below its floor limit, and the merchant carries the risk until the sale reaches Northbank.
  • The metro gate opens on a local check; 3 rides at $2.90 clear later as one $8.70 charge (illustrative).
DEEP DIVE: offline data authentication, stand-in versus offline, how transit fares are aggregated, stored-value transit cards

Offline data authentication

A terminal with no network still has to tell a real card from a copy. EMV gives it offline data authentication: the card signs data with its own private key, and the terminal checks the signature through a chain of public keys that ends at the network’s keys, preloaded in the terminal. SDA signs fixed data, DDA signs a fresh challenge each time, and CDA signs the cryptogram itself.

Stand-in versus offline

Two different parties can answer when the issuer doesn’t. In stand-in processing (chapter 03) the network answers for the issuer, online, within limits the issuer agreed to. An offline approval happens one step earlier: the terminal answers for everyone, and no message leaves it until later, at the merchant’s risk.

Some payment apps add a third kind. With no connection they store a tap and send it later as an ordinary online request, and the merchant carries any decline.

How transit fares are aggregated

A transit back office manages one risk: the first ride is given before any bank has answered. So after the first tap of the day it sends one authorization, a small amount or an account check, and a declined card goes on the deny list. Later taps join the day’s total, the back office applies any daily or weekly fare cap, and one cleared charge reaches the issuer.

The accent row is the only charge your statement shows: 3 rides, one line (illustrative).

Stored-value transit cards

Some transit cards keep the money on the card itself. Japan’s Suica is the best known in Wallet: its balance lives in the Secure Element, and the gate deducts the fare there and then, with no bank asked at all. The tap is faster and works with no network, but the balance is only as safe as the card’s keys, and you top it up from a payment card in Wallet.

Paying in an app or on a website

The next morning you order ahead in Harbor Coffee’s app: $5.75, to collect at the counter. There is no terminal and no NFC field this time. The token and its one-time code have to cross the internet to the café, and so far every payment has started at a terminal next to the phone. How do the token and its one-time code reach the café’s payment provider, and who can read them on the way?

STEP 01 / 04

THE MAP SO FAR

Fig 10.1The accent arrows replace the terminal: the café’s server and gateway carry the request now.

In an app, two parts do the terminal’s job. The café app and its server ask Apple Pay for a payment and receive an encrypted payment token. The café’s , run by its payment provider, decrypts that token and sends the acquirer an ordinary card payment.

The dashed arrow up to Apple Pay servers is new. In a shop Apple’s servers aren’t in the payment’s path; in an app they are, because they re-encrypt the payment for the café (step 2). Everything from the acquirer on is chapter 03’s path again.

STEP 02 / 04

THE CODE IS ENCRYPTED FOR THE CAFÉ, VIA APPLE

Fig 10.2The accent step is where the code is re-encrypted for the café; Apple can read it there.

You confirm the $5.75 order with Face ID (hop 1). The Secure Element builds the same kind of payment as at the counter, the token, a cryptogram and the amount, and marks it as an in-app payment. In place of a terminal’s unpredictable number, the cryptogram takes an anti-replay value from Apple’s servers. The Secure Element then encrypts the result with an Apple key (hop 2).

Apple’s servers decrypt it, check the anti-replay value, and encrypt it again with Harbor Coffee’s key (hop 3). So Apple can read an in-app payment, which it never sees in a shop. What comes back to the app is the payment token, which only the holder of the café’s key can open; the app posts it to the café’s server (hops 4 and 5).

On a website the same flow runs through ApplePaySession in Safari. The page must be served over HTTPS from a domain registered and verified with Apple. The café’s Apple Pay merchant ID, an identifier it registers with Apple, ties that domain, the app and the café’s keys together.

APPLE PAY ON THE CAFÉ’S WEBSITE, IN THE BROWSER
// runs when you tap the Apple Pay button on the café's checkout page
const session = new ApplePaySession(3, {
  countryCode: 'US',
  currencyCode: 'USD',
  supportedNetworks: ['visa', 'masterCard'],
  merchantCapabilities: ['supports3DS'],
  total: { label: 'Harbor Coffee', amount: '5.75' },
});

session.onvalidatemerchant = async (event) => {
  // the café's server asks Apple for a merchant session with its identity certificate
  const res = await fetch('/apple-pay/session', {
    method: 'POST',
    body: JSON.stringify({ validationURL: event.validationURL }),
  });
  session.completeMerchantValidation(await res.json());
};

session.onpaymentauthorized = async (event) => {
  // event.payment.token is encrypted for the café; its server passes it to the gateway
  const res = await fetch('/pay', { method: 'POST', body: JSON.stringify(event.payment.token) });
  const ok = res.ok ? ApplePaySession.STATUS_SUCCESS : ApplePaySession.STATUS_FAILURE;
  session.completePayment({ status: ok });
};

session.begin(); // shows the payment sheet; Face ID approves the $5.75
STEP 03 / 04

THE GATEWAY OPENS THE TOKEN AND SENDS A NORMAL AUTHORIZATION

Fig 10.3Each row is one decrypted field; the accent row is the one-time code Visa or Northbank checks.

The gateway holds the café’s payment processing private key. The token’s envelope, EC_v1, carries a one-off public key, and the gateway combines it with that private key to derive the key that decrypts the data. Inside are the token •••• 3341, the expiry, the amount 575 in cents, currency 840, the data type 3DSecure and the online payment cryptogram.

The gateway turns these into a card-not-present authorization request to the acquirer, with the token as the card number and the cryptogram in the chip-data field. Visa checks the cryptogram, or Northbank does, and swaps the token as in chapter 05. Some networks also add an ECI value, an e-commerce indicator; when it is there, the gateway must pass it on.

Because Face ID already checked you, no 3-D Secure page appears. That page is how a bank checks the cardholder on an ordinary online card payment; here the cryptogram and the phone’s own check take its place.

THE DECRYPTED PAYMENT DATA THE GATEWAY READS, BINARY VALUES CUT
{
  "applicationPrimaryAccountNumber": "4895370011223341",
  "applicationExpirationDate": "290930",
  "currencyCode": "840",
  "transactionAmount": 575,
  "deviceManufacturerIdentifier": "<hex: the device that made it>",
  "paymentDataType": "3DSecure",
  "paymentData": {
    "onlinePaymentCryptogram": "<base64: the single-use cryptogram>"
  }
}
STEP 04 / 04

A SUBSCRIPTION GETS ITS OWN TOKEN

Fig 10.4Compare the columns; the accent row is why subscriptions shouldn’t charge the phone’s token.

The weekly $18.00 beans subscription needs a token the café can charge while your phone is in your pocket. When the app asks for a recurring payment, Apple Pay requests a (an MPAN): a token the network issues for Harbor Coffee rather than for your phone. Merchant tokens arrived with iOS 16, and the decrypted payload marks one with a merchantTokenIdentifier field.

A merchant token is tied to your Apple Account, not to one device, so it keeps working when you replace the iPhone. You can see it in Wallet and stop it there. If your bank doesn’t support merchant tokens, Apple Pay returns a device token instead.

COMMON QUESTIONS

Does the café see my card number now?
It sees the token, •••• 3341, and only if it decrypts the payment itself. Most cafés let the gateway decrypt, which keeps their own servers out of PCI DSS scope.
Why does Apple Pay skip my bank’s verification page?
Face ID and the cryptogram already show it is you and your phone, and Northbank gets that result inside the request.
Does paying in an app need internet?
Yes. The app, Apple’s servers, the gateway and Northbank must all be reachable.

WHAT YOU NOW KNOW

  • In an app the Secure Element’s payment goes to Apple, which re-encrypts it with Harbor Coffee’s key; Apple can read it there.
  • The gateway decrypts it and sends a card-not-present request for $5.75 with token •••• 3341 and a single-use cryptogram.
  • The weekly $18.00 subscription uses a merchant token for Harbor Coffee, so it keeps working on a new phone.
DEEP DIVE: merchant certificates, decrypting EC_v1, the web flow and merchant validation, SCA and 3-D Secure

Merchant certificates

A merchant set up for Apple Pay holds two certificates. The merchant identity certificate proves the merchant to Apple’s servers when a website asks for a payment session. The payment processing certificate’s public key is the one Apple encrypts each payment token for, and its private key decrypts them. When a gateway decrypts for the café, the gateway creates that key pair and keeps the private key, and the café never handles it.

Decrypting EC_v1

The encrypted token is a JSON envelope. Its header carries a one-off public key, a hash of the merchant’s public key, so the gateway knows which key to use, and a transaction ID. The gateway first checks Apple’s signature and that its signing time is recent. Then it runs elliptic-curve Diffie-Hellman between its private key and the one-off key, derives a symmetric key, and decrypts the data with AES-GCM.

THE ENCRYPTED PAYMENT TOKEN THE APP POSTS, VALUES CUT
{
  "version": "EC_v1",
  "data": "<base64: the encrypted payment data>",
  "signature": "<base64: Apple's PKCS #7 signature>",
  "header": {
    "ephemeralPublicKey": "<base64: a one-off public key>",
    "publicKeyHash": "<base64: hash of the café's public key>",
    "transactionId": "<hex: made on the device>"
  }
}

The web flow and merchant validation

On a website, the merchant proves itself before the payment sheet appears. The onvalidatemerchant handler calls the café’s server, which asks Apple for a merchant session with its merchant identity certificate and returns it, and completeMerchantValidation hands that session to the browser. Since iOS 18, people in other browsers can pay too, by scanning a code with their iPhone.

Strong customer authentication and 3-D Secure

In the EEA and the UK, PSD2’s strong customer authentication requires two of three factors for most online payments: something you know, something you have, something you are. An Apple Pay payment has two, the phone you hold and Face ID. Other online card payments get them through 3-D Secure, the bank’s challenge page. The ECI value records how the cardholder was checked, and with it which side carries the fraud loss.

The whole picture

Every part from the ten chapters, numbered to match the reference table below.

Find a number on the map, then its row below: what the part does, who runs it and what it decides.
  1. 1plastic card

    names your Northbank account

    run by
    you; made by Northbank
    decides on
    nothing: it is read
    when wrong
    14 invalid card number, 54 expired card
  2. 2card account

    holds the credit line or balance

    run by
    Northbank
    decides on
    how much is available
    when wrong
    51 insufficient funds; a pending hold you didn’t expect
  3. 3card terminal

    reads the card or phone, builds the request

    run by
    the café; leased from its acquirer
    decides on
    which kernel and verification to use
    when wrong
    “insert card”, “see phone”, a second authorization after a double tap
  4. 4acquirer

    sends the café’s payments, pays it out

    run by
    the café’s acquirer
    decides on
    whether to accept and pay the merchant
    when wrong
    held payouts, a wrong MCC on every payment
  5. 5network switch

    routes requests to issuers

    run by
    Visa
    decides on
    the BIN
    when wrong
    a timeout, or a stand-in approval
  6. 6authorization host

    approves or declines each payment

    run by
    Northbank
    decides on
    card status, cryptogram, funds, fraud score
    when wrong
    05 do not honour
  7. 7clearing and settlement

    turns approvals into posted charges and moves net money

    run by
    Visa and settlement banks
    decides on
    the café’s batch
    when wrong
    a pending charge that never posts; a payout short by the fees
  8. 8token service and vault

    issues tokens, swaps them back, checks their domain

    run by
    Visa
    decides on
    the token’s domain and status
    when wrong
    a token used outside its device or channel is declined
  9. 9Wallet app

    adds cards, asks you to approve

    run by
    iOS on your iPhone
    decides on
    nothing: it asks
    when wrong
    “card not added”, “contact your card issuer”
  10. 10Apple Pay servers

    pass new cards to Visa, re-encrypt in-app payments

    run by
    Apple
    decides on
    which device a card is on; anti-replay for in-app
    when wrong
    in-app payments fail; cards can’t be added
  11. 11Secure Element

    holds token, key, counter; computes the cryptogram

    run by
    your iPhone
    decides on
    whether an approval is present
    when wrong
    cards marked unusable after the passcode is removed
  12. 12Secure Enclave

    matches Face ID, authorizes one payment

    run by
    your iPhone
    decides on
    your face, finger or passcode
    when wrong
    “double-click to pay” repeats; the passcode is asked instead
  13. 13NFC controller

    carries the radio exchange to the Secure Element

    run by
    your iPhone
    decides on
    nothing: it routes
    when wrong
    the terminal never reacts; hold the phone closer
  14. 14transit gate and back office

    opens on a local check, charges a day’s rides later

    run by
    the city metro
    decides on
    the deny list; the day’s fare total
    when wrong
    the gate refuses a card whose last fare was declined
  15. 15café app and server

    asks Apple Pay for a token, forwards it

    run by
    Harbor Coffee
    decides on
    the amount and the merchant ID
    when wrong
    the payment sheet never opens (merchant validation failed)
  16. 16payment gateway

    decrypts the token, sends a card-not-present request

    run by
    the café’s payment provider
    decides on
    which key to decrypt with
    when wrong
    decryption errors after a certificate change; reused tokens declined
  17. ·token (Device Account Number)

    a card number for one device

    run by
    issued by Visa
    decides on
    nothing: it is checked
    when wrong
    receipts show •••• 3341, not your card’s •••• 9017
  18. ·merchant token

    a card number for one shop, for repeat charges

    run by
    issued by Visa
    decides on
    nothing: it is checked
    when wrong
    a subscription keeps charging after you change phones (by design)
  19. ·interchange

    the fee the café’s side pays your bank

    run by
    set by Visa, capped by regulators
    decides on
    card type, merchant category, channel
    when wrong
    the café’s payout is $11.97, not $12.40

THREE THINGS TO KEEP

  • Apple Pay is an ordinary card payment, made with a stand-in card number that only works from your phone.
  • In a shop the phone never goes online. Your bank checks a one-time code only your phone could make.
  • Approval is a promise. The money moves later, in a batch, and the café pays your bank a fee.

That beep at the counter is your bank saying yes, through three companies you never see.