Generate UPI Intent API

This API allows merchants to generate a UPI payment intent for accepting UPI payments.

HTTP Method: POST

Environment

Request headers

ParameterDescription
dateThe current date and time. For example, format of the date is Wed, 28 Jun 2023 11:25:19 GMT.
authorizationThe 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

FieldDescription
usernameRepresents the username or identifier for the client or merchant, for example smsplus.
algorithmUse SHA512 algorithm for hashing and send this as header value.
headersSpecifies which headers have been used in generating the hash, for example date.
signatureThe 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

ParameterDescriptionExample
transactionId
mandatory
String Unique identifier for the transaction. This should be unique for each request.0fd9829f68
transactionAmount
mandatory
String Amount to be paid. The amount should be in the format of "XX.XX".190
expiryTime
mandatory
String Expiry time for the intent in seconds. After this time, the intent will expire and cannot be used for payment.10000
refUrl
optional
String Reference URL for the transaction. This can be your website URL or any reference page.http://www.payu.in
category
optional
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

ParameterDescriptionExample
messageString Response message indicating the operation result.Success
statusInteger Status code for the operation. 1 for success, 0 for failure.1
result.intentIdString 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.intentUriString 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.intentUrlString URL for payment that can be used in web applications.https://secure.payu.in/omni?id=000b
result.intentUrlWithQRString URL with QR code for payment that can be displayed to users for scanning.https://secure.payu.in/omni?id=000b
result.bankAccountsArray Array of bank account details associated with the merchant.[Object]
result.bankAccounts[].bankNameString Name of the bank.HDFC Bank
result.bankAccounts[].accountNumberString Partially masked account number.XXXXXXXX1234
result.bankAccounts[].ifscCodeString IFSC code of the bank branch.HDFC0000001
result.transactionIdString Transaction ID provided in the request.0fd9829f68
result.expiryTimeInteger Expiry time in seconds as provided in the request.10000