Skip to content

01 Payment Ecosystem


Every card payment involves multiple organisations working together. Most developers assume payments are a two-party interaction — the customer and the merchant. The reality involves at least six distinct parties, each playing a specific role that the others cannot replace.

Here is the full picture before we explain each one:

plantuml


The customer — the person holding the card and making the purchase. They have a card issued by their bank (the issuing bank). Their only job in the transaction is to present their card details and, optionally, authenticate themselves (e.g., enter a PIN or approve an OTP).

The cardholder has no direct interaction with most of the parties below. They see the merchant’s website and their bank’s app. Everything in between is invisible to them.


The business accepting payment. A merchant can be a global e-commerce platform, a local coffee shop with an online store, or a SaaS company charging monthly subscriptions.

To accept card payments, a merchant must sign a Merchant Services Agreement with an acquiring bank. This agreement grants them a Merchant ID (MID) — a unique identifier that travels with every transaction, telling the card network and issuer which business is charging the customer. Without a MID, a business simply cannot process card payments.


The cardholder’s bank — the institution that issued their card. Examples: Chase, Bank of America, Citibank, Barclays, HDFC Bank.

The issuer’s role in every transaction:

  • Decides whether to approve or decline the charge based on: card validity, available credit or balance, fraud rules, and real-time risk models.
  • Bears the credit risk for credit card transactions (if the customer does not pay their bill, the issuer loses money).
  • Bears the fraud risk for most transactions (if a stolen card is used, the issuer typically reimburses the cardholder and absorbs the loss — this is why issuers care so much about fraud detection).
  • Earns interchange fees on every approved transaction as compensation for taking on this risk.

The merchant’s bank. Examples: Wells Fargo, JPMorgan Chase (as acquirer), Worldpay, Fiserv.

The acquirer’s role:

  • Sponsors the merchant’s access to the card networks.
  • Receives the authorization request from the processor and routes it to the card network.
  • At the end of the settlement process, deposits the payment into the merchant’s bank account (minus fees — typically 1 business day to 3 business days after the transaction).
  • Bears risk if the merchant goes bankrupt after receiving payments (the acquirer has to return money to cardholders who were charged for goods never delivered).

Visa, Mastercard, American Express, Discover. These are the rails — the global infrastructure that connects every issuing bank to every acquiring bank.

What card networks are not: they are not banks. Visa does not issue your card (your bank does). Visa does not hold your money (your bank does). Visa provides the plumbing and sets the rules.

What card networks do:

  • Maintain the global messaging infrastructure that routes authorization requests and responses in milliseconds.
  • Set the rules that all issuers and acquirers must follow (including PCI DSS, 3DS requirements, chargeback rules).
  • Earn a small network fee (separate from interchange) on every transaction.
  • Publish the interchange fee tables that determine how much the acquirer must pay the issuer on each transaction.

Software (almost always a cloud service) that acts as the secure intermediary between a merchant’s website and the banking system. Think of it as the digital equivalent of a card terminal at a physical store.

What the gateway does:

  • Provides the merchant with an API (or hosted checkout form) to accept card data.
  • Validates the request format and the merchant’s credentials.
  • Encrypts the card data before it goes anywhere else (using HSM-backed encryption).
  • Runs the transaction through a fraud detection engine.
  • Routes the encrypted authorization request to the right processor.
  • Returns the approval/decline result to the merchant.
  • Stores a token (a surrogate for the card number) so the merchant can charge the card again later without ever handling raw card data.

Examples of payment gateways: Stripe, Braintree, Adyen, Square, PayPal.


The technical layer that speaks the card network’s language. The processor formats the gateway’s authorization request into the ISO 8583 binary message format that Visa/Mastercard understand, sends it over the network, and translates the response back.

In many cases the acquirer and the processor are the same company (e.g., Fiserv is both a processor and an acquirer). In others, the acquirer contracts a third-party processor. The distinction matters for system design: the processor is the technical integration point while the acquirer is the financial relationship.


Section 2: How Authorization Works — Step by Step

Section titled “Section 2: How Authorization Works — Step by Step”

Authorization is the process of asking the issuing bank: “Will you approve a charge of $X on this card?” Nothing about this process moves money. It is purely a question and answer.

The entire sequence takes 1–2 seconds for a typical online transaction.

plantuml


Step 1 — Customer enters card details The customer types their 16-digit card number, expiry date, and CVV into the checkout form. If the merchant uses a gateway-hosted JavaScript SDK (recommended), the card data is captured directly by the gateway’s secure script — the merchant’s server never sees the raw numbers.

Step 2 — Merchant sends to gateway The merchant’s checkout code calls the gateway’s API with the card token (if using hosted fields) or card data. The request travels over HTTPS.

Step 3 — Gateway validates and encrypts The gateway validates the request structure, runs the transaction through a fraud scoring engine (checking velocity, device fingerprints, address mismatches, etc.), and encrypts the card data using the HSM before it moves further. This step typically takes 30–100ms.

Step 4 — Gateway sends to processor The encrypted authorization request is forwarded to the acquirer’s processor.

Step 5 — Processor formats the message (ISO 8583) ISO 8583 is the international standard for financial transaction messages — think of it as a very specific telegram format defined by the industry. It uses fixed-length binary fields. Field 2 is the card number. Field 4 is the transaction amount. Field 37 is the retrieval reference number. There are over 100 defined fields. The processor translates the gateway’s structured API request into this legacy binary format.

Step 6 — Card network routes to issuer using the BIN The BIN (Bank Identification Number) is the first 6–8 digits of the card number. For example, cards starting with 4 are Visa. Cards starting with 5 are Mastercard. Within Visa, 411111 maps to a specific issuing bank. The card network maintains a global BIN table and uses it to route the authorization request to the correct issuing bank in milliseconds.

Step 7 — Issuer makes the decision The issuer’s authorization system (running 24/7, often processing thousands of decisions per second) evaluates the transaction against rules and models. This is the single most important decision point in the entire flow. The issuer either approves or declines.

Step 8 — Response travels back The response code travels back through the same chain: Issuer → Card Network → Processor → Gateway. Common response codes: 00 (Approved), 51 (Insufficient Funds), 54 (Expired Card), 14 (Invalid Card Number), 41 (Lost Card), 43 (Stolen Card), 05 (Do Not Honor — catch-all decline).

Step 9 — Merchant receives result The gateway returns a structured response to the merchant’s server, which displays the result to the customer.


Section 3: Authorization vs Capture vs Settlement

Section titled “Section 3: Authorization vs Capture vs Settlement”

This is the concept that confuses most developers new to payments. When a customer clicks “Pay Now” and sees “Payment Successful,” no money has moved. The merchant has received a promise, not cash. Let us walk through the complete lifecycle.

plantuml


What it is: The issuer places a temporary hold on the customer’s available credit or balance. The customer can see the pending charge on their bank app immediately.

What it is not: A transfer of money. The money is still in the customer’s account — it is simply earmarked and unavailable for other purchases.

How long it lasts: Authorization holds typically expire after 7 days (credit cards) or 3 days (debit cards) if no capture is submitted. If the merchant never captures, the hold evaporates and the customer’s funds are released.

Real-world example: When a hotel checks you in, they authorize 500onyourcardtocovertheroompluspotentialincidentals.Theydonotknowyourfinalbillyet.Theholdreservesthefunds.Atcheckout,theycapturetheactualamount(500 on your card to cover the room plus potential incidentals. They do not know your final bill yet. The hold reserves the funds. At checkout, they capture the actual amount (350 for a 3-night stay). The hold releases and only $350 is captured.


What it is: The merchant’s instruction to the payment system: “We have delivered the goods/service. Please process the charge.” A captured transaction is queued for settlement.

Auth + Capture together: Most e-commerce transactions authorize and capture simultaneously (the merchant is ready to ship and wants the money). This is called an auth-capture or sale transaction.

Capture only: Used when auth was done separately (hotel, car rental, fuel dispensers). The capture amount can be less than the authorized amount but typically cannot exceed it without the issuer’s permission.


What it is: Once per day (typically at night), the processor bundles all of a merchant’s captured transactions into a settlement file and sends it to the card network. The card network orchestrates the actual inter-bank transfer: the issuing banks pay the acquiring bank the sum of all settled transactions.

Why batch and not real-time? Historically, inter-bank transfers ran on batch mainframe systems overnight. The infrastructure was built for this pattern decades ago. Visa/Mastercard are modernising toward real-time settlement, but batched overnight settlement remains the dominant model for most card transactions as of 2026.


What it is: The acquirer receives the funds from the card network and deposits them into the merchant’s bank account, minus the merchant discount rate (the fees).

Timeline: Typically 1–3 business days after settlement. The specific timing depends on the merchant’s contract with the acquirer.


Not every payment is a simple “charge the card.” The payment ecosystem defines several distinct transaction types, each with different behaviour and use cases.

Transaction TypeWhat It DoesWhen to Use
AUTH_ONLYReserves funds on the card without capturing. No money moves.Hotels, car rentals, gas stations — when final amount is unknown at the time of purchase.
AUTH_CAPTUREAuthorizes and immediately captures in one step. Money will move at settlement.Standard e-commerce where goods are in stock and ready to ship.
CAPTUREFinalizes a previously issued AUTH_ONLY. Queues funds for settlement.Merchant ships order and now knows the exact amount to charge.
VOIDCancels an authorization or capture before it is settled. Free — no interchange fee.Customer cancels before shipment; merchant discovers fraud before settlement.
REFUNDReturns money to the customer after settlement has occurred. Takes 1–5 business days.Customer returns goods after payment was settled. Merchant loses interchange fees.
CREDITSends money to a customer’s card without any prior charge.Payout platforms, refunds on cards where original transaction no longer exists. Considered high-risk; requires special acquirer approval.

Section 5: Card Types and Their Differences

Section titled “Section 5: Card Types and Their Differences”

All cards look the same physically but behave very differently in the payment network.

The issuer extends a line of credit to the cardholder. The customer spends now and repays later. Key characteristics:

  • Higher interchange fees (~1.5–2.5%) because the issuer is extending credit and taking on default risk.
  • Authorization holds can last up to 7 days.
  • Chargeback rights are stronger — consumers can dispute transactions up to 120 days after statement date.
  • Rewards cards (cashback, points) carry even higher interchange fees because the issuer funds the rewards program from that fee.

Funds are debited directly from the cardholder’s bank account. No credit extended. Key characteristics:

  • Lower interchange fees (~0.05–0.5%) because there is no credit risk. The Durbin Amendment (US, 2011) capped debit interchange at 0.21+0.050.21 + 0.05% for banks with > 10B in assets.
  • Authorization holds on debit cards are capped at 3 business days — a hotel cannot hold your bank account funds for a week.
  • Two processing networks: signature debit (processed through Visa/MC rails, higher fees) and PIN debit (processed through separate PIN networks like STAR, Pulse — lower fees).

A card loaded with a fixed amount of funds. No bank account attached, no credit extended. Key characteristics:

  • Used for gift cards, government benefit disbursements, payroll cards.
  • Same interchange fee structure as debit cards.
  • Cannot be charged more than the loaded balance — no overdraft.
  • Higher fraud risk because they are often purchased with cash and have no identity verification.

Cards issued to employees for business purchases. Key characteristics:

  • Different (often higher) interchange rates.
  • Require Level 2 and Level 3 data for lower interchange rates — fields like customer code, sales tax amount, item descriptions, commodity codes. Merchants who pass this enhanced data get a discounted interchange rate.
  • Used heavily in B2B payments where detailed line-item data is needed for expense reporting.

Section 6: Interchange Fees — The Economics of Payments

Section titled “Section 6: Interchange Fees — The Economics of Payments”

Interchange is the single largest cost in accepting card payments and the most misunderstood. Let us trace exactly who pays whom and why.

plantuml

Interchange compensates the issuing bank for three costs it bears:

  1. Credit risk: For credit cards, the issuer has extended credit. If the cardholder does not pay their bill, the issuer loses the $100 — not the merchant, not the acquirer. The interchange fee is partial compensation for that risk.

  2. Fraud risk: If a stolen card is used at a merchant and the transaction goes through, the issuer reimburses the cardholder. In most cases the issuer absorbs that loss. The interchange fee offsets fraud losses.

  3. Rewards cost: Premium rewards cards (1% cashback, airline miles) cost the issuer money on every transaction. A portion of the interchange fee funds the rewards program. This is why rewards cards have higher interchange rates than basic cards.

ComponentWho Sets ItWho Receives ItTypical Amount
Interchange feeVisa / MastercardIssuing bank0.05% – 2.5%
Network fee (assessment)Visa / MastercardCard network~0.13%
Processor markupYour payment processorAcquirer / processor0.1% – 0.5%
Gateway feeYour gatewayGateway provider0.050.05 – 0.30 flat
Merchant discount rateNegotiated with processorDistributed above~2.5% – 3.5% total

In the early 2000s, a series of massive card data breaches exposed the payment industry’s security gaps. In 2004, Visa, Mastercard, American Express, Discover, and JCB jointly created the PCI Security Standards Council and published the Payment Card Industry Data Security Standard (PCI DSS).

PCI DSS is a set of technical and operational security requirements that apply to any organisation that stores, processes, or transmits cardholder data. This includes merchants, payment gateways, processors, and any third-party service provider in the chain.

Compliance is not optional — it is a contractual requirement embedded in every merchant services agreement. Violating PCI DSS can result in fines, increased transaction fees, and termination of the ability to accept card payments.

LevelTransaction VolumeAnnual Audit Requirement
Level 1> 6 million Visa/MC transactions per year, OR any organisation that has suffered a breachFull on-site audit by a Qualified Security Assessor (QSA) — an independent, certified external auditor. Also requires quarterly network vulnerability scans by an Approved Scanning Vendor (ASV).
Level 21 million – 6 million transactions/yearAnnual Self-Assessment Questionnaire (SAQ) + quarterly ASV scans
Level 320,000 – 1 million e-commerce transactions/yearAnnual SAQ + quarterly ASV scans
Level 4< 20,000 e-commerce transactions/yearAnnual SAQ recommended; quarterly ASV scans recommended

PCI DSS v4.0 (current as of 2024) organises its requirements into 12 high-level categories:

#RequirementPlain-English Summary
1Install and maintain network security controlsFirewalls between the card data environment and the internet
2Apply secure configurations to all system componentsNo default passwords; disable unnecessary services
3Protect stored account dataEncrypt stored PANs; never store CVV at all
4Protect cardholder data with strong cryptography during transmissionTLS 1.2+ for all transmissions
5Protect all systems against malwareAntivirus on all systems that could be affected by malware
6Develop and maintain secure systems and softwarePatch management; secure coding practices
7Restrict access to system components by business need to knowRole-based access control
8Identify users and authenticate access to system componentsUnique IDs; MFA for admin access
9Restrict physical access to cardholder dataData centre physical security
10Log and monitor all access to system componentsAudit logs; real-time alerts
11Test security of systems and networks regularlyPenetration testing; vulnerability scanning
12Support information security with organisational policiesWritten security policies; incident response plan

The Self-Assessment Questionnaire (SAQ) has multiple variants depending on how the merchant interacts with card data. Two matter most for developers:

SAQ A — Redirect / Hosted Checkout (~22 questions) Applies to merchants who fully outsource card data handling to a PCI-certified gateway. The merchant’s website never receives, processes, transmits, or stores card data — it only redirects the customer to the gateway’s hosted page (or uses a gateway JavaScript widget that handles input directly). This is the simplest path. The merchant has minimal PCI obligations.

SAQ D — Full card data handling (~329 questions) Applies to merchants whose systems directly receive and process card data — e.g., building a custom payment form that posts card numbers to their own server before forwarding to the gateway. This requires answering all 329 questions across all 12 requirement categories. It is a significant compliance burden that most merchants avoid by using SAQ A-eligible integration patterns.


ACH (Automated Clearing House) is the US domestic inter-bank transfer network operated by Nacha (formerly NACHA — National Automated Clearing House Association). It processes direct deposits, bill payments, business-to-business transfers, and consumer bank debit transactions.

Unlike card networks, ACH does not process in real time. It is a batch processing system that runs at scheduled windows throughout the day (typically 3–6 times per business day) and settles on the next business day.

plantuml

PropertyACH (Bank Transfer)Card Payment
Processing speed1–3 business days~1–2 seconds
Cost~$0.25 flat fee~1.5–3% of amount
Return windowUp to 60 days (unauthorized)60–120 days (chargeback)
Best forLarge amounts, known customersAny amount, any customer
Reversal riskHigh — returns arrive days laterLower — disputes have process
RequiresBank routing + account numberCard number, expiry, CVV

ACH entries are classified by SEC (Standard Entry Class) codes which define the type of transaction and the required authorization:

SEC CodeMeaningAuthorization Required
WEBInternet-initiated debitOnline authorization (click-through agreement)
CCDCorporate credit or debitWritten authorization
PPDPrearranged payment and depositWritten or oral authorization
TELTelephone-initiatedOral authorization
IATInternational ACH transactionSpecial rules apply

Section 9: Digital Wallets — Apple Pay, Google Pay, Samsung Pay

Section titled “Section 9: Digital Wallets — Apple Pay, Google Pay, Samsung Pay”

When you type your card number into an online form, that number exists — in transit and briefly in memory — across many systems. A single compromised system in that chain could expose your card number to attackers who could then use it on any other website.

Digital wallets solve this by ensuring the real card number never leaves the wallet provider’s secure servers during a purchase.

Device Account Numbers (DPAN) and Tokenisation

Section titled “Device Account Numbers (DPAN) and Tokenisation”

When you add a card to Apple Pay or Google Pay, the wallet provider performs a process called card provisioning:

  1. You add your Visa card ending in 4242 to Apple Pay.
  2. Apple communicates with Visa’s token service and your issuing bank.
  3. Visa generates a Device Account Number (DPAN) — a different 16-digit number that is unique to your device and your card (e.g., the DPAN might be 4911 2233 4455 6677). This is also called a Device Primary Account Number.
  4. This DPAN is stored in a secure chip on your iPhone called the Secure Element. Your real card number (4242...) is never stored on the device.

plantuml

The Cryptogram — Why Tokens Cannot Be Reused

Section titled “The Cryptogram — Why Tokens Cannot Be Reused”

Every Apple Pay / Google Pay transaction generates a one-time cryptogram — a short cryptographic signature tied to:

  • The DPAN
  • The transaction amount
  • The merchant’s identity
  • A timestamp and random nonce

This cryptogram can only be used once. If an attacker intercepts the cryptogram, it is completely useless — it cannot be replayed for a different amount, a different merchant, or even the same transaction a second time. The card network’s token service validates the cryptogram before processing.

Contrast this with a raw card number: if someone intercepts your card number, expiry, and CVV, they can use it at any online merchant anywhere in the world.

For online purchases, using Apple Pay or Google Pay is objectively more secure than typing a card number. The DPAN + cryptogram model means:

  1. The merchant never sees your real card number.
  2. The token cannot be used at another merchant.
  3. The cryptogram cannot be replayed.
  4. Authentication (Face ID/Touch ID) verifies it is you.

This is why Apple Pay and Google Pay transactions have significantly lower fraud rates than standard card-not-present transactions.

From a technical perspective, digital wallet transactions flow through the same card authorization infrastructure as regular card transactions. The gateway resolves the DPAN back to a real PAN and processes a standard authorization. Merchants do not need to build separate integration logic for the actual authorization.

What merchants do need to implement:

  • Apple Pay: Register a merchant identifier with Apple, host a domain verification file, and implement the Apple Pay JavaScript SDK on the checkout page.
  • Google Pay: Implement the Google Pay JavaScript API. Register with Google as a merchant.
  • Both: The checkout page renders the wallet payment button, handles the returned payment token, and passes it to the gateway API.

Section 10: Chargebacks — The Merchant’s Nightmare

Section titled “Section 10: Chargebacks — The Merchant’s Nightmare”

A chargeback is a forced reversal of a transaction initiated by the cardholder’s bank (the issuer), not by the merchant. It is a consumer protection mechanism — if a customer believes a charge was unauthorised, or if they did not receive the goods/services they paid for, they can dispute the charge with their bank.

When a chargeback is issued:

  1. The issuer reverses the transaction amount from the acquirer.
  2. The acquirer takes the money back from the merchant.
  3. The merchant loses the revenue AND the goods (if already shipped) AND pays a chargeback fee (1515–100 per dispute) to the acquirer.
  4. The merchant has an opportunity to dispute the chargeback (called a “representment”) by submitting evidence.

plantuml

Card networks define specific reason codes for chargebacks. Key categories:

CategoryDescriptionExample Reason Codes
FraudCardholder claims they did not authorise the transactionVisa: 10.4 (Card Absent Fraud)
AuthorisationTransaction processed without proper authorisationVisa: 11.3 (No Authorisation)
Consumer disputeGoods not received, not as described, cancelled subscriptionVisa: 13.1 (Merchandise/Services Not Received)
Processing errorsDuplicate transaction, incorrect amountVisa: 12.6 (Duplicate Processing)

The 1% Rule — Why Chargeback Rate Matters

Section titled “The 1% Rule — Why Chargeback Rate Matters”

Card networks track every merchant’s chargeback ratio (chargebacks in a given month ÷ total transactions in that month). If this ratio exceeds 1%, the merchant is placed in a chargeback monitoring programme.

Consequences of high chargeback rates:

  • Monthly fines from the card network (5050–100 per chargeback over the threshold)
  • Mandatory remediation programme with strict milestones
  • If the ratio stays high for 6+ months: merchant account termination — the merchant can no longer accept Visa or Mastercard. Getting back on is extremely difficult.

3DS2 Liability Shift — The Most Important Fraud Rule

Section titled “3DS2 Liability Shift — The Most Important Fraud Rule”

For card-not-present (online) transactions, the normal rule is: if fraud occurs, the merchant pays the chargeback. The issuer reimburses the cardholder and deducts the money from the acquirer, who deducts it from the merchant.

3D Secure 2 (3DS2) changes this.

When a merchant implements 3DS2 and the transaction passes 3DS authentication (whether the customer sees a challenge or it passes frictionlessly), the liability for fraud chargebacks shifts from the merchant to the issuing bank.

This is called the liability shift:

Transaction TypeFraud OccursWho Pays the Chargeback?
No 3DSStolen card usedMerchant
3DS2 frictionless (issuer-approved)Stolen card usedIssuing Bank
3DS2 challenge (customer authenticated)Stolen card usedIssuing Bank
3DS2 attempted but issuer unavailableStolen card usedIssuing Bank

For most e-commerce merchants, 3DS2 is a net positive:

  • Most transactions (80–90%) pass frictionlessly — no customer friction.
  • Fraud chargebacks shift liability to the issuer.
  • The issuer’s fraud models may be better than the merchant’s, resulting in fewer declines of legitimate transactions.
  • The merchant pays no chargeback fees on fraud transactions that had 3DS2 liability shift.

The trade-off: 3DS2 adds a small amount of latency (~100ms) to the authorization flow, and a small percentage of transactions (5–15%) will trigger a visible challenge (OTP/biometric) which adds friction. For high-value, high-fraud categories (electronics, digital goods), this trade-off strongly favours enabling 3DS2.



← Payment Gateway HLD