Skip to content
EN
Book a demo

HomeGuides

Payment Gateway Integration, Step by Step, Through One API

Payment gateway integration means connecting your checkout to a gateway so it can take a customer's payment and tell you the result. You choose an integration method, send the gateway a payment request, handle its reply and its later status updates, test, and go live. The same process works for the first gateway and, with one API in front, for the tenth.

On this page

The rest of this page lists the payment gateway integration steps in the order you'd do them. Treat it as the payment gateway integration process your team runs once and reuses. Where a step depends on the gateway, it tells you what to look for in its API documentation, because every gateway names fields and statuses its own way.

01Payment gateway integration: before you start

Three decisions come before any code, and they're easier to make with these items in front of you.

What you need Who owns it Where it comes from
A gateway contract and test credentials Head of payments The gateway's onboarding team
API documentation for your chosen method Developer The gateway's developer portal
A list of countries, currencies and payment methods to launch with Product owner Your sales plan
A view of your PCI DSS obligations Security lead Your assessor and the standards body
A staging environment with a public callback address DevOps Your own infrastructure
A named owner for settlement checks Finance The gateway's reports

Cost questions belong here too. Costs split into the gateway's own charges, which its contract sets, and your side: developer time, security work and upkeep. Read the contract for the first. For the second, count the number of methods and providers, since each one adds testing and maintenance.

02Step by step

  1. 01 Choose how your checkout meets the gateway

    The method sets how much you build and how much card data you touch. A hosted payment page keeps card entry on the gateway's page. A JS SDK embeds the card fields in your page. Host-to-host sends card data from your servers to the gateway's API.

    Mobile apps use iOS or Android SDKs, and a CMS store can use a plugin. Weigh the checkout integration options against your team's skills and your PCI scope before you write code.

  2. 02 Work out your PCI DSS scope

    The more card data your systems handle, the more of PCI DSS you carry. Ask the gateway which self-assessment type applies to your chosen method, and have your assessor confirm it. Hosted pages and SDK-embedded fields keep the card number away from your servers in most designs, but the gateway's documentation says how its own version works. The PCI Security Standards Council holds the standard and the questionnaires.

  3. 03 Get credentials and a sandbox

    Request test credentials and the sandbox address. Keep test and live keys in separate places from day one, in secrets storage, never in your repository. In the gateway's documentation, find out how requests are authenticated and how long a key lasts.

  4. 04 Build the payment request

    Take the fields the documentation marks as required and map each to something your order system already holds: an order reference, an amount, a currency, a return address. Add nothing optional yet. After the request goes out, you should see a response that either completes the payment or sends the customer to a page for authentication.

  5. 05 Handle the reply and the status updates

    A gateway answers twice. The immediate reply tells you what happened to the request. Status updates arrive later, usually as callbacks or webhooks sent to an address you register, and they carry the outcome of anything that wasn't final at first. Ask the documentation which statuses are final, which can change and how to verify that an update came from the gateway.

    Write the handler so it can receive the same update twice without changing the order twice.

  6. 06 Add authentication for cards

    In the European Economic Area, the second Payment Services Directive requires strong customer authentication for most online card payments, and EUR-Lex holds the text. Your integration has to send the data the gateway needs for 3-D Secure and handle the return from the authentication page. Check the documentation for how the gateway signals a challenge.

  7. 07 Test in the sandbox

    Run the scenarios from the next section. Fix the first failure before looking for a second one, because early errors in the mapping tend to cause the later ones.

  8. 08 Go live in a small slice

    Swap in live credentials and open the integration to a small share of customers, such as one market. Watch the first settlements arrive and match them against orders. Widen when finance agrees the numbers match.

03Testing before real traffic

Use the gateway's test cards and scenarios, and record each result.

  • An approved payment marks the order as paid exactly once
  • A declined payment shows the customer a clear message and leaves the order open
  • A payment that needs authentication returns to your site and finishes
  • A repeated status update changes nothing
  • A refund appears on the order and in the gateway's test reports
  • A request with a wrong amount or currency is rejected before it leaves your server

Passing all six gives you a baseline. Re-run it whenever the gateway changes its documentation.

04Rolling back, and what goes wrong

The customer pays but the order stays open. The status update never reached you, or your handler rejected it. Check the gateway's delivery log against your server log for one payment, and make the handler return a clear success reply once it has stored the update.

Test works, live fails. Credentials, callback addresses and allowed server addresses often differ between environments. Compare them one by one, starting with the callback address, before you suspect your code.

The second gateway breaks the first integration. This happens when gateway-specific fields spread through your order code. Keep them behind one adapter, so adding a provider changes one file instead of every file.

To roll back a launch, switch the live market off in your configuration and return customers to the previous payment method. Keep the old route in place until two settlement cycles have matched.

05Where the platform does the step

Once one integration exists, a gateway you add behind our API leaves your checkout code as it is. The platform is a single API layer for transaction requests, routing and cascading, tokenization and reporting, with results in API responses and status updates by webhooks. API documentation is provided, role-based API keys are available, and every API call is recorded in logs. A sandbox mirrors production settings for testing.

Providers you already use join that layer as they are, and a missing one becomes a multi PSP integration request.

06FAQ

How does payment gateway integration work?

Your checkout sends a payment request to the gateway, the gateway talks to the card networks and banks, and it returns a result. Later status updates keep your order in sync. Everything in between belongs to the gateway.

How much does it cost to integrate a payment gateway?

The cost depends on the gateway's contract and on your own work, so there's no honest single figure. The drivers are developer time, security work, testing across methods and countries, and upkeep when providers change their APIs.

Do I need a different integration for PHP, Python or Java?

The gateway's API works the same way in any language. What changes is your code. Check whether the gateway publishes an official library for your language, and if it doesn't, call the API directly following its documentation.

Can I integrate more than one gateway?

Yes. You can build each one directly, or send everything to one API and attach gateways behind it. The second route keeps your checkout code the same as providers are added or replaced.

Next step

Plan your integration with us

Tell us your method, your markets and the gateways you have or want, and we'll walk through the steps that apply to you. Talk to us about integration.

Book a demo

Map your integrations onto one API

We look at the providers you run today and what moving them behind one API would take.