Integrating a Payment Gateway: What to Settle Before You Write Code

A payment gateway integration is mostly a compliance, pricing and reconciliation decision wrapped around a small amount of code. Here is what Indian product teams should lock down before going live.

On this page
  1. Security and compliance come before the checkout screen
  2. Keep card data off your servers
  3. Verify who is actually authorised to process
  4. Treat tokenisation as a design constraint
  5. Server-side hygiene
  6. Read the fee stack, not the headline rate
  7. Test the failure paths, not just the success page
  8. Reconciliation must be designed in, not bolted on
  9. Plan for operations and exit

A payment gateway integration often starts as a two-day ticket and quietly turns into a six-week project once finance, security and customer support get involved. The code that calls the API is the easy part. What decides whether the integration holds up over the next three years is how you handle card data, how fees behave across instruments, how thoroughly you test the failure paths, and whether the money landing in your bank account can be matched line by line to orders in your database.

For Indian teams the compliance layer adds a few non-negotiables. Here is a practical pre-integration checklist covering security, fees, testing and reconciliation.

Security and compliance come before the checkout screen

Decide early how much payment data your systems will touch, because that single decision drives your audit burden, your engineering effort and your incident risk.

Keep card data off your servers

Hosted checkout pages, redirect flows and iframe-based card fields keep sensitive data inside the gateway's environment, which keeps your PCI DSS scope small. The moment card numbers pass through your own forms, your scope expands sharply and so does the evidence you must produce for compliance. Most teams building in 2026 have no good reason to accept that trade-off.

Verify who is actually authorised to process

Under the RBI's Payment Aggregator directions issued in 2020, only authorised entities should be pooling and settling funds for merchants. Many providers are technology platforms riding on a bank or a licensed aggregator. Understand who holds the money, who is the merchant of record on the settlement report, and what happens to your funds if the arrangement changes. Check the provider's status against the regulator's published list rather than relying on a marketing page.

Treat tokenisation as a design constraint

Card-on-file tokenisation has been in force since October 2022, which means saved cards are stored as tokens rather than raw card details. That affects subscriptions, one-click checkouts, EMI flows and any place where you previously assumed a stored card could be charged indefinitely. Design for the case where a token is missing, expired or not created for a given card network, and make sure your renewal logic degrades gracefully instead of silently failing.

Server-side hygiene

  • Compute the payable amount on the server. Never trust an amount sent from the browser.
  • Verify webhook signatures and treat unverified webhooks as untrusted input.
  • Use idempotency keys on every create-payment and refund call.
  • Rotate API keys, restrict them by IP where the provider allows it, and keep them out of client bundles and logs.
  • Never log full card numbers, CVV values or authentication credentials, even in debug builds.

Read the fee stack, not the headline rate

A quoted percentage is rarely the number that shows up in your bank account. Pricing differs by instrument, and a blended rate hides the parts that matter.

  • Per-instrument MDR. Cards, net banking, wallets and UPI are priced differently, and UPI along with RuPay debit transactions carries a mandated zero MDR for merchants. Model your unit economics per instrument rather than assuming one rate.
  • One-time and recurring charges. Setup fees, annual maintenance and platform charges are easy to overlook when comparing quotes.
  • Refunds. Ask explicitly whether the MDR is returned on a refund or whether you absorb it twice.
  • Disputes. Chargeback fees, representment charges and who bears the loss when evidence is rejected.
  • Settlement terms. T+1 versus T+2, instant settlement charges, rolling reserves, minimum settlement thresholds and weekend and holiday cut-offs.
  • Cross-border. Currency conversion markup and the extra compliance steps for international cards.

Get the commercial terms in writing, including the notice period for pricing changes, and check whether the rate is renegotiable once you cross a volume threshold. Also confirm how the provider invoices you and whether GST is charged on the fee, since that affects your input credit position.

Test the failure paths, not just the success page

Most integration bugs are not in the happy path. They show up when a customer's payment succeeds at the gateway but the callback never reaches your server, or when a retry creates a duplicate order.

  • Successful payment, failed payment and pending or asynchronous outcomes.
  • Network drop or browser close after authorisation but before your confirmation page loads.
  • Duplicate submissions, double clicks and client-side retries.
  • Full refunds, partial refunds, multiple partial refunds and refunds that fail.
  • Webhooks delivered out of order, delivered twice, or delivered after you already marked the order paid.
  • Amount and currency edge cases, including the smallest permitted transaction value.

Build an explicit order state machine so that a payment status cannot move backwards, and reconcile webhooks against a polling fallback for the cases where delivery simply does not happen. Once sandbox testing is done, run a small live pilot with internal users on real amounts before opening the flow to customers.

Reconciliation must be designed in, not bolted on

A webhook is a signal, not the truth. The settlement report and the bank statement are the truth, and they arrive later, sometimes net of fees and refunds.

Build a three-way match between your order records, the gateway's payment records and the bank credit. That requires durable identifiers: your own order reference passed to the gateway, the gateway's payment identifier, and the bank reference or UTR for the settlement credit. Store them immutably and keep an append-only event log instead of overwriting status fields.

Automate the daily download and ingestion of settlement files, and alert on unmatched items beyond an ageing threshold. Handle time zones and cut-off times explicitly, since a transaction at 11:58 pm may settle in the next cycle. Refunds, chargebacks and reversals should flow into the same reconciliation ledger so finance is not maintaining a parallel spreadsheet that nobody audits.

Plan for operations and exit

Before signing, ask about support escalation paths, documented uptime commitments, webhook retry policy and how you would migrate tokens and saved instruments to another provider if commercial terms turn sour. Some teams route a small share of traffic through a second gateway to reduce single-provider risk, but that only works if reconciliation is already clean enough to handle two settlement files.

None of this is glamorous. It is, however, the difference between a checkout that merely works in staging and a payments system that finance trusts, auditors accept and customers never have to complain about.

StopLord Editor Team

Engineering & Content

Practical guides from the StopLord Technologies team on web development, mobile apps, cloud, security and digital growth.

Keep reading

Let’s talk

Have a project in mind? Let’s build it together.

Tell us what you want to achieve. We will reply with honest advice, a clear scope and the next steps — no obligation.