
A customer taps pay, and the page they’re looking at freezes for a second or two while a spinner turns. That pause is not decoration. In that window, a short chain of systems talks to each other, checks the card, checks the funds, and sends back a yes or a no. Most explanations of payment processing skip straight to “the money moves,” which is the part that matters least to anyone building or evaluating a checkout flow. This piece stays in the plumbing: the actual calls, in the actual order, and what each one is for.
The moment you click pay: what the checkout page actually sends
When a customer fills in a card number and hits pay, the checkout page does not send that card number straight to the merchant’s server. If it did, every online store would be sitting on a pile of raw card data, and every data breach would be a card breach. Instead, the checkout form, almost always running code supplied by the payment gateway rather than the merchant, sends the card details directly to the gateway’s servers over an encrypted connection.
What comes back to the merchant’s own server is not the card number at all. It is a token: a string that represents that card for this transaction, or sometimes for future transactions, but carries no usable card data on its own. The merchant’s server then uses that token to ask for authorization. This single design choice, pushing raw card data away from the merchant as early as possible, is what the next section is actually about.
Tokenization: why your card number never touches the merchant’s server
Tokenization exists to shrink the blast radius of a breach. If a merchant’s database is ever compromised, an attacker who finds only tokens has found nothing usable outside that gateway’s own system. The token means something to the gateway that issued it and to nobody else.

The mechanism is simple in outline even though the engineering behind it is not. The customer’s browser sends the card number to the gateway over TLS, the gateway stores or forwards the real card data inside its own secured environment, and it hands back a token that the merchant stores instead. For a one-time purchase, that token might only be valid for a few minutes. For a saved card, the merchant stores the token long-term and reuses it for the next charge, which is how a checkout can offer “pay with the card ending in 4242” without ever holding that card number itself.
This is also why PCI compliance obligations look so different for a merchant using a tokenized, hosted checkout field versus a merchant handling raw card numbers directly. Tokenization does not eliminate the need to care about security, but it moves the hardest part of that burden onto the gateway, which is built around carrying it.
The authorization call: gateway, processor, card network, and issuing bank in one round trip
Once the merchant’s server has a token, it sends an authorization request to the gateway: charge this amount, to this token, for this order. From here, the request passes through several parties in a single round trip that usually takes well under two seconds.

-
The gateway packages the request and routes it to a payment processor.
-
The processor forwards it to the relevant card network (Visa, Mastercard, and so on).
-
The card network routes the request to the bank that actually issued the customer’s card.
-
The issuing bank checks the account: is there available credit or balance, does the card look stolen, does the transaction pattern look normal, and does anything about the merchant or amount trip a fraud rule.
-
The issuing bank sends an approve or decline back along the same chain, network to processor to gateway to merchant.
Four or five organizations, each running its own systems, each adding a small amount of latency, and the whole thing still finishes before the customer’s spinner feels slow. This is the core of what people mean when they ask how payment gateway APIs work: it is this chain of handoffs, not a single service doing one job.
Why some payments get approved instantly and others get declined or flagged
An approval or a decline is the issuing bank’s answer, not the gateway’s and not the merchant’s. The gateway and processor are carrying the question; the bank is the one deciding. That matters when a founder is debugging a spike in declines and instinctively blames the gateway integration, when the actual cause often sits upstream, in the bank’s own risk rules.
Declines generally fall into a few buckets:
-
Insufficient funds or credit, the most literal reason, and the easiest for a customer to fix.
-
Card details mismatched or expired, which a well-built checkout form catches before the call even goes out.
-
Fraud scoring, where the issuing bank’s own models flag the transaction as unusual for that cardholder, a mismatch in location, amount, or merchant category being common triggers.
-
Soft declines, where the bank wants more information or a retry, as opposed to a hard decline that means stop asking.
Some transactions come back neither approved nor declined but flagged for additional verification, commonly 3D Secure, where the customer is asked to confirm the purchase through their bank’s own app or a one-time code. This step adds friction and sometimes costs a sale, but it also shifts liability for fraud away from the merchant in many cases, which is the trade a lot of businesses are willing to make.
Capture versus authorization: the step most explanations skip
An authorization is not a payment. It is a hold, a confirmation that the funds exist and the bank is willing to set them aside. The money has not actually moved yet, and the merchant has not actually been paid. That happens at capture, a separate call the merchant’s system sends to tell the gateway to go ahead and collect the funds that were authorized.
For a simple retail purchase, authorization and capture often happen back to back, close enough in time that the distinction is invisible to the customer. But plenty of businesses rely on the gap between them on purpose. A hotel might authorize a card at check-in and capture only the final bill at checkout, once incidentals are added. A retailer shipping physical goods might authorize at order time but only capture once the item actually ships, so they are not collecting payment for something they have not yet sent.
Authorizations also expire if they are never captured, typically within a handful of days depending on the card network, after which the hold on the customer’s funds releases on its own. Anyone evaluating a gateway for a business with delayed fulfillment, subscriptions, or usage-based billing needs to understand this gap specifically, because it is where a surprising number of billing bugs live.
How settlement actually moves money, and why it takes days not seconds
Capture tells the system to collect the money. Settlement is the actual movement of funds from the customer’s bank to the merchant’s account, and it does not happen instantly, even though the authorization did.

Gateways and processors typically batch captured transactions together and submit them to the card networks at set intervals, often once a day. The card networks then route each transaction to the correct issuing bank, which transfers funds to the acquiring bank, which credits the merchant’s account, minus the processing fees taken out along the way. Each of those transfers has its own clearing time, which is why a merchant looking at their dashboard sees “funds available” dates that are measured in business days rather than minutes.
This is also where the gap between “the customer was charged” and “the merchant got paid” becomes concrete. The customer’s statement shows the charge almost immediately because authorization already put a hold on their funds. The merchant’s bank balance lags behind because settlement is still working through a batch process built around daily cycles, not real-time transfers.
Where this flow breaks: timeouts, retries, and failed webhooks
Every one of the handoffs described above is a place where something can go wrong, and a product person evaluating a gateway should assume some of it will.

A few of the common failure points:
-
Network timeouts between any two parties in the chain, where the gateway never hears back from the processor, or the merchant’s server never hears back from the gateway, leaving a transaction in an ambiguous state that has to be resolved by checking status rather than assuming failure.
-
Duplicate charges from naive retries, where a merchant’s system times out waiting for a response and resubmits the same authorization request, charging the customer twice unless the integration uses an idempotency key to tell the gateway “this is the same request, not a new one.”
-
Failed webhooks, the asynchronous notifications a gateway sends to tell a merchant’s system that a payment succeeded, failed, or a dispute was opened. If a merchant’s server is down or slow when that webhook fires, and the integration does not retry or reconcile, the merchant’s own records can quietly drift out of sync with what actually happened on the gateway’s side.
-
Partial failures in multi-step flows, such as a successful authorization followed by a capture call that fails, leaving an authorized-but-uncaptured transaction that someone has to notice and resolve manually.
None of this is a reason to avoid integrating payments directly. It is a reason to ask, before choosing a gateway, how it handles retries, what its webhook reliability looks like, and whether its API supports idempotency keys as a first-class feature rather than an afterthought.
What to check when you’re comparing gateway providers
Most gateway comparisons focus on pricing, which matters, but the mechanics covered here point to a shorter, more technical checklist worth running through first:
-
Does the gateway offer hosted tokenization fields, so raw card data never touches your own servers at all.
-
What does its authorization and capture API actually look like, and can you separate the two cleanly for your use case.
-
How does it report declines, with enough detail to distinguish a hard decline from a soft one worth retrying.
-
Does it support 3D Secure or equivalent step-up verification, and can you control when it triggers.
-
What is its webhook retry policy, and does its API support idempotency keys for safe retries on your end.
-
How long does settlement actually take in practice, and does that match your cash flow needs.
Reading the API documentation with these questions in hand tells you more about a gateway in twenty minutes than most comparison articles will.
For how this payment infrastructure fits into the broader fintech toolkit, see the comparison in Fintech Solutions.