Classic Integration
This section describes classic integration over the Redirect experience for cards using v2/payments API involves the following steps:
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: Initiate payment request with PayU
The merchant initiates PayU with the required transaction mandatory or optional parameters. This needs to be a server-to-server cURL call request. URL, parameters, and descriptions. The response for the seamless payment request is not similar to Merchant Hosted or PayU Hosted Checkout.
You can collect card payments using Server-to-Server integration using classic integration. For seamless Classic integration, the additionalInfo.txnFlow field is set to 4.
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 Cards Classic Integration 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 |
|
|
order |
|
|
additionalInfo |
|
|
callBackActions |
|
|
billingDetails |
|
paymentMethod object fields description
paymentMethod object
Field | Description | Example |
---|---|---|
name |
|
CreditCard |
bankCode |
|
CC |
paymentCard |
|
paymentCard object fields description
paymentCard object
Parameter | Description | Example |
---|---|---|
cardNumbermandatory for physical card |
Card number. | 5497774415170603 |
validThroughmandatory for physical card |
Expiry date in MM/YYYY format. | 05/2025 |
ownerNameoptional |
Name of the card owner. | Ashish |
cvvmandatory for physical card |
CVV number of the card. | 123 |
tavvmandatory for saved card |
Cryptogram of the card for tokenized payments. | AAABAWFlmQAAAABjRWWZEEFgFz |
last4Digitsmandatory for saved card |
Last four digits of the card. | 0603 |
cardTokenTypemandatory for saved card |
Card token type. Valid values: PAYU, NETWORK, ISSUER. | PAYU |
cardTokenmandatory for saved card |
Card token of the stored card. | b5f2d8785768087678fm9 |
order object fields description
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. |
additionalInfo object fields description
Parameter | Description | Example |
---|---|---|
enforcePaymethodoptional |
Force a transaction with a specified method (e.g., CC, DC). | CC |
forcePgidoptional |
Forces identification for payment gateway. | PG123 |
partnerHoldTimeoptional |
Time held by the partner for the transaction. | 60 |
userCredentialsoptional |
Credentials for user authentication. | string |
userTokenoptional |
Token for the customer. | user_token_123 |
subventionAmountoptional |
Amount paid through EMI subvention payments. | 100 |
authOnlyoptional |
Initiates an authentication-only payment (true/false). | false |
createOrderoptional |
A flag to store the order details (true/false). | true |
txnS2sFlowoptional |
For defining seamless/non-seamless flows in handling payments. | seamless |
AdditionalInfo object
Field | Description | Example |
---|---|---|
txnFlow |
|
4 |
authenticationFlow |
|
REDIRECT |
createOrder |
|
false |
preAuthorize |
|
1 |
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
callBackActions 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 |
Error HandlingIf any error message is displayed with an error code, refer to the Error Codes section to understand the reason for these error codes.
Sample request
curl --location 'https://apitest.payu.in/v2/payments' \
--header 'date: Tue, 05 Nov 2024 06:12:57 GMT' \
--header 'authorization: hmac username="smsplus", algorithm="sha512", headers="date", signature="d583ff8069c7dfa8340464a24bdd01cbebf4432b4dfe4de862065cc9c9dc622c24c77cb1ac1142bf581ec07eca8d0ec78a66db93f6cd557d0da552f05c0825e3"' \
--header 'Content-Type: application/json' \
--header 'mid: 8390470' \
--header 'X-CREDENTIAL-USERNAME: UMXDPA' \
--data-raw '{
"accountId": "UMXDPA",
"referenceId": "ZP6267f0d2996ce",
"amount": 10,
"paymentMethod": {
"name": "CreditCard",
"bankCode": "CC",
"paymentCard": {
"cardNumber": 500***1234560***,
"validThrough": "04/2027",
"ownerName": "Ashish",
"cvv": ***,
"tavv": "/wAAAAAAPtP+g6IAmbSeg1gAAAA=",
"last4Digits": "0000",
"cardTokenType": "NETWORK",
"cardToken": "29850879bf39848ca078727b8e1a95165a41cea1"
}
},
"order": {
"productInfo": "string",
"orderedItem": [
{
"itemId": null,
"description": "AAA",
"quantity": null,
"amount" : 10.0
}
],
"userDefinedFields": {
"udf1": "",
"udf2": "",
"udf3": "",
"udf4": "",
"udf5": "",
"udf6": "",
"udf7": "",
"udf8": "",
"udf9": "",
"udf10": ""
},
"paymentChargeSpecification": {
"price": 10,
}
},
"additionalInfo": {
"txnS2sFlow": "4",
"authenticationFlow": "REDIRECT"
},
"callBackActions": {
"successAction": "https://testapi.payu.in/admin/testresponsev2?action=successAction",
"failureAction": "https://testapi.payu.in/admin/testresponsev2?action=failureAction",
"cancelAction": "https://testapi.payu.in/admin/testresponsev2?action=cancelAction",
"codAction": "https://testapi.payu.in/admin/testresponsev2?action=codAction",
"termAction": "string",
"timeOutAction": null,
"returnAction": "https://testapi.payu.in/admin/testresponsev2?action=successAction"
},
"billingDetails": {
"firstName": "sartaj",
"lastName": "",
"phone": "9876543210",
"email": "[email protected]",
"city": "Bharatpur",
"state": "Rajasthan",
"country": "India",
"zipCode": "321028"
},
"deviceInfo": {
"platform": null,
"version": null,
"ip": null,
"userAgent": null,
"acceptHeader": null,
"language": null,
"colorDepth": null,
"screenHeight": null,
"screenWidth": null,
"timeZone": null,
"javaEnabled": null
}
}'
Sample response
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="ec84843a663143bb89391f6fa2d4b9404bab1543a3eee81263b4a507ebf5d289d8fad1fbcdd59da820951e3e0f9b0b0b3d1bad9b41338804e7c42a8a6197c6e9"' \
--header 'Content-Type: application/json' \
--header 'Cookie: PHPSESSID=sclorpmpb4ngion5e996os22ao' \
--data-raw '{
"accountId": "smsplus",
"referenceId": "b5f2d8785768087678fn4",
"amount": 10,
"currency": "INR",
"paymentSource": "WEB",
"paymentMethod": {
"name": "CreditCard",
"bankCode": "CC",
"paymentCard": {
"cardNumber": 5497774415170603,
"validThrough": "05/2025",
"cvv": 123,
"cardToken": "29850879bf39848ca078727b8e1a95165a41cea1",
"ownerName": "Ashish",
"issuer": "ICICI",
"bin": "500446",
"last4Digits": "0000",
"cardHash": null,
"cardTokenType": "NETWORK",
"tavv": "/wAAAAAAPtP+g6IAmbSeg1gAAAA="
}
},
"order": {
"productInfo": "qwertyuiopasdfghjkl",
"orderedItem": [
{
"itemId": "1",
"description": "string",
"quantity": 1
}
],
"userDefinedFields": {
"udf1": "",
"udf2": "",
"udf3": "",
"udf4": "",
"udf5": "",
"udf6": "",
"udf7": "",
"udf8": "",
"udf9": "",
"udf10": ""
},
"paymentChargeSpecification": {
"price": 10,
"convenienceFee": "CC:12,AMEX:19,SBIB:98,DINR:2,DC:25,NB:55",
"offers": {
"applied": [
{
"offerId": "no_offer",
"amount": null
}
]
}
}
},
"additionalInfo": {
"txnS2sFlow": "4",
"authenticationFlow": "REDIRECT"
},
"callBackActions": {
"successAction": "https://apitest.payu.in/test_response",
"failureAction": "https://apitest.payu.in/test_response",
"cancelAction": "https://apitest.payu.in/test_response"
},
"billingDetails": {
"firstName": "sartaj",
"lastName": "",
"phone": "9876543210",
"email": "[email protected]",
"city": "Bharatpur",
"state": "Rajasthan",
"country": "India",
"zipCode": "321028"
},
"authorization": {
"eci": "05",
"cavv": "AAABAWFlmQAAAABjRWWZEEFgFz",
"flowType": "Frictionless",
"threeDSTransID": "67b4c71f-19bf-4d97-bd09-4e3687dc9e42",
"threeDSServerTransID": "eea30d14-71cf-41af-b961-f95b7d67dc93",
"threeDSTransStatus": "Y",
"threeDSTransStatusReason": "01",
"aquirer_bin": "401200",
"additionalInfo": {
"authUdf1": "string",
"authUdf2": "string"
}
},
"threeDS2RequestData": {
"threeDSVersion": "2.2.0",
"deviceChannel": "APP"
}
}'
Step 2: Redirect the customer
Redirect the customer to the bank page using the acsTemplate as received in Step 1.
Step 3: Verify payment
Sample response
The sample response after the customer makes payment will be similar to v2 merchant hosted checkout payments.
Note:Reverse hashing of the response is not required with that of v2/payment API.
Array
(
[referenceId] => b5f2d8785768087678fm9
[paymentId] => 1999110000001769
[message] => Please call verify api to get the transaction status
)
Verify the transaction details using the Verification APIs. For API reference, refer to Verify Payment API under API Reference.
TipThe transaction ID that you posted in Step 1 with PayU must be used here.
Updated 5 days ago