Integrating UPI and a payment gateway in India means connecting your app to a provider like Razorpay, PayU, Cashfree, or PhonePe that handles UPI, cards, net banking, and wallets through a single API. For most businesses, integration takes 1–3 weeks, costs little to set up (gateways charge per transaction, typically 1.8–2.5%, with UPI often cheaper or free), and requires PCI-DSS-compliant handling of payment data. This developer's guide covers how UPI works, how to choose a gateway, the integration steps, and the compliance you must not skip.
How UPI and Payment Gateways Work Together
UPI (Unified Payments Interface) is India's real-time bank-to-bank payment rail, powering apps like Google Pay, PhonePe, and Paytm. A payment gateway is the software layer that lets your app accept UPI along with cards, net banking, and wallets without you integrating each bank individually. When a customer pays, the gateway securely routes the transaction to the bank or UPI network, confirms it, and notifies your server.
- UPI handles the actual money movement between bank accounts instantly.
- The gateway abstracts UPI, cards, and wallets behind one integration and one dashboard.
- Your app calls the gateway's API to create orders and verify payments.
Choosing the Right Payment Gateway in India
The leading gateways all support UPI; pick based on fees, features, and developer experience:
- Razorpay — excellent developer experience, wide feature set (subscriptions, payment links, payouts), popular with startups.
- PayU — strong enterprise features and high success rates.
- Cashfree — competitive pricing, strong payouts and UPI features.
- PhonePe / Paytm — good if your audience heavily uses those wallets.
Compare transaction fees, settlement time (T+1 vs T+2), supported methods, and API quality before committing.
Step-by-Step Integration
A typical server-side gateway integration follows this flow:
- Create a merchant account and complete KYC with the gateway.
- Get API keys — a test (sandbox) key pair and a live key pair.
- Create an order on your server — call the gateway's Orders API with the amount and currency; never trust amounts sent from the client.
- Open checkout on the client — the gateway's SDK/widget collects the payment (UPI, card, etc.).
- Verify the payment signature on your server — the gateway returns a signature you must verify with your secret key to confirm authenticity.
- Handle webhooks — listen for server-to-server webhook events (payment captured, failed, refunded) as the source of truth, since users can close the app mid-payment.
Why Server-Side Verification Is Non-Negotiable
Never mark an order as paid based only on a client-side success callback — it can be spoofed. Always verify the payment signature on your backend and reconcile with webhooks. This single practice prevents the most common payment fraud in poorly built integrations.
Compliance and Security You Must Not Skip
Handling payments in India carries clear obligations:
- PCI-DSS — never store raw card numbers; let the gateway tokenize and handle card data.
- RBI tokenization — card details are tokenized per RBI mandate; rely on the gateway's tokenization.
- HTTPS everywhere — all payment traffic must be encrypted.
- GST-compliant invoicing — generate proper tax invoices for each transaction.
- Secure secrets — keep API secret keys on the server only, never in mobile or frontend code.
Handling Refunds, Subscriptions, and Failures
A production integration needs more than a single payment:
- Refunds — implement full and partial refunds via the gateway's refund API.
- Subscriptions — use the gateway's recurring/mandate features for UPI AutoPay or card subscriptions.
- Failed payments — show clear retry flows and reconcile pending transactions via webhooks.
Frequently Asked Questions
How do I integrate UPI payments in my app?
Integrate a payment gateway like Razorpay, PayU, or Cashfree that supports UPI. Create orders on your server, open the gateway's checkout on the client, verify the payment signature on your backend, and rely on webhooks as the source of truth. This gives you UPI, cards, and wallets through one API.
How much does payment gateway integration cost in India?
Setup is usually free or low-cost; gateways charge per transaction, typically 1.8–2.5%, with UPI often cheaper or free. Development time for a solid integration is usually 1–3 weeks depending on features like subscriptions and refunds.
Is it safe to confirm payments from the client side?
No. Client-side success callbacks can be spoofed. Always verify the payment signature on your server using your secret key and reconcile with server-to-server webhooks before marking an order as paid.
Which payment gateway is best for startups in India?
Razorpay is a popular choice for startups thanks to its excellent developer experience and broad features, but PayU and Cashfree are strong alternatives. Compare transaction fees, settlement times, and supported methods for your specific use case.
Need a secure, GST-compliant payment integration for your app or website? SV Soft Solutions builds robust payment flows with UPI, cards, subscriptions, and webhooks done right. Explore our custom software services or book a free consultation today.