How Payment Gateway APIs Move Money From Customer to Your Account
What a payment gateway API does, and why you need one
A payment gateway API is the bridge between your website or app and the banks and card networks that actually move money. When a customer enters their card number on your checkout page, the API sends that information securely to a payment processor, which checks with the card issuer (Visa, Mastercard, their bank) to confirm the funds exist. If approved, the money moves from the customer's account toward yours. The API then sends a yes-or-no answer back to your checkout page in real time—usually in under a second.
You do not build or run the API yourself. You rent access to one from a payment processor like Stripe, Square, PayPal, or Authorize.net. The processor owns the infrastructure, handles the security rules (called PCI compliance), and keeps the connection open to the card networks 24 hours a day. Your job is to plug your website or app into their API using the code they provide, then test it so that when a real customer buys something, the transaction goes through.
Without an API, you would have to send customers to a separate payment page hosted by the processor—slower, less branded, and more likely to lose sales. An API lets you keep customers on your site the whole time, which feels seamless and builds trust.
Key Takeaways
- A payment gateway API is software that connects your checkout page to the banks and card networks that approve and move money.
- You do not build the API; you rent it from a payment processor like Stripe, Square, or Authorize.net, which handles security and compliance.
- The API sends card data securely, receives an approval or decline in under a second, and tells your website whether the sale went through.
- Most processors charge a percentage of each transaction (typically 2.2% to 3.5%) plus a small per-transaction fee, and some add monthly minimums or setup costs.
- Integration takes anywhere from a few hours for a simple store to several weeks for a large system, depending on your technical team and the processor's documentation.
How the API actually processes a transaction, step by step
When a customer clicks "Pay Now" on your checkout page, your website collects their card number, expiration date, and CVV (the three-digit security code). Your code then calls the payment processor's API with that information, plus the amount, currency, and a description of what is being bought.
The API encrypts the card data so it cannot be read in transit, then sends it to the processor's servers. The processor checks the card number format, looks up which bank issued it, and sends a request to that bank asking "Does this card have enough money? Is it stolen? Is it blocked?" The bank responds within milliseconds. If the answer is yes, the processor reserves the funds (called an authorization). If no, the processor sends back a decline code—"Insufficient funds," "Card expired," "Fraud suspected"—and your checkout page shows the customer an error message.
If the authorization succeeds, the processor sends your API a confirmation code and a transaction ID. Your website stores that ID, shows the customer a receipt, and sends them an order confirmation email. Behind the scenes, the processor begins moving the money: the customer's bank debits their account, the card network (Visa, Mastercard) routes the funds, and the processor deposits the money into your business bank account—usually within one to three business days, though some processors offer next-day or same-day settlement for an extra fee.
If you need to refund the customer later, you use the same API to send back the transaction ID and the refund amount. The processor reverses the charge, and the money goes back to the customer's card within a few days.
What you pay for a payment gateway API
Payment processors charge in three ways. The most common is a percentage-plus-per-transaction fee: you pay a percentage of the sale (usually 2.2% to 3.5%) plus a flat fee per transaction (usually $0.25 to $0.50). So a $100 sale might cost you $2.70 to $3.50. Some processors also charge a monthly fee ($20 to $300) whether you process transactions or not, or a minimum monthly charge (you pay the higher of the monthly fee or the percentage-based fees you actually owed).
A few processors use a flat-rate model: you pay the same percentage on every transaction regardless of card type or whether the card is present. This is simpler to predict but usually costs more if you process a lot of high-value sales.
Some processors charge extra for features: recurring billing (charging a customer's card on a schedule, like a subscription), international transactions, ACH transfers (bank-to-bank payments), or chargeback disputes (when a customer disputes a charge with their bank). A few charge for PCI compliance (the security standard that protects card data), though most include it in their base fee.
Settlement speed also affects cost. Most processors deposit your money in one to three business days at no extra charge. If you want next-day or same-day settlement, you typically pay an additional 0.5% to 1% of the transaction amount.
Choosing between different payment processors and their APIs
The main processors—Stripe, Square, PayPal, Authorize.net, and Adyen—all offer similar core features but differ in ease of setup, pricing, and what extras they include. Stripe and Square are known for clear documentation and fast integration; Authorize.net is older and more common in enterprise systems; PayPal is easiest if you already have a PayPal account; Adyen is built for high-volume international businesses.
Before you choose, decide what you actually need. If you run a simple online store, you want an API that is easy to integrate and has good support for your platform (Shopify, WooCommerce, custom code). If you run a subscription business, you need one that handles recurring billing well. If you sell internationally, you need one that supports multiple currencies and local payment methods (not just cards). If you process high volume, you want one with competitive rates and fast settlement.
Most processors let you test their API in a sandbox environment—a fake version where you can send test card numbers and see what happens without moving real money. Always test before you go live. Test a successful charge, a declined card, a refund, and a chargeback dispute if the processor supports it.
Security and compliance: what the API handles for you
The biggest reason to use a payment processor's API instead of building your own is that they handle PCI DSS compliance—a set of security rules that protect card data. If you store or transmit card information yourself, you become responsible for PCI compliance, which means expensive audits, strict security controls, and massive liability if data is stolen. Most small and medium businesses cannot afford this.
When you use a payment processor's API correctly, you never touch the raw card number. Your checkout page sends it directly to the processor's servers, encrypted. Your servers only ever see the transaction ID and the approval status. This keeps you out of PCI scope and protects your customers' data.
The API also handles tokenization: the processor stores the card securely on their servers and gives you a token (a random string) that represents that card. You can use the token to charge the card again later without asking for the card number again. This is how subscription billing and one-click checkout work.
Most processors also offer fraud detection built into the API—they flag suspicious patterns (a card used in two countries in an hour, a sudden spike in transaction volume, a card that has been reported stolen) and either decline the charge or ask the customer for extra verification. You can usually adjust these rules in the processor's dashboard.
Common problems during API integration and how to fix them
The most common mistake is sending card data to your own servers before sending it to the API. This breaks PCI compliance and exposes you to liability. Always send the card number directly from the checkout page to the processor's API, never through your own backend.
The second common mistake is not handling errors gracefully. If the API times out or returns an error code, your checkout page should show the customer a clear message ("Your card was declined. Please try another card" or "Something went wrong. Please try again in a few seconds") and log the error so you can investigate. Do not show raw error codes or technical jargon to the customer.
The third is not testing refunds and disputes. Many businesses integrate the charge flow perfectly but never test what happens when a customer disputes a charge or asks for a refund. Test both before you go live, so you know how to handle them when they happen.
Integration time varies widely. A simple integration (one-time charges on a basic website) can take a few hours. A complex one (recurring billing, multiple currencies, fraud detection, custom reporting) can take weeks. Most processors provide sample code and documentation, but if your team is not familiar with APIs, budget time for learning or hire a developer who has integrated that processor before.
Frequently Asked Questions
Do I need a payment gateway API if I use Shopify or WooCommerce?
No. Shopify and WooCommerce have built-in payment processing; they handle the API integration for you. You just choose a processor (Stripe, Square, PayPal) in your settings, and the platform connects to their API automatically. You still pay the processor's fees, but you do not write any code.
What happens if the API goes down?
If the processor's servers are unavailable, your checkout page cannot process charges. Most processors may provide 99.9% uptime, which means a few hours of downtime per year. During an outage, you can either wait for the processor to recover or temporarily redirect customers to a backup processor if you have one set up. This is rare but worth planning for if you process high volume.
Can I use multiple payment processors at once?
Yes. You can integrate multiple APIs into your checkout page and let customers choose which processor to use, or automatically route transactions to different processors based on rules you set (e.g., use Processor A for US cards, Processor B for international cards). This adds complexity but gives you redundancy and can help you negotiate better rates.
How long does it take for money to show up in my bank account?
Most processors deposit funds one to three business days after the transaction is approved. Some offer next-day or same-day settlement for an extra fee. The exact timing depends on your processor, your bank, and whether the transaction is disputed. Refunds usually take three to five business days to appear back on the customer's card.
What is a chargeback, and how does the API handle it?
A chargeback happens when a customer disputes a charge with their bank instead of asking you for a refund. The bank investigates and either sides with the customer (you lose the money and pay a chargeback fee, usually $15 to $100) or sides with you. The API does not prevent chargebacks, but most processors let you view disputes in your dashboard, upload evidence (like a shipping confirmation or email receipt), and respond to the bank's investigation.