How payments work

Payment gateway vs processor: six roles, often one company

"The gateway declined it" is the payments version of "the computer says no": usually wrong, and no help at 3 AM. A card payment passes through six roles, and most of the confusion comes from one company playing three of them. Here's what each role does, which ones you sign a contract with, and how to tell from an error which one said no, with the payment flow from chapter 4.

Definitions are from the Visa Rules (24 October 2026 edition) and Visa's acceptance entities guide; prices are Stripe's and Authorize.net's US list prices, checked on 14 November 2026.

A payment gateway carries card details from your checkout to the processor and brings the answer back. A payment processor moves the transaction between the acquiring bank and the card networks. The gateway is the front door; the processor is the plumbing behind it. Many companies, Stripe included, are both, and a payment service provider (PSP) sells you the gateway, the processor and the merchant account under one contract.

The six roles

RoleWhat it doesExamplesDo you sign with it?
GatewayCollects and tokenizes card details, sends the authorization request, returns the answer to your siteAuthorize.net, Stripe, BraintreeYes, in the traditional setup. Part of the PSP contract otherwise
ProcessorFormats and routes transactions between the acquirer and the networks; authorization, clearing and settlement filesFiserv, Worldpay, a PSP's own processingRarely directly. It sits behind your acquirer or PSP
AcquirerThe bank that signs the merchant, enters transactions into the network, receives settlement and carries the risk if you can't cover a chargebackYour merchant bankYes: the merchant agreement, directly or through a PSP
Card networkRoutes between acquirer and issuer, sets the rules and the interchange rates, settles between banksVisa, Mastercard, Amex, DiscoverNo. You follow its rules through your acquirer
IssuerThe customer's bank: approves or declines, and handles the cardholder's disputeChase, Barclays, MonzoNo. Never
PSPBundles gateway, processor and the acquiring relationship into one API and one contractStripe, Adyen, PayPal BraintreeYes: it's the only contract you sign

Visa's own definitions are tighter. An acquirer is "a Member that signs a Merchant or Payment Facilitator ... and directly or indirectly enters a Transaction into Interchange"; an issuer is a Member that "enters into a contractual relationship with a Cardholder for the issuance of one or more Card products"; and a VisaNet Processor is directly connected to VisaNet and "provides Authorization, Clearing, or Settlement services to Merchants and/or Members" (Visa Rules, October 2026). Visa has no definition of "gateway": it files gateway services under third-party agents, the companies that sell payment services to merchants or acquirers without being the bank (Visa).

The flow, hop by hop

  1. Your checkout sends the card (as a token) and the amount to the gateway.
  2. The gateway hands it to the processor, which builds an authorization request on behalf of the acquirer.
  3. The card network routes it to the issuer.
  4. The issuer approves or declines, and the answer goes back the same way.
  5. Later, the acquirer clears and settles the day's transactions through the network, takes its fees, and pays your account.

The authorization is a round trip that takes seconds. The money follows days later, which is why "approved" and "paid" are different states in your database.

Who you sign with

Traditional setup: two or three contracts. A merchant account with an acquirer, often sold by an independent sales organization (ISO). Visa is blunt about what that means: ISOs "operate as agents on behalf of acquirers, meaning that when sellers sign services contracts with an ISO they are signing with the acquirer" (Visa). Then a separate gateway. Authorize.net's Gateway Only plan, for merchants who already have a merchant account, is $25 a month plus $0.10 per transaction and a $0.10 daily batch fee (Authorize.net). You pay interchange, network fees and the acquirer's markup on top; payment gateway fees has the full bill.

PSP: one contract. Stripe's US price for domestic cards is 2.9% + $0.30 per successful charge, and that one line covers the gateway, the processing and the acquiring (Stripe). Adyen and PayPal Braintree sell the same bundle. Some PSPs sign you as a sub-merchant under their own acquiring relationships, which is how you can go live the same day: the PSP is acting as a payment facilitator.

The words blur in practice. Authorize.net is a gateway that also sells an All-in-One plan at 2.9% + $0.30 per transaction with a merchant account included (Authorize.net). Stripe is called a gateway, a processor and a PSP, and it's all three. Ask what the company does, not what it calls itself.

What is a payment service provider?

In conversation, a PSP is a company like Stripe or Adyen that gives you everything above in one integration: card acceptance, wallets and bank methods, fraud screening, payouts and a dashboard. In EU regulation the phrase is a legal category with a broader meaning that includes banks, so read it in context. The practical test: if one contract and one API key get you from a card number to money in your bank account, you're using a PSP.

Which layer said no?

The error tells you, if you read it by type. On Stripe, the exception class maps onto the layers (Stripe):

  • CardError: a payment error. Either the issuer declined (card_declined, with a decline code saying why) or Stripe's fraud screening blocked it. Your integration is working.
  • InvalidRequestError: your request was wrong. It never left the gateway.
  • APIConnectionError or APIError: the outcome is unknown. Stripe's advice is not to assume it succeeded or failed: retry with the same idempotency key, or look the object up.
import stripe


def which_layer(exc):
    """Map a failed Stripe call to the layer that said no, and what to do next."""
    if isinstance(exc, stripe.CardError):
        decline_code = getattr(exc.error, "decline_code", None) if exc.error else None
        # The issuer declined, or the PSP's own fraud screening blocked it.
        return "issuer_or_risk", exc.code, decline_code, "ask for another card"
    if isinstance(exc, stripe.InvalidRequestError):
        # Rejected at the front door: it never reached a card network.
        return "your_request", exc.code, None, "fix the request"
    if isinstance(exc, stripe.RateLimitError):
        return "gateway", exc.code, None, "back off and retry"
    if isinstance(exc, (stripe.APIConnectionError, stripe.APIError)):
        # Outcome unknown. Retry with the same idempotency key, or look it up.
        return "unknown", None, None, "reconcile before charging again"
    return "other", getattr(exc, "code", None), None, "log and alert"

The unknown branch is the one that double-charges customers when it's handled as a decline. Idempotency keys covers the retry, and the card decline codes reference covers what the issuer meant.

The gateway's job, and the one decision at this layer that sets your PCI scope. From chapter 4.

3. Payment Gateway

Think of this as the online equivalent of a credit card terminal. It collects card details, encrypts them, routes the payment data to the processor, and returns the response to your website.

Examples: Stripe, PayPal, Square, Authorize.Net

What happens here:

# Your server never sees raw card data
payment_response = gateway.charge({
    'amount': 10000,  # $100.00 in cents
    'currency': 'usd',
    'token': 'tok_visa',  # Tokenized card data
    'description': 'Order #1234'
})

Your server should never handle raw card data. Always use tokenization provided by your payment gateway. That single decision moves you from SAQ D, which carries every merchant requirement in PCI DSS, to SAQ A, the shortest self-assessment questionnaire there is. (Your merchant level, and whether you need an on-site audit, is set by transaction volume, not by this choice. Chapter 17 has the details.)

Why the acquirer cares about your chargebacks: it's the bank that pays if you can't. From chapter 4.

5. Acquiring Bank (Your Bank)

This is the bank that holds your merchant account. It accepts payments on your behalf, eats the risk on chargebacks, deposits funds into your business bank account, and charges you merchant fees for the privilege.

The acquiring bank is taking a risk. If Sarah disputes the charge in 3 months and wins, they have to give her money back - even if you've already withdrawn it. This is why chargebacks impact your merchant account health.

The bundle, and the PSPs most teams pick between. From chapter 4.

What Are PSPs?

Payment Service Providers handle the entire payment stack for you - gateway, processor, merchant account, risk management, and compliance, all behind a single API.

Popular PSPs:

  • Stripe - Developer-first, global reach
  • PayPal/Braintree - Massive consumer adoption
  • Adyen - Enterprise-focused, omnichannel
  • Square - Strong for in-person plus online
  • Mollie - European-focused
  • Razorpay - India and Southeast Asia

Questions

What is a payment gateway?

A payment gateway carries card details from your checkout to the processor and brings the answer back to your site. It collects and tokenizes the card and sends the authorization request. Authorize.net is a standalone gateway; Stripe and Braintree include one.

What is the difference between a payment processor and a payment gateway?

The gateway is the front door: it takes the card details from your checkout and returns the result. The processor is the plumbing behind it: it routes the transaction between the acquiring bank and the card networks. Many companies, Stripe included, are both.

What is a payment service provider?

A payment service provider (PSP) bundles the gateway, the processing and the merchant account into one contract and one API, as Stripe, Adyen and PayPal Braintree do. In EU regulation the term is a broader legal category that includes banks.

Do I need a merchant account and a payment gateway?

Only in the traditional setup. There you sign a merchant agreement with an acquirer, often through an ISO, and a separate gateway contract, such as Authorize.net's Gateway Only plan at $25 a month plus $0.10 per transaction and a $0.10 daily batch fee. With a PSP like Stripe, one contract covers both.

Who declines a card payment, the gateway or the bank?

Usually the issuer, the customer's bank. The gateway rejects malformed requests, and the PSP's fraud screening can block a payment, but a decline with a decline code comes from the issuer. On Stripe, a CardError is a payment error and an InvalidRequestError means your request never left the gateway.

What the book adds

The rest of chapter 4

  • The authorization, hop by hop, with timings
  • Where the $3.20 on a $100 payment goes
  • Which layer a payment died at, by error
  • A charge call that can't double-bill
  • The money timeline from authorization to deposit

30-day money-back · Instant PDF and EPUB

All 42 chapters