Payment Gateway Integration: A Practical Guide for Businesses and Product Teams

By Airhux Technology · October 21, 2026 · 7 min read

Payment gateway integration connects your website or app to a service that securely collects card and other payment details, sends them for approval, and reports the result back to you. Done well, customers pay smoothly and your records always match the money that actually moved. Done badly, you get failed payments, double charges, orders marked paid that were not, and a heavier compliance burden than necessary.

The work is not only technical. Choices such as where the card form lives, when you charge, and how you handle refunds affect risk, customer experience and accounting.

This guide walks through the decisions and building blocks every team should understand before writing the first line of payment code.

1. How a Payment Gateway Fits In

A typical online card payment involves several parties: your application, the payment gateway, the payment processor, the card networks and the customer's bank. The gateway is the part you integrate with.

  • Your app creates a payment for a specific amount and currency.
  • The customer enters payment details in a secure form.
  • The gateway sends the request for approval and returns a result.
  • Your app records the outcome and fulfills the order.

Your job in a payment gateway integration is to make each of those steps reliable, secure and traceable.

2. Hosted vs Embedded Checkout

The first big decision is where the payment form lives.

  • Hosted checkout: the customer is sent to, or shown, a payment page run by the gateway. It is the fastest to launch and keeps card data entirely off your systems, but you have less control over the look and flow.
  • Embedded checkout: payment fields appear inside your own page, usually as secure fields or components supplied by the gateway. You get a seamless experience while card data still goes directly to the gateway.
  • Direct API with raw card data: your servers handle card numbers themselves. This gives full control but brings the heaviest compliance burden and is rarely necessary.

For most businesses, hosted or embedded components offer the best balance of experience and security.

3. PCI DSS Scope and Tokenization

The Payment Card Industry Data Security Standard (PCI DSS) applies to any business that accepts card payments. How much of it applies to you depends on how card data touches your systems.

  • If card numbers pass through or are stored on your servers, your compliance scope is large.
  • If the gateway collects card data directly and gives you a token, your scope is much smaller.
  • A token represents the card for future charges without exposing the actual number.
  • Never log card numbers, security codes or full payment payloads.

Tokenization does not remove your obligations entirely, but it greatly reduces them. Confirm your specific requirements with your gateway and, where needed, a qualified assessor.

4. 3-D Secure and Strong Customer Authentication

3-D Secure adds a step where the customer's bank can verify the cardholder, for example through a banking app approval or a one-time code.

  • In some regions, such as the European Economic Area, strong customer authentication is required for many online payments.
  • Elsewhere, it can be used selectively to reduce fraud on higher-risk payments.
  • Successfully authenticated payments may shift liability for certain fraud claims away from the merchant, depending on network rules.
  • Your integration must handle the extra step and its outcomes, including the customer abandoning it.

Use the gateway's built-in support rather than building the flow yourself.

5. Authorize vs Capture

Card payments can happen in one step or two.

  • Authorization checks that funds are available and places a hold on the customer's card.
  • Capture actually takes the held money.
  • Sale or automatic capture does both at once.

Separating them is useful when you must confirm something before charging, such as stock availability, a booking with a supplier, or a final price. Authorize first, complete the order, then capture. If the order fails, release the authorization instead of refunding. Note that authorizations expire after a period set by the card networks and your gateway, so capture promptly.

6. Refunds and Chargebacks

Money sometimes needs to go back. Plan for both kinds of reversal.

  • Refunds are initiated by you, in full or in part, usually back to the original payment method.
  • Chargebacks are initiated by the cardholder through their bank, and you must respond with evidence within a deadline.
  • Record every refund against the original payment so totals always reconcile.
  • Prevent refunding more than was captured, and prevent the same refund being issued twice.
  • Keep order details, delivery evidence and customer communication to support chargeback disputes.

Clear descriptors on card statements and responsive customer support reduce chargebacks before they start.

7. Webhooks and Idempotency

Payments are asynchronous. A customer may close the browser before your app hears the result, and some payment methods confirm minutes or days later. Webhooks solve this.

  • Webhooks are notifications the gateway sends to your server when a payment succeeds, fails, is refunded or is disputed.
  • Verify every webhook's signature so attackers cannot fake a "payment succeeded" event.
  • Treat the gateway's confirmed status as the source of truth, not the browser redirect alone.
  • Expect duplicate and out-of-order events, and process each one safely.

Idempotency prevents double charges and duplicate records. Send an idempotency key with requests that create payments or refunds, so a retry after a timeout does not charge twice. Make your own webhook handlers idempotent too, by recording which events you have already processed.

8. Multi-Currency Payments

Selling internationally raises extra questions.

  • Decide which currencies you will show prices in and which you will settle in.
  • Check how your gateway handles currency conversion and its fees.
  • Use each currency's correct number of decimal places; some currencies have none.
  • Store amounts as integers in the smallest unit, or as precise decimals, never as floating-point numbers.
  • Offer payment methods that are popular in each market you serve.

Be clear with customers about the currency they are charged in.

9. Testing in the Sandbox

Every reputable gateway offers a sandbox, or test mode, with test keys and test card numbers.

  • Test successful payments, declines, insufficient funds and expired cards.
  • Test 3-D Secure challenges, including failure and abandonment.
  • Test authorization, capture, partial capture and release.
  • Test full and partial refunds and duplicate refund attempts.
  • Test webhooks, including delayed, duplicate and out-of-order delivery.
  • Test network timeouts and retries to confirm idempotency works.

Keep test and live keys strictly separate, store them as secrets, and never commit them to source code.

Common Mistakes to Avoid

  • Handling raw card numbers when hosted or embedded fields would do
  • Marking orders paid based only on the browser redirect
  • Ignoring webhook signature verification
  • Retrying payment requests without idempotency keys
  • Capturing payment before confirming the order can be fulfilled
  • Storing money as floating-point numbers
  • Mixing test and live keys, or committing keys to code
  • No plan for refunds, partial refunds or chargebacks

Frequently Asked Questions

How long does payment gateway integration take?

A hosted checkout can be quick to set up. Embedded checkout with authorization and capture, refunds, webhooks and multi-currency support takes more planning and testing. The surrounding business logic is usually the larger part of the work.

Do I need to be PCI DSS compliant if I use a gateway?

Yes, every business accepting cards has PCI DSS obligations. Using hosted or embedded fields with tokenization keeps card data off your servers and greatly reduces the scope. Your gateway can explain which self-assessment applies.

When should I use authorize and capture instead of an immediate charge?

Use it when you must confirm something before taking money, such as a supplier booking, stock check or final price. If fulfillment fails, you release the hold rather than issuing a refund.

What is idempotency in payments?

It means repeating the same request produces the same result rather than a second charge. Sending a unique idempotency key with each payment or refund request lets you safely retry after a timeout.

Can I support several payment gateways?

Yes. Some businesses use more than one for different regions, payment methods or redundancy. Keeping a consistent internal payment record across gateways makes reporting and refunds manageable.

How Airhux Can Help

Ecashpay is Airhux's payment solution and payment gateway. Airhux Technology also builds custom software and web and mobile apps, so we can help you plan a payment integration that fits your checkout, your order flow and your reporting.

If you are adding payments to a new or existing product, start your project with our team. For broader planning, see how much it costs to build an app.

  • payment gateway integration
  • how to integrate a payment gateway
  • payment gateway api
  • pci dss compliance
  • 3d secure
  • authorize and capture
  • payment webhooks
  • online payment integration
  • hosted checkout vs embedded checkout