UPI API for Developers: The Ultimate Guide to UPI Integration
Learn how to integrate a robust UPI API to generate payment links, dynamic QR codes, and handle real-time webhook verifications for your Indian merchant business.
{/* Header */}
Back to blog
Developer Guide Sep 26, 2026 · 6 min read
UPI API for Developers: The Ultimate Guide to UPI Integration
Integrating a UPI API shouldn't require reading 50 pages of legacy bank documentation. Here is everything you need to know about modern UPI integration, dynamic QR codes, and server-to-server callbacks.
{/* Content Body */}
The Unified Payments Interface (UPI) has completely transformed digital commerce in India. But for developers, integrating UPI directly via banking partners can be a bureaucratic and technical nightmare involving XML payloads, outdated SOAP APIs, and VPN tunneling.
A modern UPI API acts as a secure abstraction layer. It provides clean RESTful endpoints returning JSON, simple webhook integrations, and cryptographically secure HMAC signatures, entirely masking the complexity of the underlying banking network.
What can you build with a UPI API?
- Dynamic QR Generation: Create unique, amount-locked QR codes for every shopping cart or invoice, preventing under-payments.
- Direct Intent Links: Generate
upi://payURIs that instantly open GPay, PhonePe, or Paytm on mobile devices, boosting checkout conversion rates by 20%. - Automated Reconciliation: Receive instant server-side webhooks the second a payment settles, automatically fulfilling orders without human intervention.
How to integrate a UPI API (Code Example)
Using the UPI Gateways API, generating a payment session requires just a single HTTP POST request. You authenticate using standard HTTP Headers (X-API-Key).
Node.js (Fetch)
``{`const response = await fetch("https://api.upigateways.in/v1/orders", { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": "ug_live_your_api_key_here", "X-API-Secret": "sk_live_your_api_secret_here" }, body: JSON.stringify({ amount: "1500.00", customer_name: "Developer Name", customer_mobile: "9876543210" }) }); const data = await response.json(); console.log(data.pay_url); // https://pay.upigateways.in/UG_XYZ`}``
Handling Webhooks securely
When relying on a webhook to mark an order as "Paid" in your database, security is paramount. A robust UPI API will sign every webhook payload using your private secret. You must verify this signature to prevent spoofing attacks.
We use industry-standard HMAC-SHA256. Here is an example of verifying the webhook in an Express.js backend:
Express.js Webhook Handler
``{`const crypto = require('crypto'); app.post('/webhook/upi', express.raw({ type: 'application/json' }), (req, res) => { const signature = req.headers['x-webhook-signature']; const payload = req.body.toString(); // Generate HMAC hash using your secret const expectedHash = crypto .createHmac('sha256', process.env.WEBHOOK_SECRET) .update(payload) .digest('hex'); if (signature === expectedHash) { const data = JSON.parse(payload); if (data.status === 'success') { // Mark order as paid in DB fulfillOrder(data.order_id); } res.status(200).send('OK'); } else { res.status(401).send('Invalid signature'); } });`}``
Why choose UPI Gateways?
While generic payment aggregators bundle UPI alongside credit cards and net banking, we are 100% focused on UPI infrastructure. This means:
- Zero Nodal Account delays: Transactions settle instantly to your connected VPA.
- Smart Routing: Distribute payment load across multiple VPAs to avoid bank limits.
- Pure REST API: Clear JSON responses, sandbox environments, and beautiful developer docs.
See also
- UPI API Integration Guide: Step-by-Step for Developers
- Complete UPI API Reference
Get API Keys Read API Reference