Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 40 ยท Payments

How Online Payments Work

Understand the parties behind an online card payment: merchant, PSP, acquirer, card network and issuer. Compare integration styles, methods and fees.

When a shopper presses "Pay", a lot happens in about two seconds. Their card details travel through several companies, each of which checks something, takes a small fee and passes the request along. Developers rarely talk to all of them directly, but knowing who they are explains most of the confusing words in a payment provider's documentation: authorization, settlement, interchange, chargeback, 3-D Secure.

This lesson is a map. It names the parties, follows one card payment from end to end, compares ways to integrate, surveys payment methods beyond cards and shows how fees add up. The lessons after it go deeper: Authorization, Capture, Refunds and Chargebacks, PCI DSS Scope and 3-D Secure and Webhooks and Signature Verification.

The parties

Party Role
Cardholder The shopper who owns the card or account.
Merchant You, the shop selling something.
Payment service provider (PSP) The company whose API you call. It hides most of the complexity and often acts as a gateway, acquirer partner and fraud tool in one.
Gateway The software that securely transmits payment data from the merchant to the processing network. Many PSPs include one.
Acquirer (merchant bank) The bank that holds the merchant's account and receives the money.
Card network Visa, Mastercard, American Express and others. They set the rules and route messages between banks.
Issuer The bank that issued the shopper's card. It decides whether to approve the payment.

Small shops almost always use a PSP that bundles these roles, so they contract with one company. Large merchants sometimes contract with an acquirer directly and use several PSPs for resilience or cost.

Following one card payment

sequenceDiagram
    participant S as Shopper
    participant M as Merchant site
    participant P as PSP / gateway
    participant A as Acquirer
    participant N as Card network
    participant I as Issuer
    S->>M: Enter card details (or pay with a wallet)
    M->>P: Create payment (amount, currency, token)
    P->>A: Authorization request
    A->>N: Route request
    N->>I: Ask: approve this amount?
    I-->>N: Approved or declined
    N-->>A: Response
    A-->>P: Response
    P-->>M: Result (and later a webhook)
    M-->>S: Order confirmed or error shown

An authorization travels shopper to merchant to PSP to acquirer to network to issuer, and the answer returns the same way.

The key idea is that an approval does not move money. It tells the merchant that the issuer agrees to pay and reserves the amount on the cardholder's account. The money moves later, in settlement, usually in a daily batch: the issuer sends funds through the network to the acquirer, which pays the PSP, which pays the merchant, typically after a delay of one to several business days and minus fees.

This two-step shape (authorize now, capture and settle later) is why payment APIs have separate operations, which the next lessons explain.

How you integrate

A PSP offers a spectrum of integration styles. The more of the payment form you control, the more of the compliance burden (see PCI DSS Scope and 3-D Secure) lands on you.

Style What the shopper sees Your effort Compliance burden
Hosted payment page A redirect to a page run by the PSP Lowest Lowest
Embedded components / hosted fields Fields on your page, rendered by the PSP in iframes Medium Low
Direct API (card data through your server) A form entirely under your control Highest Highest

In practice most shops choose embedded components: a good-looking checkout that keeps raw card numbers away from their servers. Direct API handling of card numbers is rare and demands serious security work.

Whichever style you pick, the payment flow follows the same shape from the merchant's side:

  1. Your server creates a payment (sometimes called a payment intent or session) for an amount and currency. It receives a secret that identifies the attempt.
  2. The browser collects payment details with the provider's component and confirms the payment with the PSP. The card data never reaches your server.
  3. The PSP may ask the shopper to complete an extra step, such as 3-D Secure.
  4. Your server learns the final result, ideally via a signed webhook, not just from the browser returning to your site (the shopper might close the tab).
  5. You update the order (The Order Lifecycle).

Payment methods beyond cards

Cards dominate in some markets and are a minority in others. A global shop needs a mix.

  • Cards: credit, debit and prepaid. Widest reach, supports chargebacks.
  • Digital wallets: Apple Pay, Google Pay and similar. They wrap a card token and a device unlock, usually giving high conversion on mobile.
  • Account-based wallets: PayPal and regional equivalents. The shopper pays from a balance or a linked account.
  • Bank transfers and direct debit: SEPA debit in Europe, ACH in the US, "pay by bank" schemes and national instant payment systems. Cheaper, but often slower to confirm and with different reversal rules.
  • Local methods: iDEAL (Netherlands), Pix (Brazil), UPI (India), Bancontact (Belgium) and many others. In some countries these are the default way to pay.
  • Buy now, pay later (BNPL): an external lender pays you in full and the shopper repays in installments. It can raise basket sizes, with its own fees and approval step.
  • Cash and vouchers: the shopper receives a code and pays at a store or a kiosk. Confirmation arrives asynchronously, sometimes days later.

Two consequences for your design: some methods confirm asynchronously (so an order must be able to wait in a pending payment state), and available methods depend on country, currency, amount and sometimes the product type. Show only what applies.

What a payment costs

Fees vary by country, card type, volume and contract, so the numbers below are illustrative only. A typical card payment cost has several layers:

  • Interchange: paid to the issuer. Often the largest part. It depends on card type (consumer or corporate, debit or credit) and region.
  • Scheme (network) fees: paid to the card network.
  • Acquirer or PSP markup: the provider's margin.
  • Fixed per-transaction fee: a few cents.
  • Extras: currency conversion, chargeback fees, 3-D Secure, payouts, fraud tooling.

Many PSPs offer a blended price (a single percentage plus a fixed amount) which is easy to understand. Larger merchants negotiate interchange-plus pricing, which shows each cost separately.

Because the fixed fee is the same for every payment, tiny orders suffer: a fee of 2.9% plus 30 cents costs a much bigger share of a 3 dollar order than of a 300 dollar order. This stand-in computes what a merchant receives after fees:

JS What reaches the merchant

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The same idea explains why a refund does not always return the fee, and why minimum order values appear on some stores. Remember to keep all amounts as integers (Representing Money Correctly).

Choosing methods per shopper

Showing the right methods first is a conversion lever. This stand-in picks and orders methods using country and currency. Real providers do this for you, but the rule shape is worth seeing:

JS Which payment methods to show

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Practical rules for developers

  • Never trust the browser's report of success. Confirm payments from your server, using the PSP's API or a verified webhook.
  • Keep a payment record separate from the order, with the PSP's reference ids, amount, currency and status.
  • Send your own order id as metadata so you can reconcile later.
  • Design for pending and failed states. Declines are normal; offer a retry or another method.
  • Use the PSP's test mode and its published test cards while developing. Never put real card numbers into test systems.
  • Plan for refunds, disputes and reporting from the start. Finance will reconcile payouts against orders.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which party decides whether a card payment is approved?

    The issuer is the shopper's bank. The network and acquirer route the request, but only the issuer knows the account and agrees to pay.
  2. 2. What does a successful authorization mean?

    Authorization is a promise and a hold. Funds move in settlement, normally after capture, a day or more later.
  3. 3. Which integration style usually keeps card numbers off your servers while letting you design the page?

    Hosted fields render the sensitive inputs in the provider's iframes, so the numbers go straight to the PSP.
  4. 4. Why should an order be able to wait in a pending payment state?

    Not every method confirms within the checkout request. Bank debits and cash vouchers can take hours or days.
  5. 5. Why do very small orders suffer more from card fees?

    A fixed fee of a few cents is almost nothing on a large order and a noticeable percentage on a small one.

Summary

  • A card payment involves the shopper, merchant, PSP or gateway, acquirer, card network and issuer.
  • The issuer decides; authorization reserves the amount and settlement moves the money later.
  • Hosted pages, embedded components and direct APIs trade control against compliance effort.
  • Real shops need several payment methods, some of which confirm asynchronously.
  • Fees combine interchange, network fees, provider markup and fixed amounts, so small orders cost proportionally more.
  • Confirm results on the server, keep payments separate from orders and use test mode while building.

Next, follow the money through its stages: Authorization, Capture, Refunds and Chargebacks.