Payment APIs: A Guide for Merchants and High-Risk Businesses

API

A payment API is the interface that lets your website, app or platform talk to a payment provider: to take payments, issue refunds, store cards, run subscriptions and get transaction data back. If you sell online, you are almost certainly using one, even if a plugin hides it from you.

This guide explains what payment APIs are, how they work, the main integration options, how to secure a payment API integration, and what high-risk merchants should look for in a provider.

Key takeaways

  • A payment API (application programming interface) lets your systems send payment requests to a provider and receive the results.
  • Payment APIs handle more than taking money: refunds, captures, stored cards, subscriptions, payouts, disputes and reporting.
  • How you integrate affects your PCI DSS scope. Hosted payment pages and hosted fields keep card data off your servers. A direct API integration puts it in your hands.
  • Securing a payment API comes down to protecting keys, verifying webhooks, using tokens instead of card numbers, and testing in a sandbox before going live.
  • For high-risk merchants, the API matters less than what sits behind it: an acquirer that accepts your business and the tools to keep fraud and chargebacks down.

What is a payment API?

API stands for application programming interface: a defined way for one piece of software to ask another to do something. A payment API is the set of requests a payment provider makes available, such as “authorise this card payment”, “refund this order” or “list yesterday’s transactions”, along with the responses it sends back.

Payment APIs connect the parts of the payment chain: your checkout, your payment gateway, the acquirer and, through the card schemes, the customer’s bank. They replaced older setups where merchants had to rely on fixed, hard-to-change payment software.

Most payment APIs today are REST APIs that exchange data in JSON over HTTPS, and use API keys or tokens to identify the merchant.

What a payment API can do

FunctionWhat it does
PaymentsAuthorise, capture and cancel card payments and other payment methods
RefundsReturn all or part of a payment to the customer
Stored cards (tokenisation)Save a card as a token for repeat purchases without storing the card number
SubscriptionsCharge customers on a schedule using stored credentials
AuthenticationRun 3D Secure before authorisation
PayoutsSend money to sellers, creators or affiliates, where the provider supports it
DisputesReceive chargeback notifications and submit evidence
ReportingPull transaction, settlement and fee data into your own systems
WebhooksNotify your system automatically when something happens, such as a payment succeeding or a chargeback arriving

How a payment API works

  1. The customer checks out. Card details are collected, ideally by the provider’s own hosted form, so they never reach your server.
  2. Your system sends a request. It calls the provider’s API with the amount, currency, order reference and a token for the card, authenticated with your secret API key.
  3. The provider processes it. It runs fraud checks and 3D Secure if needed, then sends the authorisation request through the acquirer to the card issuer.
  4. A response comes back. Approved or declined, with a transaction ID and, for declines, a reason code.
  5. Webhooks follow up. Later events, such as settlement, refunds or chargebacks, are sent to your system as webhooks.

Lock icons connecting devices to a central payment system, illustrating encrypted payment processing

Integration options and PCI DSS scope

How card data enters your checkout decides how much of the PCI Data Security Standard (PCI DSS) you have to meet. The PCI Security Standards Council publishes different self-assessment questionnaires (SAQs) depending on the setup.

IntegrationHow it worksCard data on your systemsTypical PCI DSS effort
Hosted payment pageThe customer is redirected to the provider’s page to payNoLowest (usually SAQ A)
Hosted fields or iframeThe provider’s fields are embedded in your checkoutNoLow (usually SAQ A), but you must protect the page that loads them
JavaScript or direct postYour page sends card data straight to the provider from the browserNot stored, but your page handles itHigher (usually SAQ A-EP)
Direct server-to-server APICard data passes through your servers to the provider’s APIYesHighest (SAQ D or a full assessment)

Your acquirer decides which validation applies to you, so confirm it before you choose. For most merchants, hosted fields give the best balance of control over the checkout and a small compliance burden. A direct API integration only makes sense if you have a real reason to handle card data yourself and the security team to do it.

How to secure a payment API integration

  • Keep secret keys secret. Store API keys on the server, never in front-end code or in your code repository. Use separate keys for test and live, rotate them, and remove access when staff leave.
  • Use the least privilege. If the provider supports restricted keys, give each system only the permissions it needs.
  • Verify webhooks. Check the signature on every webhook so nobody can send fake “payment succeeded” messages to your system.
  • Use tokens, not card numbers. Let the provider tokenise cards so you never store the card number.
  • Make requests idempotent. Use idempotency keys or unique order references so a retried request doesn’t charge the customer twice.
  • Use HTTPS everywhere with current TLS versions, on your checkout and on your webhook endpoints.
  • Protect the checkout page. Scripts injected into a checkout page can skim card data, even with hosted fields. Control which scripts your payment pages load.
  • Log and monitor. Watch for unusual patterns, such as bursts of small authorisations that suggest card testing.

Why payment APIs matter for high-risk merchants

High-risk merchants face more fraud, more disputes and closer monitoring, so the integration needs to do more than take payments:

  • Stored credentials for subscriptions, set up correctly so renewals run as merchant-initiated transactions. See our guide to recurring billing.
  • 3D Secure and fraud data, sending the issuer as much information as possible to improve approvals.
  • Dispute webhooks, so chargebacks reach your team the moment they arrive and can be answered before the deadline.
  • Reporting by country and card type, so you can spot problems early. See our guide to improving approval rates.
  • Support for several acquirers or payment methods, where your provider offers it, so a single acquirer problem doesn’t stop all sales. Read more about payment orchestration.

Mainstream payment platforms with polished APIs often don’t accept adult, dating, gaming or nutraceutical businesses. For high-risk merchants, the first question is whether a provider will approve and keep your business. The API comes second. Our payment gateway API integration guide for high-risk merchants goes into the technical side in more detail.

Coins in the air as a card is used to pay

How to choose a payment API provider

  • Acceptance of your business. Confirm the provider and its acquirers work with your industry and countries.
  • Documentation and sandbox. Clear documentation and a test environment that behaves like production save weeks of development time.
  • Plugins for your platform. If you use WooCommerce, a subscription platform or a custom stack, check what is ready-made.
  • Payment methods and currencies available through the same API.
  • Transparent pricing, including scheme fees, refunds, chargebacks and any API or gateway fees.
  • Support. When an integration breaks in production, you need technical help quickly.

At FastoPayments, we believe that using AI as an assisting tool is a better fit for the payment industry. Since we’re not replacing jobs or watering down the industry, per se, with useless products and pointless features. Instead, we’re actually helping out merchants by offering them a comprehensive understanding and overview of their client.

Dennis E.R. Pedersen, CEO and Founder of FastoPayments

Dennis Pedersen, FastoPayments

Best practices for implementing a payment API

Plan first

Map your payment flows before writing code: one-off payments, subscriptions, refunds, failed payments, chargebacks and payouts. Decide which integration option fits your PCI DSS appetite.

Test thoroughly in the sandbox

Test approvals, declines, 3D Secure challenges, refunds, webhooks arriving late or twice, and network timeouts. Most production problems come from cases nobody tested.

Go live carefully

Start with low volume, watch approval rates and errors closely, and keep the old setup available until the new one is proven.

Monitor and improve

Track approval rates, decline reasons, chargebacks and API errors over time, and keep your integration and plugins up to date with your provider’s changes.

Frequently asked questions

What is a payment API?

A payment API is an interface that lets your website, app or platform send payment requests to a payment provider, such as taking a payment or issuing a refund, and receive the results.

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

A payment gateway is the service that securely passes payment data between your checkout and the acquirer. The payment API is how your systems talk to that gateway or provider.

How do I secure a payment API?

Keep secret keys on the server and rotate them, verify webhook signatures, use tokens instead of card numbers, use idempotency keys, use HTTPS, and control which scripts run on your checkout pages.

Do I need to be PCI compliant if I use a payment API?

Yes, every merchant that accepts cards has PCI DSS obligations. How much work it takes depends on the integration: hosted payment pages and hosted fields keep card data off your systems and need the least effort, while direct API integrations need the most.

What is a payment API sandbox?

A sandbox is a test environment where you can send API requests and simulate payments, declines and refunds without moving real money.

Can high-risk merchants use payment APIs?

Yes, but many mainstream payment platforms don’t accept high-risk businesses. High-risk merchants need a provider whose acquirers accept their industry, and that provider’s API or plugins.

What are payment webhooks?

Webhooks are messages a payment provider sends to your system when something happens, such as a payment succeeding, a refund completing or a chargeback arriving, so you don’t have to keep checking.

Next step

For high-risk merchants, the best API is the one connected to an acquirer that will keep processing your payments. Fasto works with adult, subscription, nutraceutical, gaming, dating and hospitality merchants, and approval typically takes two to three weeks.

Get a free quote, or read more about our high-risk merchant accounts.

There are years of industry experience behind our high-risk merchant guides and tips...