UPI Integration
PayU allows you to collect payments using UPI handles with seamless integration. For the list of UPI providers supported, refer to UPI Handles.
Steps to Integrate:
Before you begin:PayU recommends you to integrate with Test environment initially. For more information, contact you PayU Key Account Manager (KAM) or PayU Support.
Step 1: Validate the UPI handle
When your customer makes payment through UPI, you can validate the customer's Virtual Payment Address (VPA) and then initiate payment. The validateVpa API is used to validate the UPI handle. Validate the VPA (UPI handle) using the validateVpa API. For more information, refer to Validate VPA Handle API.
Step 2: Initiate the payment to PayU
The following parameters vary for the UPI payment mode in the Collect Payment API (v2/payments API).
Environment
Test Environment | https://apitest.payu.in/v2/payments |
Production Environment | https://api.payu.in/v2/payments> |
Reference:For the Try It experience and response, refer to Collect Payments API under API Reference.
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
The following table describes the request body parameters:
Parameter | Description | Example |
---|---|---|
accountId |
|
MERCHANT123 |
txnId |
|
REF123456 |
paymentMethod |
|
{ "name": "UPI", "bankCode": "UPI" } |
additionalInfo |
|
{"vpa": "test@payu", "txnS2sFlow": "seamless"} |
order |
|
|
callBackActions |
|
|
billingDetails |
|
paymentMethod object
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
order object
Parameter | Description | Example |
---|---|---|
productInfomandatory |
Product details. | Product details |
orderedItemoptional |
Details about the items ordered. | Array of Objects |
userDefinedFieldsoptional |
Custom fields for additional information. Fields: udf1, udf2, udf3, udf4, udf5, udf6, udf7, udf8, udf9, udf10. For more information, refer to | Object |
paymentChargeSpecificationmandatory |
Includes amount and charges. For more information, refer to paymentChargeSpecification object fields description | Object |
paymentChargeSpecification object fields description
Parameter | Description | Example |
---|---|---|
pricemandatory |
The transaction amount. | 1000 |
netAmountDebitoptional |
Net amount to be debited. | 1000 |
taxSpecificationoptional |
Tax details of the product/order. | Object |
convenienceFeeoptional |
Fees format (e.g., CC:12). | CC:12 |
offersoptional |
Offers applied or available for the payment. | 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. |
callBackActions object
callBackActions object
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
billingDetails object
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 |
additionalInfo object
Additional Info Object
Parameter | Description | Example |
---|---|---|
partnerHoldTimeoptional |
Time held by the partner for the transaction. | 60 |
createOrderoptional |
A flag to store the order details (true/false). | true |
txnFlowoptional |
For defining seamless/non-seamless flows in handling payments. | seamless |
Sample request
curl --location 'https://apitest.payu.in/v2/payments' \
--header 'date: Thu, 27 Mar 2025 10:12:27 GMT' \
--header 'authorization: hmac username="smsplus", algorithm="sha512", headers="date", signature="<signature>"' \
--header 'Content-Type: application/json' \
--data-raw '{
"accountId": "smsplus",
"referenceId": "b5f2d8785768087678fn4",
"currency": "INR",
"paymentSource": "WEB",
"paymentMethod": {
"name": "UPI",
"bankCode": "UPI"
},
"additionalInfo": {
"vpa": "test@payu",
"txnFlow": "seamless"
},
"order": {
"productInfo": "qwertyuiopasdfghjkl",
"userDefinedFields": {
"udf1": "",
"udf2": ""
},
"paymentChargeSpecification": {
"price": "10"
}
},
"callBackActions": {
"successAction": "https://pp78admin.payu.in/test_response",
"failureAction": "https://pp78admin.payu.in/test_response",
"cancelAction": "https://pp78admin.payu.in/test_response"
},
"billingDetails": {
"firstName": "John",
"lastName": "",
"phone": "9876543210",
"email": "[email protected]",
"city": "Bharatpur",
"state": "Rajasthan",
"country": "India",
"zipCode": "321028"
}
}'
Sample response
Parameter | Description |
---|---|
txnId | This parameter contains the transaction ID of the transaction. |
paymentId | This parameter contains the payment ID of the transaction. |
message | This parameter contains the status message of the transaction. |
{
"referenceId": "b5f2d8785768087678fm9",
"paymentId": "1999110000001769",
"message": "Please call verify api to get the transaction status"
}
Step 3: Verify the payment
After initiating the payment, you must verify the payment status using the Verify Payment API. For more information, refer to Verify Payment API.
The customer can complete the UPI payment through their UPI app, and you can verify the transaction status to confirm the payment.
Note:
- The UPI transaction may take some time to complete
- Always verify the payment status before providing the service to the customer
- Use the referenceId from the initial request to track the transaction
Updated 5 days ago