Non-seamless - Preauth Transaction

The Collect Payment API (v2 Payment API) with the preAuthorize=1 in the additionalInfo object.

📘

Note:

You must use the additionalInfo.txnFlow must be set to nonseamless for PayU Hosted Checkout.

📘

Reference:

To handle redirect URLs (surl and furl), refer to Handling the Redirect URLs.

Environment

Request header

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, in this case, it's "smsplus".
algorithmIndicates the hashing algorithm used for the HMAC signature. Here, it is set to "sha512".
headersSpecifies which headers have been used in generating the hash. In this case, only the "date" header is used.
signatureThe actual HMAC signature generated using the specified algorithm (sha512) and includes the hashed data. For more information, refer to hashing algorithm.

hashing algorithm

You must hash the request parameters using the following 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();
// 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 + '|' + merchant_secret;
console.log("Hash String is ", hash_string);
var hash = CryptoJS.SHA512(hash_string).toString(CryptoJS.enc.Hex);
var authHeader = 'hmac username="' + merchant_key + '", ' + 'algorithm="' + AUTH_TYPE + '", headers="date", signature="' + hash + '"'
return authHeader;
}

pm.environment.set('date', date);
pm.environment.set('authorization', authorization);
pm.environment.set('merchant_key',merchant_key);
pm.environment.set('merchant_secret',merchant_secret);

function isEmpty(obj) {
for(var key in obj) {
if(obj.hasOwnProperty(key))
return false;
}
return true;
}

Request body

Parameter Description

accountId
mandatory

StringThe merchant key provided by PayU during onboarding.

referenceId
mandatory

StringReference ID for transaction tracking. This must be unique for each transaction.

amount
optional

StringAmount of the transaction.
Note: This value will not be considered as the transaction. Only the details in the order.paymentChargeSpecification.price field will be considered.

currency
mandatory

StringCurrency of the transaction. For example, INR.

paymentSource optional

StringContains the payment source. For example, WEB.

order
mandatory

JSON ObjectDetails about the transaction order including product information, ordered items, user defined fields, and payment charge specifications. For more information, refer to order object fields description

additionalInfo
mandatory

JSON ObjectAdditional information including enforced payment methods and various options for user preferences during the transaction. For more information, refer to additionalInfo object fields description.
Note: The txnFlow field in this JSON object must be set to nonseamless.

callBackActions
mandatory

JSON ObjectActions to perform on the payment server in different scenarios. For example, success, failure, cancellation, cash on delivery, etc. For more information, refer to callbackActions object fields description

billingDetails
mandatory

JSON ObjectBilling details of the customer including name, address, phone number, email, etc. For more information, refer to billingDetails object fields descriptions.

additionalInfo object fields description

Field Description

enforcePaymethod
optional

StringMethods of payment that are enforced in the payment process. For more information, refer to Enforce Pay Method or Remove Category.

txnFlow
mandatory

StringSpecify "nonseamless" for non-seamless integration.

preAuthorize
mandatory for Pre

String When set to "1", the transaction will be in pre-authorized state and funds will be captured later.

callbackActions object fields description

Field Description

successAction
mandatory

StringURL to redirect to upon successful payment.

failureAction
mandatory

StringURL to redirect to if the payment is failed.

cancelAction
mandatory

StringURL to redirect to if the transaction is cancelled.

codAction
optional

StringURL to handle Cash on Delivery actions.

termAction
optional

StringURL for completing terms and conditions actions.

returnAction
optional

StringURL to return to after successful payment action is completed.

❗️

Error Handling

If any error message is displayed with an error code, refer to the Error Codes section to understand the reason for these error codes.

order object fields description

Field Description

productInfo
mandatory

StringDetails about the product being purchased. For more information, refer to userDefinedFields object fields description.

userDefinedFields
optional

ObjectCustom fields defined by the user for additional information.

paymentChargeSpecification
mandatory

Object Payment details including amount, additional charges and PayU offers to be applied. For more information, refer to paymentChargeSpecification object fields description.

userDefinedFields object fields description
FieldDescription
udf1User defined field.
udf2User defined field.
udf3User defined field.
udf4User defined field.
udf5User defined field.
udf6User defined field.
udf7User defined field.
udf8User defined field.
udf9User defined field.
udf10User defined field.
paymentChargeSpecification object fields description
Field Description Example

price
mandatory

This field must contain the price or transaction amount to be posted.

10.00

billingDetails object field descriptions

Field Description Example

firstName
mandatory

First name of the billing contact

Ashish

lastName
optional

Last name of the billing contact

Kumar

phone
mandatory

Phone number of the billing contact

9123456789

email
mandatory

Email address of the billing contact

[email protected]

city
optional

City of the billing address

Bengaluru

state
optional

State of the billing address

Karnatka

country
optional

Country of the billing address

Indiia

zipCode
optional

Postal/Zip code of the billing address

560071

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' \
{
  "accountId": "smsplus",
  "referenceId": "b5f2d8785768087678fm9",
  "paymentStatus": "SUCCESS",
  "amount": 10,
  "currency": "INR",
  "paymentSource": "WEB",
  },
  "order": {
    "productInfo": "string",
    "orderedItem": [
      {
        "itemId": null,
        "description": "AAA",
        "quantity": null
      }
    ],
    "userDefinedFields": {
      "udf1": "",
      "udf2": "",
      "udf3": "",
      "udf4": "",
      "udf5": "",
      "udf6": "",
      "udf7": "",
      "udf8": "",
      "udf9": "",
      "udf10": ""
    },
    "paymentChargeSpecification": {
      "price": 10
  },
  "additionalInfo": {
    "txnFlow": "nonseamless",
    "createOrder" : "false",
    "preAuthorize": "1"
  },
  "callBackActions": {
    "successAction": "https://pp78admin.payu.in/test_response",
    "failureAction": "https://pp78admin.payu.in/test_response",
    "cancelAction": "https://testapi.payu.in/admin/testresponsev2?action=cancelAction"
  },
  "billingDetails": {
    "firstName": "sartaj",
    "lastName": "",
    "address1": "Test Payu Gurgaon",
    "address2": "",
    "city": "Bharatpur",
    "state": "Rajasthan",
    "country": "India",
    "zipCode": "321028",
    "phone": "9876543210",
    "email": "[email protected]"
  }
}

Response parameters

Parameter Description

referenceId

This parameter contains the reference ID of the transaction.
statusCode

paymentId

This parameter contains the payment ID of the transaction.
statusCode

message

This parameter contains the status message of the transaction.

Sample response

{
  "result": {
    "checkoutUrl": "https://pp78secure.payu.in/_payment_options?mihpayid=<mihpayuid>&userToken="
  },
  "status": "PENDING"
}
📘

Reference:

To check the transaction status, refer to Verify Payment API.