How to Integrate a Payment Gateway: Technical Guide for Indian Businesses
6 min read
Highlights:
Understand three integration methods: hosted checkout, direct API, and hybrid SDK, with distinct PCI compliance requirements for each approach.
Discover webhook implementation for asynchronous payment status updates and sandbox testing protocols before production deployment.
Verify your payment gateway holds a valid RBI authorisation from the 46 authorised Payment Aggregators operating legally in India.
Introduction
Your customer adds items to the cart, fills in the address, reaches the checkout page, and confidently clicks Pay Now. Everything looks perfect. But if the payment page loads slowly, redirects oddly, or fails, the customer closes the tab without thinking twice.
That one moment decides whether you earn revenue or lose a customer forever.
Payment gateway integration is what powers this moment. It quietly connects your website or app with banks, UPI apps, and card networks in the background. When done right, users never notice it. When done wrong, they definitely do.
In India, payment integration is not just about code. It also involves RBI rules, security standards, and choosing from dozens of authorised payment aggregators. This guide explains how to integrate a payment gateway in simple terms, using real examples that reflect how Indian businesses actually operate.
Types of Payment Gateway Integration Methods
Three primary integration methods exist, each balancing technical control against compliance complexity.
Hosted checkout redirects customers to the gateway’s secure payment page. Your business collects order details, then sends customers to the gateway’s domain for payment completion. This method minimises your PCI DSS compliance scope since the gateway handles sensitive card data directly.Real-life use case: A D2C skincare brand using Shopify redirects users to a hosted payment page. They do not handle card details at all, which reduces risk and saves compliance effort.
Direct API integration keeps the entire checkout on your website using gateway APIs. You collect payment details on your server and transmit them via API calls. This offers maximum design control but requires full PCI DSS compliance costlier and more complex for small development teams.Real-life use case: A travel booking platform designs a custom checkout flow with offers, loyalty points, and multi-currency options. They use direct API integration to control every step of the payment experience.
Hybrid integration combines both approaches. The checkout form appears on your site, but sensitive data flows through SDKs or tokenisation, reducing PCI scope whilst maintaining brand consistency. PhonePe Payment Gateway provides low-code SDKs and RESTful APIs that integrate quickly with existing applications.Real-life use case: A food delivery app integrates a payment SDK so users can pay without leaving the app, while card data never touches the app’s servers.
Method
Development Time
PCI Scope
Design Control
Hosted
Hours to days
Minimal
Limited
Direct API
Days to weeks
Full (SAQ D)
Complete
Hybrid/SDK
Days
Reduced
High
Step-by-Step Integration Process
Before writing code, complete merchant onboarding with your acquiring bank. NPCI requires three stages: compliance and risk assessment, including KYC verification and nodal or current account setup; merchant identifier generation, where banks create your MID and TID; and UPI configuration, defining your MCC code, UPI ID, account details, and IFSC code.
Prepare business registration documents (GST certificate, PAN), director KYC documents (Aadhaar, PAN), and bank account details before approaching acquiring banks to reduce onboarding delays.
Once approved, choose between SDK and API integration. SDKs accelerate implementation for businesses with limited development resources through pre-built payment modules. APIs offer flexibility for custom checkout flows requiring specific business logic.
Implement webhook endpoints for asynchronous payment methods like UPI and net banking. Many payment flows don’t return an immediate status. Webhooks send automated server-to-server notifications when transactions complete, fail, or require action. Configure a secure HTTPS endpoint on your server to receive these POST requests, enabling real-time order status updates without constant polling.
Real-life use case: An online coaching platform uses webhooks so that once payment succeeds, the course access is unlocked automatically without waiting for manual checks.
Security & Compliance Requirements
All payment gateways operating in India must hold RBI authorisation under the Payment Aggregator framework introduced in March 2020. Payment Aggregators cannot commence operations without authorisation granted under Section 7 of the Payment and Settlement Systems Act, 2007.
Verify your chosen provider appears on RBI’s authorised list before integration. This protects against compliance risks and potential operational disruptions if unlicensed operators face regulatory action.
PCI DSS compliance requirements vary by integration method. All entities involved in payment processing need PCI compliance, but smaller merchants with limited cardholder data and fewer systems can reduce compliance efforts. Hosted checkout solutions handle card data entirely on the gateway’s infrastructure, minimising your audit scope. Direct API integrations, where you collect card details, require full PCI DSS validation (SAQ D), which is significantly more expensive and technically demanding.
Implement data encryption for all payment communications and use tokenisation to replace sensitive card numbers with non-sensitive equivalents during storage and transmission.
Why this matters: Several merchants have experienced payment freezes after using unlicensed gateways that were later shut down by regulators.
Testing Your Integration Before Go-Live
Never deploy payment integrations directly to production. All major payment gateways provide sandbox environments with test API keys and dummy card numbers for safe testing.
Sandbox environments let developers simulate real-time transactions using dummy data, helping identify bugs and integration errors before processing actual customer payments. This prevents revenue loss from failed live transactions and protects your brand reputation.
Test multiple scenarios: successful payments, declined transactions, network timeouts, partial refunds, webhook delivery failures, and payment method-specific flows (UPI pending status, net banking redirects). Validate that your system correctly handles each response code and updates the order status appropriately.
Create a validation checklist covering payment initiation, response handling, webhook verification, refund processing, and error logging. Only migrate to production after confirming all test scenarios pass consistently across multiple payment methods.
Real-life example: An e-commerce store avoided a major launch-day failure by thoroughly testing refund flows and webhook events in the sandbox environment first. By simulating successful payments, failed transactions, and refund scenarios, the team ensured their system responded correctly in every case.
They only switched to live mode once all scenarios worked consistently and reliably.
Your Next Steps
Payment gateway integration balances technical implementation with regulatory compliance. Choose integration methods matching your development resources and PCI compliance capacity. Complete merchant onboarding documentation early to avoid delays, implement webhooks for reliable payment status updates, and test exhaustively in sandbox environments before going live.
Verify your payment gateway holds a valid RBI Payment Aggregator authorisation. This protects your business from compliance risks whilst ensuring access to India’s complete digital payment infrastructure.
FAQs
1. What documents do I need to integrate a payment gateway in India?
You need business registration documents (GST certificate, PAN), bank account details (account number, IFSC code), KYC documents (Aadhaar or PAN of directors), and a nodal or current account for settlement. The acquiring bank verifies these during merchant onboarding.
2. How long does payment gateway integration typically take?
Simple hosted checkout integrations are complete in hours with pre-built plugins. Direct API integrations for custom requirements may take days to weeks, depending on complexity, testing requirements, and available developer resources.
3. Do I need PCI DSS compliance for all integration methods?
No. Hosted payment pages minimise your PCI DSS scope since the gateway handles card data. Direct API integrations, where you collect card details on your server, require full PCI DSS compliance (SAQ D), which is costlier and more complex.
4. What is the difference between a payment gateway and a payment aggregator?
Payment gateways facilitate transaction routing between banks. Payment aggregators onboard merchants, pool transactions, provide settlement services, and offer technological infrastructure for accepting multiple payment methods – all under RBI authorisation in India.
5. How do webhooks work in payment gateway integration?
Webhooks are automated server-to-server notifications sent by the payment gateway when events occur (payment success, failure, or refund). Your server receives these HTTP POST requests at a configured endpoint URL, allowing real-time order status updates without constant polling.