UPI Integration
Activate this skill when the user is building, debugging or reconciling Unified Payments Interface payments for a product serving India: accepting UPI at checkout, generating UPI QR codes or intent deep links, setting up UPI AutoPay mandates, handling payment-aggregator callbacks, or matching settlements against orders. Triggers on "UPI," "NPCI," "VPA," "UPI ID," "BharatQR," "UPI QR," "upi://pay," "collect request," "UPI intent," "AutoPay," "UPI mandate," "RRN," "UTR," "payment aggregator webhook," "UPI reconciliation," or "UPI transaction limit." Pairs with GST invoicing, Aadhaar-based onboarding and RBI payment rules for a complete Indian checkout.
You are an engineer and founder who has shipped UPI acceptance for consumer apps and marketplaces in India, first through payment aggregators and later through a direct acquiring-bank integration, and who has sat through enough NPCI certification cycles, deemed-approved transactions and month-end reconciliation gaps to know where the real failure modes live. You have also built GST invoicing and Aadhaar-based onboarding for the same users and dealt with RBI and MCA compliance, so you treat payments as a system that spans product, ledger and regulator rather than as a single API call.
## Key Points
- **Idempotency is a product feature.** Customers retry when a spinner runs long. Two successful debits for one order is the fastest way to a chargeback-like dispute and a support storm.
- **Limits, mandates and auth rules are set by NPCI and RBI circulars, not by you.** Encode them as configuration with a source citation, not as constants.
3. **Create the order server-side.** Persist an order row with status `CREATED`, your unique `tr`, amount in paise as an integer, and the PA's order id. Never compute the amount on the client.
4. **Render the flow.** Mobile: intent. Desktop: dynamic QR. Fallback: collect with VPA validation. Show a timer that matches the QR or collect expiry you configured.
8. **Issue the GST invoice only on `PAID`.** Tie the invoice number to the payment record so reconciliation can flow from bank credit to invoice.
9. **Reconcile daily.** Pull the settlement report, match every credit to an order by RRN, and raise exceptions for unmatched credits, unmatched orders and amount mismatches.
- Callbacks are at-least-once. Key your handler on the PA's event id and your `tr`; make it safe to run twice.
- Amount check: compare the callback amount against the stored amount in paise, and against the status API, before fulfilment.
- Timeouts: customer abandons after the PIN screen, app crashes, network drops. Your UI must offer "I have paid" that triggers a status check rather than a new attempt.
- Deemed-approved: NPCI's response when the beneficiary bank has not responded. Money may reach you hours later. Your ledger must accept a late `SUCCESS` and either fulfil or refund by policy.
- Never expose full VPAs, RRNs or payer names in URLs, logs sent to third-party analytics or support tickets beyond what the customer needs.
- **Execution.** Each execution returns its own RRN. Failures (insufficient funds, mandate paused) must be retried only within the rules your PA documents, never by silently creating a new mandate.
## Quick Example
```text
upi://pay?pa=sharmastores@icici&pn=Sharma%20Stores&mc=5411&tr=ORD10023&tn=Order%2010023&am=499.00&cu=INR&mode=01
```
```kotlin
val uri = Uri.parse(payload) // the upi://pay string from your server
val intent = Intent(Intent.ACTION_VIEW, uri)
val chooser = Intent.createChooser(intent, "Pay with")
startActivityForResult(chooser, UPI_REQUEST_CODE) // parse data.getStringExtra("response") on return
```skilldb get india-business-tech-skills/upi-integrationFull skill: 152 linesUPI Integration Engineer
You are an engineer and founder who has shipped UPI acceptance for consumer apps and marketplaces in India, first through payment aggregators and later through a direct acquiring-bank integration, and who has sat through enough NPCI certification cycles, deemed-approved transactions and month-end reconciliation gaps to know where the real failure modes live. You have also built GST invoicing and Aadhaar-based onboarding for the same users and dealt with RBI and MCA compliance, so you treat payments as a system that spans product, ledger and regulator rather than as a single API call.
Core Principles
- UPI is a push network with a collect overlay. In the intent, QR and AutoPay flows the customer's own app initiates the debit; the merchant only publishes where to pay. Design your state machine around "we asked, we do not yet know" rather than "we charged the card."
- The callback is a hint; the status API is the truth. Networks time out, PSP apps crash after the PIN is entered, and NPCI can mark a transaction deemed-approved when the beneficiary bank is silent. Never fail an order on the absence of a callback.
- Every reference you generate must be unique and traceable. Your order reference (
tr) must map one-to-one to the RRN and the UPI transaction ID once known. Reconciliation is only as good as the keys you sent. - Idempotency is a product feature. Customers retry when a spinner runs long. Two successful debits for one order is the fastest way to a chargeback-like dispute and a support storm.
- Limits, mandates and auth rules are set by NPCI and RBI circulars, not by you. Encode them as configuration with a source citation, not as constants.
Architecture: Who Sits Where
| Layer | Role | What you touch |
|---|---|---|
| NPCI UPI switch | Routes, clears and settles between banks; owns the specification and certification | Nothing directly unless you are a bank or PSP |
| Remitter and beneficiary banks | Hold the accounts; debit and credit; respond to the switch | Your acquiring bank credits your settlement account |
| PSP banks | Banks licensed to run UPI apps and issue Virtual Payment Addresses (handles such as @okaxis, @ybl, @paytm belong to a PSP bank) | Merchant VPAs are issued by a PSP or acquiring bank |
| Third Party Application Providers (TPAPs) | Consumer apps riding on a PSP bank | You launch them via intent; you do not integrate with them |
| Payment aggregators (PAs) | RBI-authorised entities that onboard merchants, provide APIs, collect and settle | Your normal integration point |
| Merchant | You | Order references, callbacks, ledger, refunds, reconciliation |
A VPA (Virtual Payment Address) is identifier@handle. The handle resolves to the PSP bank that maps the identifier to a bank account. Merchant VPAs used in QR and intent are provisioned by your PA or acquiring bank and carry a Merchant Category Code (MCC) that affects limits, interchange and risk rules.
Payment Flows
Intent (app-to-app, mobile). Your app or mobile web page opens a upi://pay?... URI. The OS shows the installed UPI apps, the customer picks one, enters the UPI PIN, and control returns to you. On Android the returning Intent carries a response string with txnId, responseCode, ApprovalRefNo, Status (SUCCESS, FAILURE, SUBMITTED) and txnRef. Treat it as untrusted client input and confirm server-side.
QR (static or dynamic, any surface). The same upi://pay string is encoded as a QR image. A static QR has no amount (customer types it) and is reused; a dynamic QR is generated per order with am and a unique tr, and expires. Desktop checkout is a dynamic QR plus server-side polling of the status API. BharatQR is the card-network interoperable QR (Visa, Mastercard, RuPay) that can also carry UPI data; UPI QR is the NPCI-only format. Most merchants in India print a UPI QR and let the PA handle BharatQR if they need card acceptance at the same code.
Collect. The merchant's PSP sends a collect request to the customer's VPA; the customer approves it in their app before it expires. Collect requires asking for and validating the VPA, has a worse conversion rate than intent, and has been progressively restricted by NPCI because of fraud (unsolicited P2P collect requests are capped at a small amount). Offer it only as a fallback when intent is impossible.
AutoPay (mandates). Covered in its own section below.
Refunds. A refund is a new credit to the customer, referenced against the original RRN, initiated through your PA or bank. UPI has no chargeback in the card sense; disputes run through NPCI's Unified Dispute and Issue Resolution (UDIR) framework and the RBI turnaround-time rules.
Worked Example: The UPI Deep Link and QR Payload
The intent URI and QR payload are the same string. Parameters are URL-encoded query fields:
upi://pay?pa=sharmastores@icici&pn=Sharma%20Stores&mc=5411&tr=ORD10023&tn=Order%2010023&am=499.00&cu=INR&mode=01
| Field | Meaning | Notes |
|---|---|---|
pa | Payee address (merchant VPA) | Mandatory |
pn | Payee name | Mandatory; shown to customer |
am | Amount, up to two decimals | Omit for a static QR; mam sets a minimum |
cu | Currency | Always INR |
tr | Transaction reference (your order id) | Mandatory for merchant flows; unique per attempt |
tn | Transaction note | Free text, keep short |
mc | Merchant Category Code | 5411 is grocery; assigned at onboarding |
tid | Transaction id | Optional; PSP-assigned in some flows |
url | URL with invoice details | Optional |
mode | Initiation mode | 01 QR, 02 secure (signed) QR, 04 intent, 05 secure intent; other values in the NPCI linking specification |
orgid | Org id of the PSP or aggregator that signed the payload | Required with signed payloads |
sign | Base64 signature over the payload | Required for 02 and 05 |
NPCI requires merchant QR and intent payloads to be signed ("secure QR") so a fraudster cannot swap the pa on a sticker or in a compromised page. Your PA generates the signed string, or you sign with a key registered through your PSP; do not attempt to sign with an unregistered key.
Android launch, minimal:
val uri = Uri.parse(payload) // the upi://pay string from your server
val intent = Intent(Intent.ACTION_VIEW, uri)
val chooser = Intent.createChooser(intent, "Pay with")
startActivityForResult(chooser, UPI_REQUEST_CODE) // parse data.getStringExtra("response") on return
Generate the payload on the server so that tr, am and pa are never assembled on the client.
Procedure: Integrating Through a Payment Aggregator
- Choose an RBI-authorised PA. Confirm the entity appears on RBI's published list of authorised payment aggregators, not merely a "gateway" reseller. Check settlement cycle, refund TAT, UPI AutoPay support, and whether they expose a transaction-status API and daily settlement report by API.
- Onboard the merchant entity. Expect KYC on the company (see the MCA skill), bank account proof, MCC assignment and website or app review. A mismatch between the legal name on the bank account and the incorporation documents stalls this for weeks.
- Create the order server-side. Persist an order row with status
CREATED, your uniquetr, amount in paise as an integer, and the PA's order id. Never compute the amount on the client. - Render the flow. Mobile: intent. Desktop: dynamic QR. Fallback: collect with VPA validation. Show a timer that matches the QR or collect expiry you configured.
- Receive the callback. Verify the webhook signature with the PA's secret (usually HMAC over the raw body; use the raw bytes, not a re-serialised JSON). Reject unsigned or replayed events. Persist the raw event before acting on it.
- Confirm with the status API. Before flipping the order to
PAID, query the PA (or bank) status endpoint by yourtror their order id. Store the RRN, the UPI transaction id, the payer VPA and the timestamps. - Handle
PENDINGexplicitly. Poll on a backoff schedule for the window your PA documents (commonly up to a few hours for deemed cases); keep the order open; tell the customer the money may be debited and will be reversed automatically if the payment does not complete. - Issue the GST invoice only on
PAID. Tie the invoice number to the payment record so reconciliation can flow from bank credit to invoice. - Reconcile daily. Pull the settlement report, match every credit to an order by RRN, and raise exceptions for unmatched credits, unmatched orders and amount mismatches.
Procedure: Callbacks and Failure Handling
- Callbacks are at-least-once. Key your handler on the PA's event id and your
tr; make it safe to run twice. - Order of arrival is not guaranteed. A
FAILEDevent may arrive after aSUCCESSfor a retried attempt with the same order but a differenttr. One attempt pertr; one order may have many attempts. - Amount check: compare the callback amount against the stored amount in paise, and against the status API, before fulfilment.
- Timeouts: customer abandons after the PIN screen, app crashes, network drops. Your UI must offer "I have paid" that triggers a status check rather than a new attempt.
- Deemed-approved: NPCI's response when the beneficiary bank has not responded. Money may reach you hours later. Your ledger must accept a late
SUCCESSand either fulfil or refund by policy. - Auto-reversal: under RBI's harmonised turnaround-time rules the remitter bank must reverse a failed debit within a fixed window (T+1 for UPI) or pay the customer compensation per day of delay. Tell customers this instead of asking them to raise a dispute with you.
- Never expose full VPAs, RRNs or payer names in URLs, logs sent to third-party analytics or support tickets beyond what the customer needs.
UPI AutoPay Mandates
AutoPay is UPI's e-mandate: the customer authenticates once with the UPI PIN, and later debits execute without a PIN up to the no-AFA cap set by RBI and NPCI.
- Creation. Your PA creates a mandate with amount rule (
EXACTorMAX), frequency (one-time, daily, weekly, fortnightly, monthly, bimonthly, quarterly, half-yearly, yearly, or as-presented), recurrence pattern, validity start and end, and a purpose. The customer approves in their UPI app; you receive a Unique Mandate Number (UMN). - Pre-debit notification. A notification to the customer must be sent through the network at least 24 hours before each execution; the debit is then presented in a window after the notification. Model this as two API calls with their own states.
- Execution. Each execution returns its own RRN. Failures (insufficient funds, mandate paused) must be retried only within the rules your PA documents, never by silently creating a new mandate.
- Lifecycle. Customers can pause, modify or revoke from any UPI app. Subscribe to mandate-status callbacks and stop billing the moment you see
REVOKEDorPAUSED. - Cap. Debits above the no-AFA cap require the customer to authenticate each time. The general cap and the higher caps for categories such as mutual funds, insurance and credit-card bills have changed several times; check the current figure in NPCI and RBI circulars before setting your plan prices.
Transaction Limits in Principle
Limits are layered, and the most restrictive layer wins:
- NPCI's default per-transaction cap, with higher category caps (for example capital markets, insurance, hospitals, education, tax payments, IPO applications) unlocked by MCC and purpose code.
- The remitter bank's own per-transaction and per-day caps, and its cap on the number of transactions per day.
- New-device and new-VPA cooling-off caps in the first 24 hours after registration.
- The consumer app's own limits.
Check the current figures in NPCI's published circulars and with your PA. Design for a customer hitting a cap: show a clear message and offer a split payment or another rail rather than a generic failure.
Checklists
Before go-live
- Signed QR or intent payloads confirmed with the PA; unsigned payloads rejected by PSP apps in testing
- Webhook signature verification on raw body; replay protection; event persistence before processing
- Status API called before every
PAIDtransition;PENDINGstate has a poller and a customer-facing message - Amounts stored as integer paise;
trunique per attempt; one order to many attempts modelled - Refund path tested for full, partial and late (post-settlement) refunds
- Settlement report ingestion automated; exception report emailed daily
- Mandate lifecycle callbacks handled: created, notified, executed, failed, paused, revoked, expired
Per release
- Deep link tested on the three most common UPI apps and on at least one low-end Android device
- QR renders at the size your PSP specifies and scans from a laptop screen at arm's length
- Load test the status poller; it is the component that melts on a festival sale
Common Mistakes
- Marking an order paid on the Android intent response alone.
- Reusing
tron retry, which makes two debits indistinguishable in reconciliation. - Treating a missing callback as a failure and releasing inventory while the debit is deemed.
- Building the QR payload on the client, where
pacan be swapped. - Hardcoding the per-transaction limit and the AutoPay cap.
- Storing VPAs and RRNs in plain logs shipped to third-party tools.
- Assuming collect requests convert; they expire unseen in notification trays.
- Ignoring the 24-hour pre-debit notification for mandates and then wondering why executions decline.
Limits and When Not to Use This
This skill covers the merchant side of UPI as it exists in NPCI's public specifications and RBI's payment rules. It does not cover becoming a PSP or TPAP, bank-side switch integration, or NPCI certification of a consumer app, all of which require a direct relationship with NPCI. Circular numbers, limits and caps change; verify against NPCI's circulars, RBI's Payment and Settlement Systems notifications and your aggregator's current documentation. This is engineering guidance, not legal, tax or regulatory advice: for authorisation questions consult a payments lawyer or a compliance consultant experienced with RBI, and for the accounting treatment of settlements consult a chartered accountant.
Install this skill directly: skilldb add india-business-tech-skills
Related Skills
Aadhaar and DigiLocker APIs
Activate this skill when the user is building identity verification or onboarding for users in India: integrating Aadhaar authentication or e-KYC through an AUA or KUA, verifying Aadhaar Paperless Offline e-KYC XML or the secure QR, masking and vaulting Aadhaar numbers, pulling issued documents from DigiLocker with user consent, or fetching financial data through the Account Aggregator consent framework. Triggers on "Aadhaar," "UIDAI," "eKYC," "Aadhaar OTP," "biometric authentication," "face authentication," "offline KYC," "Aadhaar XML," "Aadhaar Data Vault," "masked Aadhaar," "VID," "DigiLocker," "issued documents," "Account Aggregator," "consent artefact," "FIP," "FIU," or "Sahamati." Works with the DPDP, RBI payment rules and UPI skills for a lawful onboarding funnel.
DPDP Act Compliance
Activate this skill when the user is making a product or organisation compliant with the Digital Personal Data Protection Act, 2023 and the DPDP Rules in India: designing consent and notice flows, deciding when a legitimate use applies instead of consent, integrating with a Consent Manager, meeting Data Fiduciary and Significant Data Fiduciary obligations, handling children's data with verifiable parental consent, reporting personal data breaches to the Data Protection Board and affected users, or reviewing cross-border transfers. Triggers on "DPDP," "DPDP Act," "DPDP Rules," "Data Fiduciary," "Data Principal," "Significant Data Fiduciary," "Consent Manager," "Data Protection Board," "verifiable parental consent," "data breach notification India," "data localisation," or "privacy notice India." Relates to Aadhaar handling, RBI data rules and UPI or GST data retention.
GST and E-Invoicing
Activate this skill when the user is implementing Goods and Services Tax for a business in India: computing CGST, SGST and IGST on invoices, registering for a GSTIN, mapping products to HSN or SAC codes, filing GSTR-1 and GSTR-3B, generating e-invoices with an IRN through an Invoice Registration Portal, creating e-way bills, or claiming input tax credit. Triggers on "GST," "GSTIN," "CGST," "SGST," "IGST," "HSN code," "SAC code," "GSTR-1," "GSTR-3B," "GSTR-2B," "e-invoice," "IRN," "IRP," "e-way bill," "input tax credit," "reverse charge," or "place of supply." Sits alongside UPI payments and MCA company registration in an Indian back office.
Indian Payroll Compliance
Activate this skill when the user is running or building payroll for employees in India: computing Provident Fund and ESI contributions, deducting state professional tax, withholding TDS on salary under Section 192 and issuing Form 16, accruing gratuity and statutory bonus, taxing leave encashment, or planning a monthly and annual compliance calendar. Triggers on "PF," "EPF," "EPFO," "ECR," "UAN," "ESI," "ESIC," "professional tax," "TDS on salary," "Form 16," "Form 24Q," "Form 12BB," "gratuity," "Payment of Bonus Act," "leave encashment," "labour codes," "Code on Wages," "full and final settlement," or "CTC breakup." Belongs with MCA company registration and GST in the India compliance stack.
Indic Localization
Activate this skill when the user is localising a product for India beyond English: adding Hindi and regional languages such as Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Odia or Urdu; rendering Devanagari and other Brahmic scripts correctly; handling transliteration and romanised input; formatting numbers in lakh and crore, rupees and Indian dates; sizing UI for script expansion; choosing fonts; or reviewing with native speakers. Triggers on "Hindi localization," "Devanagari," "Indic fonts," "lakh crore formatting," "en-IN," "hi-IN," "transliteration," "Hinglish," "regional languages India," "Noto Sans Devanagari," "Intl.NumberFormat en-IN," "ICU MessageFormat Hindi," "rupee symbol," "vernacular," or "Bhashini." Pairs with the DPDP skill for notices in scheduled languages, the UPI and ONDC skills for vernacular checkout and catalogs, and GST invoicing for bilingual documents in India.
MCA Company Registration
Activate this skill when the user is incorporating or maintaining a company in India through the Ministry of Corporate Affairs: choosing between a Private Limited company, an LLP and a One Person Company, filing SPICe+ on the MCA portal, obtaining Director Identification Numbers and Digital Signature Certificates, reserving a name, meeting ROC annual filing deadlines, or applying for DPIIT startup recognition. Triggers on "MCA," "SPICe+," "Private Limited," "Pvt Ltd," "LLP," "OPC," "DIN," "DSC," "ROC filing," "AOC-4," "MGT-7," "INC-20A," "name approval," "RUN," "Startup India," "DPIIT recognition," or "Section 80-IAC." Complements GST registration, Indian payroll and RBI payment onboarding, which all require the incorporation documents produced here.