The UPI QR Generation API initiates a payment transaction and generates a QR code for UPI payments. The QR format (base64 or URL) is determined by the sendqrimage merchant parameter.
Earlier, you received only the intent URL and had to convert it to QR using their own libraries. With this feature, PayU can now send the QR code directly as:
- Base64-encoded image for immediate display
- Image URL for hosted QR rendering
This API supports both online (Intent-based) and offline (DBQR) QR modes for seamless S2S integrations (txn_s2s_flow = 4).
Note:Contact your PayU Key Account manager to enable the sendqrimage parameter to use the QR generation feature.
Environment
| Environment | URL | Methor |
|---|---|---|
| Production | https://secure.payu.in/_payment | POST |
| Sandbox | https://test.payu.in/_payment | POST |
Authentication
Include your merchant key and authorization token in the request headers.
Request Headers
| Header | Description |
|---|---|
Content-Typemandatory | application/x-www-form-urlencoded; charset=UTF-8 |
Acceptmandatory | application/json |
Authorizationoptional | Bearer token or API key as per your integration type |
Request Parameters
| Parameter | Type & Description | Example |
|---|---|---|
keymandatory | String Your merchant key provided by PayU during onboarding. | JP***g |
txnidmandatory | String Unique transaction ID for this payment request. | T123456789 |
amountmandatory | Decimal Payment amount in INR. | 100.00 |
productinfomandatory | String Description of the product or service being purchased. | Mobile Recharge |
firstnamemandatory | String First name of the customer. | Ashish |
emailmandatory | String Email address of the customer. | [email protected] |
phonemandatory | String Phone number of the customer. | 9876543210 |
surlmandatory | String Success return URL where customers are redirected after successful payment. | https://yoursite.com/success |
furlmandatory | String Failure return URL where customers are redirected after failed payment. | https://yoursite.com/failure |
pgmandatory | String Payment mode. For online QR use UPI; for offline QR use DBQR (SDK) or QR (mobile web). | UPI |
bankcodemandatory | String Payment gateway code. Use INTENT for online QR, UPIDBQR for offline QR (SDK), or UPIQR for offline QR (mobile web). | INTENT |
upiAppNamemandatory | String Must be set to MQR for mobile/SDK QR transactions. This value is stored in field8 for tracking purposes. | MQR |
txn_s2s_flowmandatory | Integer S2S flow identifier. Must be 4 for SDK-based QR flows. Not required for mobile web. | 4 |
hashmandatory | String SHA-512 hash for request validation. Formula: sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||salt). See hash generation guide. | 5C4F... |
isMobileUPIQRoptional | Integer QR mode preference. 1 = Offline DBQR primary; 2 = Online Intent primary; 0 = Disable QR. If passed in the request, this takes precedence over the merchant_param configuration. | 2 |
sendqrimageoptional | String Determines the QR image format in the response. base64 returns a base64-encoded image; url returns an image URL; if not set, only the intent string is returned (existing behavior). | base64 |
expiryTimeoptional | Integer QR code expiry duration in seconds. If not provided, defaults to 300 seconds (5 minutes). | 600 |
sendqrimage Parameter Options
The sendqrimage parameter controls how the QR code is returned:
| Value | Behavior |
|---|---|
| Not set (default) | Returns only the intentURIData or qrString. No QR image is generated. Merchant must generate QR code on their end. |
| base64 | PayU generates the QR image, converts it to base64, and includes it in the response under qrImage.base64.value. The temporary image file is deleted after encoding. |
| url | PayU generates the QR image, uploads it to S3 with a 5-minute expiry, and returns the image URL under qrImage.url.value. The URL format is https://secure.payu.in/<token>/ShowQrImage. The temporary local image file is deleted after upload. |
Sample Request
Request with base64 QR (S2S Flow)
curl --location 'https://secure.payu.in/_payment' \
--header 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--header 'Accept: application/json' \
--data-urlencode 'key=JP***g' \
--data-urlencode 'txnid=T123456789' \
--data-urlencode 'amount=100.00' \
--data-urlencode 'productinfo=Mobile Recharge' \
--data-urlencode 'firstname=Ashish' \
--data-urlencode '[email protected]' \
--data-urlencode 'phone=9876543210' \
--data-urlencode 'surl=https://yoursite.com/success' \
--data-urlencode 'furl=https://yoursite.com/failure' \
--data-urlencode 'mode=UPI' \
--data-urlencode 'ibibo-code=INTENT' \
--data-urlencode 'upiAppName=MQR' \
--data-urlencode 'txn_s2s_flow=4' \
--data-urlencode 'isMobileUPIQR=2' \
--data-urlencode 'sendqrimage=base64' \
--data-urlencode 'hash=5C4F3E2D1A0B9C8D7E6F5A4B3C2D1E0F...'Note: Replace all placeholder values (key, hash, URLs, etc.) before making the request.
Sample Response
base64 QR
{
"metaData": {
"message": null,
"referenceId": "29483752703",
"statusCode": null,
"txnId": "fM8KPzqvyWZ1KUeAf5OC",
"txnStatus": "pending",
"unmappedStatus": "pending"
},
"result": {
"paymentId": "294837527031",
"merchantName": "ARTHVIT 1809 TECH PRIVATE LIMITED",
"merchantVpa": "goodscore.payu@axisbank",
"amount": "1360.00",
"intentURIData": "pa=goodscore.payu@axisbank&pn=ARTHVIT 1809 TECH PRIVATE LIMITED&tr=29483752703&tid=PPPL294837527031007260922316a506c7f&am=1360.00&cu=INR&tn=UPIIntent",
"qrImage": {
"base64": {
"value": "iVBORw0KGgoAAAANSUhEUgAAAR0AAAEdAQMAAAALpCE4AAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADU0lEQVRoge1ZQa6rMBC1..."
}
},
"otpPostUrl": "https://secure.payu.in/ResponseHandler.php"
}
}URL QR
{
"metaData": {
"message": null,
"referenceId": "29483752703",
"statusCode": null,
"txnId": "fM8KPzqvyWZ1KUeAf5OC",
"txnStatus": "pending",
"unmappedStatus": "pending"
},
"result": {
"paymentId": "294837527031",
"merchantName": "ARTHVIT 1809 TECH PRIVATE LIMITED",
"merchantVpa": "goodscore.payu@axisbank",
"amount": "1360.00",
"intentURIData": "pa=goodscore.payu@axisbank&pn=ARTHVIT 1809 TECH PRIVATE LIMITED&tr=29483752703&tid=PPPL294837527031007260922316a506c7f&am=1360.00&cu=INR&tn=UPIIntent",
"qrImage": {
"url": {
"value": "https://secure.payu.in/7b17b5d3babc2e2998c61e3d63e1f81b/ShowQrImage"
}
},
"otpPostUrl": "https://secure.payu.in/ResponseHandler.php"
}
}Error Codes
| Error Code | Description | Recommended Action |
|---|---|---|
| 400 | Bad Request Invalid or missing required parameters. Check the request payload for missing or incorrectly formatted fields. | Verify all mandatory parameters are present and correctly formatted. Ensure sendqrimage value is either base64 or url if set. |
| 403 | Forbidden The sendqrimage parameter is not enabled for your merchant account, or the requested QR mode (online/offline) is not enabled for your merchant. | Contact your PayU account manager to enable sendqrimage in your merchant_param configuration and verify that DBQR or UPI Intent is enabled based on your isMobileUPIQR value. |
| 500 | Internal Server Error QR generation failed due to a server-side issue. This could be due to S3 upload failure, image generation failure, or payment gateway error. | Retry the request after a brief delay. If the issue persists, display error message: "QR unavailable. Retry or choose another payment method." Log the error and contact PayU support if it continues. |
