Before You Integrate a Payment Gateway: Security, Fees, Testing and Reconciliation

Payment gateway integration is rarely a two-day ticket. Here is how Indian product teams should think about security obligations, the real fee stack, test coverage that actually matters, and the reconciliation workflow most launches forget.

On this page
  1. Security is a shared responsibility, not a handoff
  2. Understand the full fee stack before you model unit economics
  3. Testing is where most integrations quietly fail
  4. Reconciliation is an operations problem, not a finance afterthought
  5. The checklist, condensed

Payment gateway integration is one of the few pieces of engineering work that touches money, regulatory compliance and customer trust simultaneously. Yet it is often scoped as a sprint task: pick a provider, drop in a checkout script, go live. That framing is why so many Indian product teams discover the hard parts weeks after launch — a settlement mismatch nobody can trace, a failed-payment bug that only appears on one bank's netbanking flow, or a compliance question about stored card data that nobody on the team can answer.

This article is a pre-integration checklist, not a vendor comparison. It covers the four areas where integration decisions have the longest tail: security, fees, testing and reconciliation.

Security is a shared responsibility, not a handoff

The most consequential early decision is how much card data your systems ever touch. Hosted checkout pages and redirect flows keep sensitive data inside the gateway's environment, which dramatically narrows your compliance surface. Direct API integrations with custom card forms put more of the burden on you, including PCI DSS obligations that come with handling, transmitting or storing cardholder data.

In India, two regulatory realities shape this choice. First, card-on-file tokenisation rules mean merchants cannot store raw card credentials; repeat payments rely on tokens issued through the card networks. Second, the RBI's payment aggregator framework requires gateway partners to be authorised and to perform merchant onboarding and KYC. Ask prospective providers directly for their authorisation status and how they handle merchant KYC — it is your compliance exposure too, not just theirs.

Beyond the provider choice, several controls are non-negotiable on your side:

  • Never trust the client. Recompute order amounts on the server before creating a payment. A tampered payload from a mobile app should never be able to change what the customer is charged.
  • Verify every webhook signature. Treat unsigned or unverified callbacks as hostile. Also treat webhooks as notifications, not as the source of truth — confirm the status with a server-side API call before fulfilling an order.
  • Keep secrets out of code. Gateway keys belong in a secrets manager with rotation support, not in a repository or a mobile binary.
  • Log carefully. Never write card numbers, CVVs, full tokens or personal data into application logs, error trackers or support tickets.
  • Assume retries will happen. Idempotency keys on payment and refund creation prevent duplicate charges when networks time out.

Additional factor authentication for domestic card-not-present transactions is a regulatory requirement, and it is also where most user drop-off happens. Design your checkout flow around that redirect or challenge step rather than treating it as an exception path.

Understand the full fee stack before you model unit economics

The headline merchant discount rate is only one line item. A realistic cost model for payment gateway integration includes:

  • Per-transaction pricing by instrument — cards, UPI, netbanking, wallets and EMI often carry different rates. UPI and RuPay debit transactions currently carry a mandated zero MDR for merchants, which materially changes the economics of small-ticket payments.
  • Applicable GST on gateway charges, which is billed on top and is easy to forget in margin calculations.
  • Platform or annual fees, minimum monthly billing, and setup or onboarding charges.
  • Refund and chargeback fees. Refunds frequently do not return the original processing fee, and chargebacks carry a fixed penalty plus the disputed amount.
  • Failed-payment cost. This is invisible on a pricing sheet but real: support time, retries and abandoned carts.

Two practical questions are worth asking in the commercial conversation: how pricing changes as volume grows, and what the settlement cycle actually is (T+1, T+2, or longer for certain instruments or risk profiles). Settlement timing affects working capital as much as pricing does.

Testing is where most integrations quietly fail

Sandbox environments rarely behave exactly like production. That is precisely why test coverage should target the messy paths, not the happy one. A minimum viable test matrix includes:

  • Successful payment for every instrument you plan to support, using the provider's official test credentials.
  • Explicit failures — declined cards, insufficient funds, bank downtime, abandoned authentication challenges.
  • Webhook behaviour: duplicate delivery, out-of-order arrival, delayed callbacks, and retries after your endpoint returns a server error.
  • Idempotency: submitting the same request twice and confirming only one charge exists.
  • Timeouts and pending states — what the customer sees, what your database records, and how the order resolves later.
  • Refund flows, partial refunds, and refunds issued after settlement.
  • Browser and app edge cases: back button, page refresh mid-payment, switching apps during a UPI collect request, and the return-to-app deep link.

Before full launch, run a small number of live transactions with real money and real settlement. Test environments will not reveal how your reconciliation process behaves against an actual settlement report.

Reconciliation is an operations problem, not a finance afterthought

A payment is not finished when the customer sees a success screen. It is finished when the money lands in your bank account, matches the order, and the fee has been accounted for. Most teams build this last, and then improvise it in a spreadsheet.

Design it early. Capture the gateway payment identifier, your internal order identifier, the instrument used, the gross amount, the deducted fee and the bank reference (UTR) at the time of the transaction. Then build a scheduled job that pulls the gateway's settlement report, compares it against your order ledger, and flags three classes of exception: payments marked successful but never settled, settlements with no matching order, and amount mismatches caused by refunds, chargebacks or fee deductions.

Give that exception queue an owner and an escalation path to the provider's support team, with agreed response times written into the contract. Keep settlement reports and gateway invoices archived for audit; finance will need them for input tax credit and for dispute defence.

The checklist, condensed

Before you write integration code, settle four things: how much card data you will touch and what that means for compliance; what the total cost of a payment looks like after GST, refunds and failures; which failure paths your test suite covers; and who owns the daily reconciliation exception queue. Answer those, and the actual API work becomes the easy part.

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.