All insights
Technology & EngineeringNode.js

Payment Gateway Integration in India: A Developer and Business Guide

How to integrate a payment gateway in an Indian website or app: choosing a provider, UPI and cards, server-side order creation, webhooks, refunds, security, and testing.

Payment gateway integration with UPI, cards and webhooks in India
Quick answer: create the order on your server, open the gateway's checkout on the client, verify the payment signature on the server, and treat the gateway's webhook as the final source of truth. Never trust the browser alone to confirm a payment, and test refunds and failures as carefully as successes.

Choosing a gateway

Indian businesses commonly choose providers such as Razorpay, Cashfree, PayU, or Stripe India, among others. Compare:

  • Supported methods: UPI, cards, net banking, wallets, EMI, and international cards.
  • Pricing and settlement time.
  • Subscription and recurring payment support, including UPI AutoPay.
  • Quality of documentation, SDKs, and dashboard.
  • Onboarding requirements: KYC documents and business verification.

Start onboarding early, because account activation can take time.

The correct payment flow

  1. Create an order on the server with the amount calculated from your database, never from the browser.
  2. Open checkout on the website or app using the order ID.
  3. Customer pays via UPI, card, or another method.
  4. Verify the signature on the server using your secret key to confirm the response is genuine.
  5. Handle the webhook: the gateway calls your server with the final status, even if the customer closes the browser.
  6. Fulfil the order only once payment is confirmed, and make this step idempotent so duplicate webhooks do not create duplicate orders.

Security essentials

  • Keep secret keys on the server only, in environment configuration.
  • Verify webhook signatures.
  • Never store card details; the gateway handles card data so you stay out of PCI scope.
  • Use HTTPS everywhere.
  • Log payment events for reconciliation and support.

Handling the hard cases

ScenarioWhat to do
Payment succeeded but browser closedWebhook confirms and fulfils the order
Payment pending (common with UPI)Show pending status, wait for webhook, then update
Duplicate webhookIdempotent handling by payment ID
Amount mismatchReject and alert; never trust client amounts
Refund requestedInitiate via API, track refund status, notify customer

UPI considerations

UPI is the most popular payment method in India. On mobile, UPI intent flows open the customer's UPI app directly; on desktop, QR codes and collect requests are common. Design clear pending states, since UPI confirmations are not always instant.

Mobile apps

Use the gateway's official React Native or native SDK, but keep the same server-side order creation and verification. For digital goods sold inside iOS apps, Apple's in-app purchase rules may apply; physical goods and services generally use regular gateways.

Testing checklist

  • Successful payments for each method.
  • Failed and cancelled payments.
  • Pending UPI payments resolving later.
  • Full and partial refunds.
  • Webhook retries and duplicates.
  • Switching from test keys to live keys safely.

Accounting and GST

Generate GST-compliant invoices, record gateway fees, and reconcile settlements with orders. Integrating payments with accounting saves hours each month.

Need payments that just work? See API integration and e-commerce solutions, or describe your checkout. Related: Shopify vs custom e-commerce.

Topics
payment gateway integration IndiaUPI payment integrationRazorpay integrationpayment webhooksonline payments
Start a conversation
Follow AD App, E-Commerce & CRM Developer

Connect with AD App, E-Commerce & CRM Developer for websites, mobile apps, CRM systems, automation, and software engineering work.

Continue reading

Related insights

View all