The _payment API can be used to generate an UPI QR which can be used for offline payment collections. The omniChannelDetails JSON object is included in the request for posting the Omnichannel details.
Environment
| Test Environment | https://apitest.payu.in/v2/payments |
| Production Environment | https://api.payu.in/v2/payments> |
Request header
| Parameter | Description |
|---|---|
| date | The current date and time. For example, format of the date is Wed, 28 Jun 2023 11:25:19 GMT. |
| authorization | The actual HMAC signature generated using the specified algorithm (sha512) and includes the hashed data. For more information, refer to authorization fields description. |
authorization fields description
| Field | Description |
|---|---|
| username | Represents the username or identifier for the client or merchant, for example smsplus. |
| algorithm | Use SHA512 algorithm for hashing and send this as header value. |
| headers | Specifies which headers have been used in generating the hash, for example date. |
| signature | The HMAC signature generated using the specified algorithm. For more information, refer to hashing algorithm. |
hashing algorithm
You must hash the request parameters using the following hash logic:
Hash logic: sha512(`<Body data>` + '|' + date + '|' + merchant_secret)
Where <Body data> contains the request body posted with the request.
Sample header code
var merchant_key = 'smsplus';
var merchant_secret = 'izF09TlpX4ZOwmf9MvXijwYsBPUmxYHD';
// date
var date = new Date();
date = date.toUTCString();
// authorization
var authorization = getAuthHeader(date);
function getAuthHeader(date) {
var AUTH_TYPE = 'sha512';
var data = isEmpty(request['data']) ? "" : request['data'];
var hash_string = data + '|' + date + '|' + merchant_secret;
var hash = CryptoJS.SHA512(hash_string).toString(CryptoJS.enc.Hex);
return `hmac username="${merchant_key}", algorithm="${AUTH_TYPE}", headers="date", signature="${hash}"`;
}Request body
| Parameter | Description | Example |
|---|---|---|
accountId |
|
MERCHANT123 |
txnId |
|
REF123456 |
paymentMethod |
|
{"name": "UPI", "bankCode": "UPI"} |
order |
|
|
additionalInfo |
|
|
callBackActions |
|
|
billingDetails |
|
paymentMethod object
| Parameter | Description | Example |
|---|---|---|
namemandatory |
Represents the payment method used. For UPI, use UPI | UPI |
bankCodemandatory |
Contains the bank code.For UPI, use UPI | UPI |
order object fields description
| Parameter | Description | Example |
|---|---|---|
productInfomandatory | Product details. Type: String | Product details |
orderedItemoptional | Details about the items ordered. Type: Array of Objects | |
userDefinedFieldsoptional | Custom fields for additional information. Type: Object. Fields: udf1, udf2, udf3, udf4, udf5, udf6, udf7, udf8, udf9, udf10. | |
paymentChargeSpecificationmandatory | Includes amount and charges. Type: Object. For more information, refer to paymentChargeSpecification object fields description |
paymentChargeSpecification object fields description
| Parameter | Description | Example |
|---|---|---|
pricemandatory | The transaction amount. Type: Number | 1000 |
netAmountDebitoptional | Net amount to be debited. Type: Number | 1000 |
taxSpecificationoptional | Tax details of the product/order. Type: Object | |
convenienceFeeoptional | Fees format. Type: String | CC:12 |
offersoptional | Offers applied or available for the payment. Type: Object |
userDefinedFields object fields description
| Field | Description |
|---|---|
| udf1 | User defined field. |
| udf2 | User defined field. |
| udf3 | User defined field. |
| udf4 | User defined field. |
| udf5 | User defined field. |
| udf6 | User defined field. |
| udf7 | User defined field. |
| udf8 | User defined field. |
| udf9 | User defined field. |
| udf10 | User defined field. |
additionalInfo object fields description
| Parameter | Description | Example | createOrderoptional |
A flag to store the order details (true/false). | true |
|---|---|---|
txnS2sFlowoptional |
For defining seamless/non-seamless flows in handling payments. | seamless |
vpa |
|
test@payu |
callBackActions object fields description
| Parameter | Description | Example |
|---|---|---|
successActionmandatory |
URL to be called on payment success. | https://example.com/success |
failureActionmandatory |
URL to be called on payment failure. | https://example.com/failure |
cancelActionmandatory |
URL to be called if user cancels the payment. | https://example.com/cancel |
codActionoptional |
URL for Cash on Delivery (COD) action. | https://example.com/cod |
billingDetails object fields description
| Parameter | Description | Example |
|---|---|---|
firstNamemandatory |
First name of the billing contact. | Ashish |
lastNameoptional |
Last name of the billing contact. | Kumar |
address1mandatory |
Primary billing address. | 123 Main Street |
address2optional |
Secondary billing address. | Apt 4B |
phoneoptional |
Phone number of the billing contact. | 9123456789 |
emailmandatory |
Email address of the billing contact. | [email protected] |
cityoptional |
City of the billing address. | Bharatpur |
stateoptional |
State of the billing address. | Rajasthan |
countryoptional |
Country of the billing address. | India |
zipCodeoptional |
Postal/Zip code of the billing address. | 321028 |
omniChannelDetails object fields description
| Field | Description | Example |
|---|---|---|
soundBoxTerminalId optional | string Identifier of the POS or sound box terminal device used for the transaction. Used for in-person/omnichannel payments. | "1" |
outletName optional | string Name of the merchant outlet or store where the transaction takes place. | "puma pimpri" |
vendorId optional | string Vendor or terminal provider identifier associated with the device or outlet. | "vendorId" |
tips optional | string Tips amount or related information for the transaction, if applicable. | "tips" |
childMerchId optional | string Child merchant ID when using split settlements or multiple outlets under a parent merchant. | "childMerchId" |
expiryTime optional | string or numeric Validity of the QR or transaction in seconds. If not sent, merchant-level or global expiry may apply. | "100" or 3600 |
Sample request
curl --location 'https://api.payu.in/v2/payments' \
--header 'Content-Type: application/json' \
--header 'date: {{date}}' \
--header 'authorization: {{authorization}}' \
--data-raw '{
"accountId": "smsplus",
"txnId": "b5f29799999987988995",
"amount": 10,
"currency": "INR",
"paymentSource": "WEB",
"paymentMethod": {
"name": "DBQR",
"bankCode": "UPIDBQR"
},
"order": {
"productInfo": "UPI Payment for Order",
"userDefinedFields": {
"udf1": "",
"udf2": "",
"udf3": "",
"udf4": "",
"udf5": "",
"udf6": "",
"udf7": "",
"udf8": "",
"udf9": "",
"udf10": ""
},
"paymentChargeSpecification": {
"price": "10.00"
}
},
"additionalInfo": {
"txnFlow": "seamless",
"createOrder": true,
"txnS2sFlow": "4",
"vpa": "anything@payu"
},
"callBackActions": {
"successAction": "https://yoursite.com/success",
"failureAction": "https://yoursite.com/failure",
"cancelAction": "https://yoursite.com/cancel"
},
"omniChannelDetails": {
"soundBoxTerminalId": "1",
"outletName": "puma pimpri",
"vendorId": "vendorId",
"tips": "tips",
"childMerchId": "childMerchId",
"expiryTime": "100"
},
"billingDetails": {
"firstName": "John",
"lastName": "Doe",
"phone": "9876543210",
"email": "[email protected]",
"city": "Mumbai",
"state": "Maharashtra",
"country": "India",
"zipCode": "400001"
}
}'Sample response
{
"result": {
"authAction": "https://api.payu.in/payments/999993715527842445/otps",
"amount": "10.00",
"merchantVpa": "anything@payu",
"postToBank": {
"token": "D60703B2-AC69-CA71-F987-3A1C404954D8",
"amount": "10.00",
"mihpayid": "a55a7c603186536fad0d6f9fe9e1a1c9828b7069599cb2623538f0ce18175cfc",
"payeeVpa": "gauravdua4.payu@indus",
"payeeName": "TestMerchant180012",
"transactionFee": "10.00"
},
"merchantName": "TestMerchant180012",
"paymentId": "999993715527842445",
"qrString": "upi://pay?pa=gauravdua4.payu@indus&pn=Test Company&tr=999993715527842445&tid=PPPL9999937155278424452312250048356&am=10.00&cu=INR&tn=UPI Transaction"
},
"status": "PENDING"
}Response parameters
The result parameter in the response contains the following fields:
| Field | Description | Example |
|---|---|---|
| authAction | string URL to post OTP or other auth data (e.g. for UPI collect/OTP flows). The client should use this endpoint when the flow requires submitting OTP or auth details. | "https://api.payu.in/payments/999993715527842445/otps" |
| amount | string Transaction amount in the response, in decimal form. | "10.00" |
| merchantVpa | string Merchant’s UPI VPA (Virtual Payment Address) where the payment is collected. | "anything@payu" |
| merchantName | string Display name of the merchant as registered with PayU. | "TestMerchant180012" |
| paymentId | string PayU’s unique payment/transaction reference. Use this for status checks, refunds, and support. | "999993715527842445" |
| qrString | string UPI payment URI to be encoded as a QR code. The client should generate a QR from this string (after removing any line breaks) and show it for the customer to scan with a UPI app. | "upi://pay?pa=...&am=10.00&cu=INR&tn=..." |
| postToBank | object Data required to post the payment request to the bank/UPI app (e.g. for collect or redirect flows). Contains token, payee details, and fee. |
Reference:To check the transaction status, refer to Verify Payment API.
