UPI has become the default way Indians pay online. Customers expect to see it at checkout, whether they’re buying groceries, booking tickets, paying school fees or subscribing to software.
For developers, adding UPI is usually straightforward, as long as you understand the flows, the role of payment gateways, and a few rules that trip up many first implementations. This guide explains the practical side.
Your two main options
Option 1: Use a payment gateway (recommended for most businesses)
Payment gateways and aggregators authorised by the RBI provide APIs, SDKs and hosted checkout pages that support UPI along with cards, netbanking and wallets.
Advantages:
- quick integration with documentation and SDKs
- multiple payment methods in one integration
- dashboards, settlements, refunds and reports
- handling of many compliance and security requirements
Trade-off: you pay a transaction fee or a pricing plan agreed with the gateway (note that pricing for UPI varies by merchant category and gateway policies, so check current terms).
Option 2: Direct bank / PSP integration
Larger businesses sometimes integrate directly with a bank acting as a UPI payment service provider. This needs bank partnerships, more compliance work and more engineering effort. It makes sense only at high volume or for specialised needs.
The rest of this guide assumes a payment gateway.
Understanding UPI payment flows
1. UPI Intent (mobile)
On a mobile device, your app or mobile website opens a list of installed UPI apps (or a specific one). The customer completes payment in their UPI app and returns to your app.
Best for: mobile apps and mobile web checkout. It’s usually the smoothest experience.
2. UPI QR code
You display a dynamic QR code containing the payment amount and order details. The customer scans it with any UPI app.
Best for: desktop websites, kiosks, invoices and in-store payments.
3. Collect request (merchant-initiated)
The customer enters their UPI ID on your checkout page, and a payment request appears in their UPI app for approval.
Important change: NPCI discontinued person-to-person (P2P) collect requests from 1 October 2025 to reduce fraud. Merchant collect requests continue to be allowed for legitimate business transactions, but many checkouts now prefer intent and QR flows, which keep the customer in control. Follow your gateway’s current guidance on which flows they support.
4. UPI AutoPay (recurring payments)
For subscriptions, SIPs and recurring bills, UPI AutoPay lets customers set up a mandate, approving recurring debits within limits. Use it for SaaS subscriptions, memberships and EMI-style payments.
How a typical gateway integration works
Most gateways follow a similar pattern:
Step 1: Create an order on your server
Your back end calls the gateway’s API to create an order with the amount, currency (INR) and your internal order reference. The gateway returns an order ID.
Never trust the amount from the browser. Calculate the price on your server.
Step 2: Start checkout on the client
Your website or app opens the gateway’s checkout (hosted page, embedded widget or SDK), passing the order ID. The customer chooses UPI and pays using intent, QR or UPI ID.
Step 3: Receive the result
After payment, the gateway returns a response to the client, usually with a payment ID and a signature.
Step 4: Verify on the server
Your server must verify the payment before marking the order as paid:
- verify the signature using your secret key, as described in the gateway docs
- or fetch the payment status from the gateway API using the payment ID
- check that the amount and order ID match what you expect
Step 5: Handle webhooks
Gateways send webhooks (server-to-server notifications) for events like payment captured, failed or refunded.
Webhooks are essential because:
- the customer may close the browser before returning to your site
- UPI payments can sometimes be pending before success or failure
- network issues can interrupt client-side callbacks
Your webhook handler should:
- verify the webhook signature
- be idempotent (processing the same event twice shouldn’t create duplicate orders)
- update the order status in your database
- respond quickly with HTTP 200, and queue slower work
Handling payment states
UPI payments can be:
| Status | What to do |
|---|---|
| Success / captured | Fulfil the order |
| Failed | Allow retry; don’t fulfil |
| Pending | Show a “payment processing” message; wait for webhook or poll status |
| Refunded | Update order and notify customer |
Don’t mark orders as failed too quickly. Some UPI payments take a little time to confirm.
Refunds
Use the gateway’s refund API for full or partial refunds. Store refund IDs, show refund status to customers, and handle refund webhooks.
Testing
- Use the gateway’s test/sandbox mode and test credentials.
- Test success, failure, pending and timeout scenarios.
- Test on real devices with multiple UPI apps for intent flows.
- Test what happens when the user closes the app mid-payment.
- Switch to live keys only after a full checklist review.
Security best practices
- Keep secret keys on the server. Never put them in mobile apps or front-end code.
- Verify every payment server-side using signatures or status APIs.
- Validate webhook signatures.
- Use HTTPS everywhere.
- Don’t store sensitive payment data you don’t need. Let the gateway handle it.
- Log transactions with order IDs, payment IDs and statuses for reconciliation.
- Rate-limit order creation endpoints to prevent abuse.
- Reconcile daily against gateway settlement reports.
Business and compliance checklist
- ☐ Complete the gateway’s KYC and business verification
- ☐ Display clear refund and cancellation policies, terms and contact details
- ☐ Issue GST-compliant invoices where applicable
- ☐ Understand settlement timelines and fees
- ☐ Follow data protection obligations for customer information, including the DPDP Act requirements applying from 2027
UX tips that improve success rates
- Show UPI prominently at checkout for Indian customers.
- On mobile, use intent to open UPI apps directly.
- On desktop, show a QR code with a timer.
- Show clear “waiting for payment” status and handle returns gracefully.
- Offer a retry button and alternative payment methods.
- Send confirmation by email, SMS or WhatsApp after payment.
Last word
Integrating UPI is less about the payment button and more about reliable order handling: server-side order creation, signature verification, webhooks, pending states, refunds and reconciliation.
Use a reputable gateway, follow their current documentation closely, test every failure path, and your customers will get the fast, familiar checkout experience they expect.
This article provides general technical guidance. Payment rules, gateway features and NPCI guidelines change over time; always refer to your gateway’s and NPCI’s latest documentation.
Leave a Comment