This API allows merchants to generate a UPI payment intent for accepting UPI payments.
HTTP Method: POST
Environment
Test Environment | http://test.payu.in/info/v1/intent` |
Production Environment | https://info.payu.in/v1/intent |
Request headers
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 parameters
Parameter | Description | Example |
---|---|---|
transactionIdmandatory | String Unique identifier for the transaction. This should be unique for each request. | 0fd9829f68 |
transactionAmountmandatory | String Amount to be paid. The amount should be in the format of "XX.XX". | 190 |
expiryTimemandatory | String Expiry time for the intent in seconds. After this time, the intent will expire and cannot be used for payment. | 10000 |
refUrloptional | String Reference URL for the transaction. This can be your website URL or any reference page. | http://www.payu.in |
categoryoptional | String Category code for the transaction. This helps in categorizing the payment for reporting purposes. | 01 |
Sample request
curl --location 'https://info.payu.in/v1/intent' \
--header 'mid: 2' \
--header 'Content-Type: application/json' \
--data '{
"transactionId": "0fd9829f68",
"transactionAmount": "190",
"expiryTime": "10000",
"refUrl": "http://www.payu.in",
"category": "01"
}'
Sample response
{
"message": "Success",
"status": 1,
"result": {
"intentId": "upi://pay?pa=payumoney@hdfcbank&pn=PayUMoney&tr=0fd9829f68&am=190.00&cu=INR&mc=5411&tn=Payment%20to%20Merchant",
"intentUri": "upi://pay?pa=payumoney@hdfcbank&pn=PayUMoney&tr=0fd9829f68&am=190.00&cu=INR&mc=5411&tn=Payment%20to%20Merchant",
"intentUrl": "https://secure.payu.in/omni?id=000b",
"intentUrlWithQR": "https://secure.payu.in/omni?id=000b",
"bankAccounts": [
{
"bankName": "HDFC Bank",
"accountNumber": "XXXXXXXX1234",
"ifscCode": "HDFC0000001"
}
],
"transactionId": "0fd9829f68",
"expiryTime": 10000
}
}
Response Parameters
Parameter | Description | Example |
---|---|---|
message | String Response message indicating the operation result. | Success |
status | Integer Status code for the operation. 1 for success, 0 for failure. | 1 |
result.intentId | String Generated UPI intent ID in the format of a UPI URI that can be used for payment. | upi://pay?pa=payumoney@hdfcbank&pn=PayUMoney&tr=0fd9829f68&am=190.00&cu=INR&mc=5411&tn=Payment%20to%20Merchant |
result.intentUri | String URI for UPI payment that can be used in mobile apps for deep linking to UPI apps. | upi://pay?pa=payumoney@hdfcbank&pn=PayUMoney&tr=0fd9829f68&am=190.00&cu=INR&mc=5411&tn=Payment%20to%20Merchant |
result.intentUrl | String URL for payment that can be used in web applications. | https://secure.payu.in/omni?id=000b |
result.intentUrlWithQR | String URL with QR code for payment that can be displayed to users for scanning. | https://secure.payu.in/omni?id=000b |
result.bankAccounts | Array Array of bank account details associated with the merchant. | [Object] |
result.bankAccounts[].bankName | String Name of the bank. | HDFC Bank |
result.bankAccounts[].accountNumber | String Partially masked account number. | XXXXXXXX1234 |
result.bankAccounts[].ifscCode | String IFSC code of the bank branch. | HDFC0000001 |
result.transactionId | String Transaction ID provided in the request. | 0fd9829f68 |
result.expiryTime | Integer Expiry time in seconds as provided in the request. | 10000 |