Environment
Test Environment | https://test.payu.in/info/linkAndPay/get\_emi\_checkout_details |
Production Environment | https://info.payu.in/linkAndPay/get\_emi\_checkout_details |
Request Parameters
Header
The request header contains the following fields:
Field | Description | Example |
---|---|---|
Date mandatory | The date and time should be in the GMT time conversion(not the IST). For example, current time in India is 18:00:00 IST, the time in the date header should be 12:30:00 GMT. | Thu, 17 Feb 2022 08:17:59 GMT |
Digest mandatory | Base 64 encode of (sha256 hash of the JSON data (post to server). | vpGay5D/dmfoDupALPplYGucJAln9gS29g5Orn+8TC0= |
Authorization mandatory | This field is in the following format:hmac username="smsplus", algorithm="hmac-sha512", headers="date digest", signature="CkGfgbho69uTMMOGU0mHWf+1CUAlIp3AjvsON9n9/E4=" Where the above format includes the following: - username: The merchant key of the merchant. - algorithm: This must have the value as hmac-sha512 that is used for this API - headers: This must have the value as date digest - signature: This must contain the hmacsha512 of (signing_string, merchant_secret), where: - signing_string: This is in the "Date"+"\n"+"Digest" format. Here, the Date and Digest is the same values in the fields listed in this table For example, "Thu, 17 Feb 2022 08:17:59 GMT""\n"+“vpGay5D/dmfoDupALPplYGucJAln9gS29g5Orn+8TC0=“ - merchant_secret: The merchant Salt of the merchant. For more information on getting the merchant Salt, refer to Generate Merchant Key and Salt on PayU Dashboard | hmac username="smsplus", algorithm="hmac-sha256", headers="date digest", signature="zGmP5Zeqm1pxNa+d68DWfQFXhxoqf3st353SkYvX8HI=" |
platformId mandatory | This field contains the platform ID and include the value as 1. | 1 |
Required parameters for calculating authorization
- Date
- Authorization
The following sample Java code contains the logic used to encrypt as described in the above table:
// date
var date = new Date();
// var date = "Wed, 28 Jun 2023 11:25:19 GMT";
date = date.toUTCString();
// authorization
var authorization = getAuthHeader(date);
console.log(authorization);
function getAuthHeader(date) {
var AUTH_TYPE = 'sha512';
var data = isEmpty(request['data'])?"":request['data'];
var hash_string = data + '|' + date + '|' + pm.variables.get("merchantSalt");
console.log("Hash String is ", hash_string);
var hash = CryptoJS.SHA512(hash_string).toString(CryptoJS.enc.Hex);
var authHeader = 'hmac username="' + pm.variables.get("merchantKey") + '", ' + 'algorithm="' + AUTH_TYPE + '", headers="date", signature="' + hash + '"'
return authHeader;
}
pm.environment.set('date', date);
pm.environment.set('authorization', authorization);
function isEmpty(obj) {
for(var key in obj) {
if(obj.hasOwnProperty(key))
return false;
}
return true;
}
Body parameters
Field | Description | Example |
---|---|---|
Key mandatory | String The merchant key provided by PayU. Reference: For more information on how to generate the Key and Salt, refer to any of the following: - Production: Generate Production Merchant Key and Sat. - Test: Generate Test Merchant Key and Salt. | Your Test Key |
requestId mandatory | String This parameter must contain the unique ID for making an eligibility request. | Test1234 |
amount mandatory | String The transaction amount for which the eligibility is checked is to be passed here | {"amount":"10000"} |
pg mandatory | String It defines the payment category using the Merchant Hosted Checkout integration. For a BNPL payment, "BNPL" must be specified in the pg parameter. | BNPL |
Bankcode mandatory | String The merchant must post this parameter with the corresponding payment option’s bank code value in it. For the list of bankcodes for BNPL, refer to BNPL Codes. In future, wallet options will also be added. | LAZYPAY |
phonemandatory | String This parameter must contain the customer’s phone number for which the eligibility is to be checked needs to be passed | “9999999999” |
payuTokenoptional | String This parameter must contain is the PayU instrument token for saved card. | Token12345 Note: One or multiple payu tokens can be passed and max 10 tokens supported in a request. |
user_credentialsoptional | String This parameter must contain an unique user credential mapped against each user, to be passed by the merchant for saved card. | abc:xyz |
Sample request
curl --location 'https://test.payu.in/info/linkAndPay/get_emi_checkout_details' \
--header 'x-credential-username: smsplus' \
--header 'Content-Type: application/json' \
--header 'authorization: hmac username="x0i6r2", algorithm="sha512", headers="date", signature="0e0ebc518c085d8ff49058b7c232bfe2e8779e9e9cafd34a4cdf1c11114035eea75b0e404a9b9e152757dbcc4926f78b6f18ba7f6643e2bf687a65942d3bde38"' \
--header 'date: Mon, 28 Oct 2024 10:34:49 GMT' \
--data '{
"amount": 2000000,
"userCredentials": "aaa:bbb",
"phone": "9560012582",
"bankCode": null,
"payuToken": null
}'
Authorization calculation logic:
For authorization calculation logic, refer to Required parameters for calculating authorization.
Sample response
Success scenario
{
"bnpl":{
"all":[
{
"Lazypay":{
"status":1,
"kfsLink":"https":,
"eligible":true,
"customerLinked":true,
"PayuToken":“Token12345”
},
"Simpl":{
"status":1,
"availableBalance":500,
"kfsLink":"https":,
"eligible":true,
"customerLinked":true,
"PayuToken":“Token78901”
}
}
]
}
}
Failure scenario
- Customer eligible but not linked
{
"bnpl": {
"all": {
"Lazypay": {
"status": 1,
"kfsLink": "https://www.somekfsLink.com",
"eligible": true,
"customerLinked": false
}
}
}
}
- Customer not eligible
{
"Lazypay": {
"status": 1,
"eligible": false, // based on amount and not to return available balance if eligible is false
"customerLinked": false,
"failure_code": "E2408",
"failure_reason": "The transaction or loan amount is greater than the available credit line with the customer"
}
}