Skip to content
Payment Gateway Integration Services
Technology15 min read

Payment Gateway Integration Services

Scult Team
15 min read

PCI scope, tokenization, webhook-based status updates, and failed-payment handling — how payment integration actually works and what it costs.

Payment Gateway Integration Services

Direct answer: Payment gateway integration connects your product or website to a payment processor's API so it can accept card payments, bank transfers, or digital wallets, while keeping raw card data out of your own systems through hosted fields or tokenization, handling payment confirmation asynchronously through webhooks, and gracefully managing the failed payments and retries that are a normal part of processing volume — not an edge case.

Payment integration looks deceptively simple from the outside: charge a card, get a confirmation, done. In production, most of the engineering effort goes into the parts that aren't the happy path — reducing your compliance burden, handling the payment statuses that arrive after the initial charge, and building retry logic for the failed payments that will happen at some percentage of your transaction volume no matter which processor you use.

What Is Payment Gateway Integration?

A payment integration is the code that connects your checkout flow, billing system, or app to a payment processor's API — the service that actually moves money, handles card networks, and manages compliance with card-brand rules. Your integration collects payment details (ideally without ever touching raw card numbers directly), sends a charge request to the gateway, and then handles the gateway's response — which, for many payment methods, doesn't arrive as a simple synchronous "approved" or "declined" but as a series of asynchronous status updates delivered via webhook.

The integration also needs to handle the full lifecycle beyond the initial charge: refunds, partial refunds, disputes and chargebacks, subscription renewals if it's recurring billing, and payment method updates when a saved card expires. Treating "process a payment" as the entire scope, rather than the full lifecycle around it, is the most common reason payment integrations need costly rework after launch.

This is worth emphasizing because it's where most underestimated projects go wrong. A team scoping "add payment processing" often estimates based on the checkout form and the first successful charge, because that's the part that's visible and demoable. The refund flow, the dispute-evidence submission process, the logic for what happens when a saved card on a recurring plan expires mid-cycle — these are all quieter requirements that surface weeks after launch, usually as an urgent request once a real customer hits one of them. Scoping the full lifecycle upfront, even at a basic level for each case, avoids that pattern.

How Does PCI-DSS Scope Reduction Work With Hosted Fields and Tokenization?

PCI-DSS (Payment Card Industry Data Security Standard) is the compliance framework every business handling card payments has to meet, and its scope — the amount of audit and security burden you carry — depends heavily on how your integration is built, not just on transaction volume.

The single biggest lever for reducing PCI scope is never letting raw card numbers touch your own servers. Two patterns achieve this: hosted fields (where the card input form is rendered by the payment processor inside an iframe embedded on your page, so card data goes directly from the customer's browser to the processor, never through your backend) and tokenization (where the processor returns a token representing the card after first collection, and every future charge uses that token instead of the raw card number). Both patterns mean your systems only ever handle a token or a reference ID, never the actual card number — which keeps you in a lighter PCI compliance category (commonly referred to as SAQ A or SAQ A-EP, depending on exact implementation) instead of the much heavier scope that applies when your own servers process raw card data directly.

This is worth planning for at the architecture stage, not retrofitting later: a checkout built to pass raw card fields through your own backend, even briefly, pulls the entire integration into a heavier compliance category, with more required security controls and a more involved annual audit process.

There's a related consideration teams often miss: even logging or error-tracking tools can accidentally capture raw card data if a request payload is logged in full for debugging purposes. A card number that briefly passes through your application layer and gets swept into an error log or an analytics event is still a PCI scope violation, even if it was never intentionally stored. Redacting or excluding payment fields from general-purpose logging and monitoring tools is a small, easy-to-overlook detail that matters as much as the checkout architecture itself.

How Do Webhooks Handle Payment Status Updates?

Most payment methods don't resolve instantly. Card payments can require additional authentication steps (3D Secure verification, for instance), bank transfers can take days to settle, and even a straightforward card charge can move through intermediate states — pending, processing, succeeded, failed — before landing on a final status. Building a checkout that assumes a single synchronous "success" response is one of the most common integration mistakes, because it misses every payment method and edge case that doesn't resolve instantly.

Webhooks are how the payment gateway tells your system what actually happened, after the fact. Your endpoint receives an event — payment succeeded, payment failed, dispute opened, subscription renewed — and updates your own records accordingly. This means your system's source of truth for "did this payment succeed" should be the webhook event, not just the initial API response from creating the charge, because the initial response often only confirms the charge was created and is being processed, not that it definitively succeeded.

Building this correctly means verifying the webhook's signature (to confirm it's genuinely from the payment gateway and not a spoofed request), handling duplicate webhook deliveries idempotently (payment gateways commonly retry webhook delivery if your endpoint doesn't respond in time, so the same event can arrive more than once), and processing events in a way that tolerates out-of-order delivery.

What Is the Difference Between a Native, Middleware, and Custom Payment Integration?

Approach What it is Best for Limitations
Native/hosted checkout A pre-built checkout page or widget hosted by the payment provider Fast launch, minimal PCI scope, standard checkout flows Limited branding and UX control, less flexibility for complex pricing or multi-step flows
Middleware/plugin A pre-built plugin for a common ecommerce platform (WooCommerce, Shopify) Standard ecommerce use cases on a supported platform Limited to what the plugin supports; custom logic often requires extending or replacing it
Custom integration Direct API integration with hosted fields or tokenization, built for your specific checkout and billing logic Custom checkout flows, subscription billing, marketplace payment splitting, non-standard pricing Requires more engineering upfront; you own more of the payment state logic

Native checkout is the right starting point for a simple, standard transaction flow where speed to launch matters more than checkout customization. Custom integration becomes necessary once your checkout has non-standard logic — usage-based pricing, marketplace payment splitting, a multi-step checkout with saved payment methods, or a subscription model with proration and plan changes — that a hosted checkout page can't represent. Our subscription commerce guide covers the broader product and business-model considerations that shape which of these approaches fits, beyond the technical integration decision alone.

How Much Does Payment Gateway Integration Cost?

Cost depends on checkout complexity, whether the integration is one-time payments or recurring billing, and how much of the payment lifecycle (refunds, disputes, retries) needs custom handling versus using the processor's built-in tools.

A straightforward one-time payment integration — hosted fields or a hosted checkout page, standard webhook handling for payment confirmation — fits our Essential tier at $1,000.

Growth tier at $2,000 covers recurring/subscription billing with webhook-driven status sync, failed payment retry logic, and basic dunning (the process of following up on failed recurring payments) built into your own billing flow rather than relying entirely on the processor's defaults. Our dedicated subscription billing system guide covers the recurring-payment edge cases — proration, plan changes, failed renewals — in more depth than fits here, and our SaaS pricing models guide is a useful companion if you're still finalizing the pricing structure the integration needs to support.

Enterprise tier at $4,000+ covers marketplace or platform payment splitting, multi-currency or multi-processor setups, custom fraud rules layered on top of the processor's own fraud detection, and integrations requiring detailed audit logging for compliance. Full pricing detail is on our pricing page.

One cost driver worth planning for specifically: businesses operating in multiple countries often need more than one payment processor, because processor coverage, supported local payment methods, and settlement currencies vary by region. An integration built assuming a single processor from day one can be harder to extend later than one designed with a processor abstraction layer from the start — even if only one processor is actually connected at launch. That upfront design choice is usually the difference between adding a second processor being a two-week project versus a rebuild.

How Long Does a Payment Gateway Integration Take?

A standard one-time payment integration using hosted fields and a common payment processor typically takes one to three weeks, including checkout UI integration, webhook setup, and testing across success and failure scenarios.

Recurring billing integrations — subscription creation, plan changes, proration, failed payment retry logic — usually run three to six weeks, because the state machine around a subscription (active, past due, canceled, paused) has meaningfully more edge cases than a single charge. Marketplace or multi-party payment splitting, or integrations spanning multiple payment processors or currencies, commonly run six to twelve weeks. Our methodology page covers how we scope discovery for payment projects specifically, since the billing edge cases — not the initial charge flow — are usually what determines the real timeline.

How Do You Handle Failed Payments and Retries?

Failed payments are routine, not exceptional — insufficient funds, expired cards, banks declining for fraud-prevention reasons, and temporary processor issues all happen at a predictable rate across any real transaction volume. A production integration treats this as a designed flow, not an afterthought.

For recurring billing specifically, the standard pattern is a dunning sequence: retry the failed payment on a schedule (immediately, then after a day, then after several days, tapering off), notify the customer at each stage so they have a chance to update their payment method, and only cancel or pause the subscription after a defined number of failed attempts. For one-time payments, the pattern is simpler — surface a clear, specific failure reason to the customer where the processor provides one, and let them retry with the same or a different payment method without losing their cart or order context.

The retry logic itself needs to be idempotent, using the payment processor's idempotency key mechanism to guarantee that a retried request — whether retried by your own system or by the customer refreshing a page — doesn't result in a duplicate charge.

The specific reason customers give a card in the first place matters too, and shapes how aggressive your retry schedule should be. Insufficient funds often resolves itself within a few days as an account gets topped up, so a spaced-out retry schedule over a week or two tends to recover more of these payments than immediate retries. An expired card, by contrast, won't resolve itself no matter how many times you retry the same card — the fastest path to recovery there is prompting the customer to update their payment method directly, sometimes through a hosted update-payment-method page the processor provides, rather than continuing to retry against a card that will never succeed. Distinguishing between failure reasons and tailoring the retry strategy accordingly is what separates a dunning system that meaningfully recovers revenue from one that just retries blindly and hopes.

Do You Need a Developer, or Can You Use a Plugin?

For a simple, standard checkout on a supported ecommerce platform, a well-maintained plugin can genuinely handle the integration without custom development — that's a legitimate choice when your checkout and billing needs are standard.

You need a developer once your checkout flow is custom (a multi-step signup with payment, a usage-based pricing model, saved payment methods across multiple products), once you need marketplace-style payment splitting, once your fraud or risk rules need to go beyond what the processor provides by default, or once you're integrating payments into a fully custom application rather than an existing ecommerce platform. Our custom software development team scopes payment integrations with PCI scope and lifecycle handling as first-class parts of the estimate, not an afterthought added after the checkout UI is built. If in-app purchases are part of your product rather than a web checkout, our in-app purchases and subscriptions guide covers the platform-specific considerations (App Store and Play Store billing rules) that a payment integration alone doesn't address.

Is Payment Gateway Integration Secure?

Security for a payment integration rests on a few concrete, non-negotiable practices: never handling raw card data on your own servers (via hosted fields or tokenization, as covered above), verifying webhook signatures on every incoming event, using idempotency keys to prevent duplicate charges, and enforcing HTTPS/TLS on every endpoint that touches payment data, checkout pages included.

Beyond the technical controls, PCI-DSS compliance itself is a process, not just a checklist — it typically involves an annual self-assessment questionnaire (or a full audit, depending on transaction volume) confirming the controls in place match your actual PCI scope. Building the integration in a way that keeps you in the lightest applicable PCI scope, as covered earlier, is what keeps this an annual questionnaire rather than a significant recurring compliance burden. Our SaaS security checklist covers the broader data-protection practices — encryption, access control, audit logging — that a payment integration should sit alongside, not apart from.

What Can Go Wrong With a Payment Integration?

The most common and costly mistake is treating the initial API response as the final word on payment success, rather than waiting for and correctly processing the webhook confirmation — this leads to orders being marked "paid" when the charge later fails, or customers being denied access to something they did successfully pay for because the webhook wasn't handled.

Other recurring issues: double-charging customers because idempotency wasn't implemented on retries, chargebacks not being handled as a distinct workflow from ordinary refunds (a chargeback needs evidence submission and has different financial implications than a standard refund), and fraud slipping through because the integration relies solely on the payment processor's default fraud rules without any additional checks suited to the specific business. Our ecommerce fraud prevention guide covers the fraud-scoring and chargeback-management side of this in more depth.

A less obvious failure mode is currency and amount-handling bugs — payment processor APIs commonly expect amounts in the smallest currency unit (cents rather than dollars, for instance), and a mismatch between how your application stores amounts and how the API expects them can produce charges that are off by a factor of 100, either overcharging or undercharging customers. This class of bug is easy to catch in testing with a deliberate check, and expensive to discover in production after real transactions have already gone through. Testing with multiple currencies early, even if you launch with just one, catches this before it becomes a live incident.

Pre-Launch Payment Integration Testing Checklist

Before any payment integration goes live, work through this list against the processor's sandbox/test environment:

  • Test a full successful charge end-to-end, including the webhook confirmation, not just the initial API response
  • Test a declined card and confirm the customer sees a clear, specific failure reason where the processor provides one
  • Test 3D Secure or equivalent additional-authentication flows if your customer base includes cards that require it
  • Send a duplicate webhook event and confirm idempotent processing prevents double-updating an order or subscription
  • Test a full refund and a partial refund, confirming both update your own records correctly
  • Simulate a chargeback/dispute event and confirm it routes to a distinct workflow from a standard refund
  • Test the full dunning sequence for a recurring payment, including the final cancellation step after repeated failures
  • Confirm amounts are handled in the correct unit (cents vs. whole currency) across every currency you support
  • Verify webhook signature validation rejects a request with an invalid or missing signature
  • Confirm PCI scope assumptions hold — audit that no raw card data appears in application logs, error trackers, or analytics events

Key Takeaways

  • Hosted fields and tokenization keep raw card data off your servers, which is the single biggest lever for reducing PCI-DSS compliance scope.
  • Webhooks, not the initial charge API response, are the reliable source of truth for payment status — build your system around that from the start.
  • Pricing runs $1,000 for a simple one-time payment integration, $2,000 for recurring billing with dunning logic, and $4,000+ for marketplace splitting or multi-processor setups.
  • Failed payments are routine at any real transaction volume; a dunning sequence with scheduled retries and customer notifications handles this better than a single retry attempt.
  • Idempotency keys are what prevent duplicate charges when a request is retried, whether by your system or by the customer.
  • Native/hosted checkout and ecommerce plugins are legitimate for standard flows; custom integration is worth it once checkout logic, billing model, or payment splitting gets non-standard.
  • Our Stripe integration development guide covers the specific patterns — Payment Intents, Stripe Connect — if Stripe is your processor of choice.
  • Our broader custom API integration services guide covers the general integration patterns — REST, webhooks, rate limits, testing — that apply across any integration project, payments included.

Ready to build a payment flow that handles the failure cases, not just the happy path? Book a meeting to scope your integration.

Want results like this?

Keep reading