Net Banking Integration

Collect payments using Net Banking with Merchant Hosted Checkout integration as described in this section. After collecting the details from the customer, make the transaction request with the payment details to PayU.

Steps to Integrate

  1. Initiate the payment to PayU
  2. Check the response from PayU
  3. Verify Payment
👍

Before you begin:

Register for an account with PayU before you start integration. For more information, refer to Register for a Merchant Account.

Step 1: Initiate the payment to PayU

Post request syntax & composition

Post Request Syntax & Composition for Net Banking

<body>
<form action='https://test.payu.in/_payment' method='post'>
<input type="hidden" name="key" value="JP***g" />
<input type="hidden" name="txnid" value="t6svtqtjRdl34W" />
<input type="hidden" name="productinfo" value="iPhone" />
<input type="hidden" name="amount" value="10" />
<input type="hidden" name="email" value="[email protected]" />
<input type="hidden" name="firstname" value="Ashish" />
<input type="hidden" name="lastname" value="Kumar" />
<input type="hidden" name="pg" value="TESTPG" />
<input type="hidden" name="bankcode" value="TESTPGNB" />
<input type="hidden" name="surl" value="your own success url" />
<input type="hidden" name="furl" value="your own failure url" />
<input type="hidden" name="phone" value="9988776655” />
<input type="hidden" name="hash" value="eabec285da28fd0e3054d41a4d24fe9f7599c9d0b66646f7a9984303fd6124044b6206daf831e9a8bda28a6200d318293a13d6c193109b60bd4b4f8b09c90972" />
<input type="submit" value="submit"> </form>
</body>
</html>
📘

Note: The above HTML code block is for Merchant Checkout integration on the Net Banking call for the test environment.

Request parameters

The following parameters vary for the NetBanking payment mode in the Collect Payment API (_payment API).

Environment

📘

Reference: For the complete list of parameters and response, refer to Collect Payment API - Merchant Hosted Checkout under API Reference.

Parameter

Description

Example

key mandatory

String Merchant key provided by PayU during onboarding.

JP***g

txnId mandatory

String The transaction ID is a reference number for a specific order that is generated by the merchant.

ypl938459435

amount mandatory

String The payment amount for the transaction.

10.00

productinfo mandatory

String A brief description of the product.

iPhone

firstname mandatory

String The first name of the customer.

Ashish

email mandatory

String The email address of the customer.

[email protected]

phone mandatory

String The phone number of the customer.

pg mandatory

String This parameter defined the payment gateway. For NetBanking, pg=NB.

TESTPG

bankcode mandatory

String Each payment option is identified with a unique bank code at PayU. The merchant must post this parameter with the corresponding payment option's bank code value in it. For the list of bank codes that can be used with the bankcode parameter, refer to Net Banking Codes .

TESTPGNB

furl mandatory

String The success URL, which is the page PayU will redirect to if the transaction is successful.

surl mandatory

String The Failure URL, which is the page PayU will redirect to if the transaction is failed.

hash mandatory

String It is the hash calculated by the merchant. The hash calculation logic is: sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)

address1 optional

String The first line of the billing address.

  • For Fraud Detection*: This information is helpful when it comes to issues related to fraud detection and chargebacks. Hence, it is must to provide the correct information.

address2 optional

String The second line of the billing address.

city optional

String The city where your customer resides as part of the billing address.

state optional

String The state where your customer resides as part of the billing address.

country optional

String The country where your customer resides.

zipcode optional

String Billing address zip code is mandatory for the cardless EMI option. Character Limit-20

udf1 optional

String User-defined fields (udf) are used to store any information corresponding to a particular transaction. You can use up to five udfs in the post designated as udf1, udf2, udf3, udf4, udf5.

udf2 optional

String User-defined fields (udf) are used to store any information corresponding to a particular transaction. You can use up to five udfs in the post designated as udf1, udf2, udf3, udf4, udf5.

udf3 optional

String User-defined fields (udf) are used to store any information corresponding to a particular transaction.

udf4 optional

String User-defined fields (udf) are used to store any information corresponding to a particular transaction.

udf5 optional

String User-defined fields (udf) are used to store any information corresponding to a particular transaction.

Hashing

You must hash the request parameters using the following hash logic:

sha512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||SALT)

For more information, refer to Generate Hash.

Sample request

curl -X \
 POST "https://test.payu.in/_payment" -H \
 "accept: application/json" -H \
 "Content-Type: application/x-www-form-urlencoded" -d "key=JP***g&txnid=ewP8oRopzdHEtC&amount=10.00&firstname=Ashish&[email protected]&phone=9876543210&productinfo=iPhone&pg=TESTPG&bankcode=TESTPGNB&surl=https://apiplayground-response.herokuapp.com/&furl=https://apiplayground-response.herokuapp.com/&hash=bff508ec0974b20fe4be6c86cceab8c8dde88c4061a2a70373ddd0bbd3d24b21ae13984915fad06f9802f56b01a30da4e367e4e749959a76c3b2e5f12eb43319"
/**
 * PayU Payment Request using Fetch API
 * 
 * IMPORTANT: This should only be executed server-side, never in the browser,
 * as it contains sensitive payment information.
 */

// Payment endpoint
const url = 'https://test.payu.in/_payment';

// Form data parameters
const formData = new URLSearchParams();
formData.append('key', 'JP***g');
formData.append('txnid', 'ewP8oRopzdHEtC');
formData.append('amount', '10.00');
formData.append('firstname', 'Ashish');
formData.append('email', '[email protected]');
formData.append('phone', '9876543210');
formData.append('productinfo', 'iPhone');
formData.append('pg', 'TESTPG');
formData.append('bankcode', 'TESTPGNB');
formData.append('surl', 'https://apiplayground-response.herokuapp.com/');
formData.append('furl', 'https://apiplayground-response.herokuapp.com/');
formData.append('hash', 'bff508ec0974b20fe4be6c86cceab8c8dde88c4061a2a70373ddd0bbd3d24b21ae13984915fad06f9802f56b01a30da4e367e4e749959a76c3b2e5f12eb43319');

// Request options
const requestOptions = {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: formData
};

// Execute the request
fetch(url, requestOptions)
  .then(response => {
    console.log('Status Code:', response.status);
    return response.text(); // or response.json() if you're sure it returns JSON
  })
  .then(data => {
    console.log('Response:', data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
import urllib.request
import urllib.parse

url = "https://test.payu.in/_payment"

headers = {
    "accept": "application/json",
    "Content-Type": "application/x-www-form-urlencoded"
}

payload = {
    "key": "JP***g",
    "txnid": "ewP8oRopzdHEtC",
    "amount": "10.00",
    "firstname": "Ashish",
    "email": "[email protected]",
    "phone": "9876543210",
    "productinfo": "iPhone",
    "pg": "TESTPG",
    "bankcode": "TESTPGNB",
    "surl": "https://apiplayground-response.herokuapp.com/",
    "furl": "https://apiplayground-response.herokuapp.com/",
    "hash": "bff508ec0974b20fe4be6c86cceab8c8dde88c4061a2a70373ddd0bbd3d24b21ae13984915fad06f9802f56b01a30da4e367e4e749959a76c3b2e5f12eb43319"
}

data = urllib.parse.urlencode(payload).encode('utf-8')
req = urllib.request.Request(url, data=data, headers=headers, method="POST")

try:
    with urllib.request.urlopen(req) as response:
        response_body = response.read().decode('utf-8')
        print("Status Code:", response.getcode())
        print("Response:")
        print(response_body)
except urllib.error.HTTPError as e:
    print("Error:", e.code, e.reason)
    print(e.read().decode('utf-8'))
import urllib.request
import urllib.parse

url = "https://test.payu.in/_payment"

headers = {
    "accept": "application/json",
    "Content-Type": "application/x-www-form-urlencoded"
}

payload = {
    "key": "JP***g",
    "txnid": "ewP8oRopzdHEtC",
    "amount": "10.00",
    "firstname": "Ashish",
    "email": "[email protected]",
    "phone": "9876543210",
    "productinfo": "iPhone",
    "pg": "TESTPG",
    "bankcode": "TESTPGNB",
    "surl": "https://apiplayground-response.herokuapp.com/",
    "furl": "https://apiplayground-response.herokuapp.com/",
    "hash": "bff508ec0974b20fe4be6c86cceab8c8dde88c4061a2a70373ddd0bbd3d24b21ae13984915fad06f9802f56b01a30da4e367e4e749959a76c3b2e5f12eb43319"
}

data = urllib.parse.urlencode(payload).encode('utf-8')
req = urllib.request.Request(url, data=data, headers=headers, method="POST")

try:
    with urllib.request.urlopen(req) as response:
        response_body = response.read().decode('utf-8')
        print("Status Code:", response.getcode())
        print("Response:")
        print(response_body)
except urllib.error.HTTPError as e:
    print("Error:", e.code, e.reason)
    print(e.read().decode('utf-8'))
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;

public class PayUPaymentRequest {
    
    public static void main(String[] args) {
        try {
            // API endpoint
            String url = "https://test.payu.in/_payment";
            
            // Form parameters
            Map<String, String> params = new HashMap<>();
            params.put("key", "JP***g");
            params.put("txnid", "ewP8oRopzdHEtC");
            params.put("amount", "10.00");
            params.put("firstname", "Ashish");
            params.put("email", "[email protected]");
            params.put("phone", "9876543210");
            params.put("productinfo", "iPhone");
            params.put("pg", "TESTPG");
            params.put("bankcode", "TESTPGNB");
            params.put("surl", "https://apiplayground-response.herokuapp.com/");
            params.put("furl", "https://apiplayground-response.herokuapp.com/");
            params.put("hash", "bff508ec0974b20fe4be6c86cceab8c8dde88c4061a2a70373ddd0bbd3d24b21ae13984915fad06f9802f56b01a30da4e367e4e749959a76c3b2e5f12eb43319");
            
            // Convert parameters to URL encoded form data
            StringJoiner sj = new StringJoiner("&");
            for (Map.Entry<String, String> entry : params.entrySet()) {
                sj.add(URLEncoder.encode(entry.getKey(), "UTF-8") + "="
                     + URLEncoder.encode(entry.getValue(), "UTF-8"));
            }
            byte[] postData = sj.toString().getBytes(StandardCharsets.UTF_8);
            
            // Create connection
            URL apiUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection) apiUrl.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("accept", "application/json");
            conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            conn.setRequestProperty("Content-Length", String.valueOf(postData.length));
            conn.setDoOutput(true);
            
            // Send request
            try (DataOutputStream dos = new DataOutputStream(conn.getOutputStream())) {
                dos.write(postData);
            }
            
            // Read response
            int responseCode = conn.getResponseCode();
            try (BufferedReader br = new BufferedReader(
                    new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
                StringBuilder response = new StringBuilder();
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                
                System.out.println("Status Code: " + responseCode);
                System.out.println("Response: " + response.toString());
            }
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Step 2: Check response from PayU

Hash validation logic for payment response (Reverse Hashing)

While sending the response, PayU takes the exact same parameters that were sent in the request (in reverse order) to calculate the hash and returns it to you. You must verify the hash and then mark a transaction as a success or failure. This is to make sure the transaction has not tampered within the response.

The order of the parameters is similar to the following code block:

sha512(SALT|status||||||udf5|udf4|udf3|udf2|udf1|email|firstname|productinfo|amount|txnid|key)

Sample response (parsed)

Array
(
    [mihpayid] => 403993715524045752
    [mode] => NB
    [status] => success
    [unmappedstatus] => captured
    [key] => JPM7Fg
    [txnid] => ewP8oRopzdHEtC
    [amount] => 10.00
    [discount] => 0.00
    [net_amount_debit] => 10
    [addedon] => 2021-09-06 13:27:08
    [productinfo] => iPhone
    [firstname] => Ashish
    [lastname] => 
    [address1] => 
    [address2] => 
    [city] => 
    [state] => 
    [country] => 
    [zipcode] => 
    [email] => [email protected]
    [phone] => 9876543210
    [udf1] => 
    [udf2] => 
    [udf3] => 
    [udf4] => 
    [udf5] => 
    [udf6] => 
    [udf7] => 
    [udf8] => 
    [udf9] => 
    [udf10] => 
    [hash] => 1be7e6e97ab1ea9034b9a107e7cf9718308aa9637b4dbbd1a3343c91b0da02b34a40d00ac7267ebe81c20ea1129b931371c555d565bc6e11f470c3d2cf69b5a3
    [field1] => 
    [field2] => 
    [field3] => 
    [field4] => 
    [field5] => 
    [field6] => 
    [field7] => 
    [field8] => 
    [field9] => Transaction Completed Successfully
    [payment_source] => payu
    [PG_TYPE] => NB-PG
    [bank_ref_num] => 87d3b2a1-5a60-4169-8692-649f61923b3d
    [bankcode] => TESTPGNB
    [error] => E000
    [error_Message] => No Error
)

Step 3: Verify the payment

Verify the transaction details using the Verification APIs. For more information, refer to Verify Payment API under API Reference.

📘

Tip: The transaction ID that you posted in Step 1 with PayU must be used here.

Environment

Sample request
curl --location 'https://test.payu.in/merchant/postservice.php?form=2' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'key=JP***g' \
--data-urlencode 'command=verify_payment' \
--data-urlencode 'var1=IhfgcZnXR4o4nB' \
--data-urlencode 'hash=a0ae79fdd66c875af6e9b21c4a67f1822deb00f2df5e9f0b1948f3222f536a9bf741b24efbb1874ca0f84f76b036e6c0d641581d0100f7abe4aeed2f3264f5c9'
Sample response
  • If credit card payment is made, the response is similar to the following:
{
    "status": 1,
    "msg": "1 out of 1 Transactions Fetched Successfully",
    "transaction_details": {
        "1733900931584": {
            "mihpayid": "21820644083",
            "request_id": null,
            "bank_ref_num": null,
            "amt": "1.00",
            "transaction_amount": "1.00",
            "txnid": "1733900931584",
            "additional_charges": "0.00",
            "productinfo": "Macbook Pro",
            "firstname": "Abc",
            "bankcode": "MAST",
            "udf1": "udf1",
            "udf2": "udf2",
            "udf3": "udf3",
            "udf4": "udf4",
            "udf5": "udf5",
            "field2": null,
            "field9": "OTP/ATM page expired due to no user action",
            "error_code": "E1602",
            "addedon": "2024-12-11 12:43:03",
            "payment_source": "payu",
            "card_type": "MAST",
            "error_Message": "Bank was unable to authenticate.",
            "net_amount_debit": "0.00",
            "disc": "0.00",
            "mode": "DC",
            "PG_TYPE": "DC-PG",
            "card_no": "XXXXXXXXXXXX7596",
            "status": "failure",
            "unmappedstatus": "dropped",
            "Merchant_UTR": null,
            "Settled_At": null,
            "cardhash": "095d184331be367bb92aa3eeecb57d0728de96cc598dd563d407982d75021149",
            "name_on_card": null,
            "card_token": "4e97156bc2d6320cdfe15",
            "field4": null,
            "threeDSVersion": "2.2.0",
            "offerAvailed": null
        }
    }
}
  • Offer availed on cart level
{
    "status": 1,
    "msg": "1 out of 1 Transactions Fetched Successfully",
    "transaction_details": {
        "1036-f0cf85f2": {
            "mihpayid": "21564143078",
            "request_id": "",
            "bank_ref_num": "431998369241",
            "amt": "2.00",
            "transaction_amount": "2.00",
            "txnid": "1036-f0cf85f2",
            "additional_charges": "0.00",
            "productinfo": "EXPRESS",
            "firstname": "guest",
            "bankcode": "TEZOMNI",
            "udf1": "Magento2",
            "udf2": "",
            "udf3": "",
            "udf4": "",
            "udf5": "qs8rbc1ng2hmqtakk381en6j2p",
            "field2": "114390824407",
            "field9": "SUCCESS|Completed Using Callback",
            "error_code": "E000",
            "addedon": "2024-11-14 16:06:40",
            "payment_source": "express",
            "card_type": null,
            "error_Message": "NO ERROR",
            "net_amount_debit": 2.00,
            "disc": "0.00",
            "mode": "UPI",
            "PG_TYPE": "UPI-PG",
            "card_no": "",
            "status": "success",
            "unmappedstatus": "captured",
            "Merchant_UTR": null,
            "Settled_At": "0000-00-00 00:00:00",
            "App_Name": "GooglePay",
            "card_token": null,
            "field4": null,
            "offerAvailed": null,
            "cart_details": {
                "id": "2446425",
                "payu_id": "21564143078",
                "total_items": "1",
                "total_cart_amount": "2.00",
                "offer_applied": null,
                "offer_availed": null,
                "offer_auto_apply": "0",
                "instant_discount": "0.00",
                "cashback_discount": "0.00",
                "total_discount": "0.00",
                "net_cart_amount": "2.00",
                "created_at": "2024-11-14 16:06:40",
                "updated_at": "2024-11-14 16:06:40",
                "sku_details": [
                    {
                        "id": "3468748",
                        "cart_id": "2446425",
                        "payu_id": "21564143078",
                        "mid": "2",
                        "sku_id": "Sample Sofa Design-Red",
                        "sku_name": "Sample Sofa Designtest?=!name",
                        "amount_per_sku": "2.00",
                        "quantity": "1",
                        "amount_before_discount": "2.00",
                        "discount": "0.00",
                        "amount_after_discount": "2.00",
                        "offer_applied": null,
                        "offer_availed": null,
                        "offer_status": null,
                        "offer_type": null,
                        "offer_auto_apply": "0",
                        "is_nce": "0",
                        "failure_reason": null,
                        "created_at": "2024-11-14 16:06:40",
                        "updated_at": "2024-11-14 16:06:40",
                        "offer_title": null,
                        "offer_description": null,
                        "instant_discount": null,
                        "cashback_discount": null,
                        "offers_raw_response": null,
                        "raw_response": null
                    }
                ]
            }
        }
    }
}
  • Offer availed at Transaction level
{
    "status": 1,
    "msg": "1 out of 1 Transactions Fetched Successfully",
    "transaction_details": {
        "1725950872187": {
            "mihpayid": "20911942990",
            "request_id": null,
            "bank_ref_num": null,
            "amt": "9900.00",
            "transaction_amount": "10000.00",
            "txnid": "1725950872187",
            "additional_charges": "0.00",
            "productinfo": "Macbook Pro",
            "firstname": "Abc",
            "bankcode": "MAST",
            "udf1": "udf1",
            "udf2": "udf2",
            "udf3": "udf3",
            "udf4": "udf4",
            "udf5": "udf5",
            "field2": null,
            "field9": "You have reached credit card load limit. Please use other payment options to continue.",
            "error_code": "E4936",
            "addedon": "2024-09-10 12:18:20",
            "payment_source": "payu",
            "card_type": "MAST",
            "error_Message": "Bank was unable to authenticate.",
            "net_amount_debit": "0.00",
            "disc": "100.00",
            "mode": "DC",
            "PG_TYPE": "DC-PG",
            "card_no": "XXXXXXXXXXXX9528",
            "status": "failure",
            "unmappedstatus": "failed",
            "Merchant_UTR": null,
            "Settled_At": null,
            "cardhash": "31056eb2112b68cdc90896f1953ca26605bb525249096172c178881bcd45ac93",
            "name_on_card": null,
            "card_token": null,
            "field4": null,
            "offerApplied": "LoadTest1@m3phN7YptAA6",
            "offerAvailed": "LoadTest1@m3phN7YptAA6",
            "transactionOffer": "{"offer_data":[{"offer_key":"LoadTest1@m3phN7YptAA6","discount":100,"offer_type":"INSTANT","isNoCost":false,"flag_to_fail":false,"status":"SUCCESS","failure_code":null,"failure_reason":"Offer Applied Successfully","offer_description":"Load Test 1","offer_title":"Load Test 1","record_type":"OFFER","parent_offer_key":null,"offer_category":null,"isDpEmi":false}],"discount_data":{"total_discount":100,"cashback_discount":0,"instant_discount":100,"total_nce_discount":0,"instant_nce_discount":0,"cashback_nce_discount":0,"gstSubventedViaOffer":false,"downPaymentAmount":0}}",
            "offerType": "instant",
            "offerLevel": "TRANSACTION_LEVEL"
        }
    }
}

Failure Responses

  • If txnID is not found, the response is similar to the following:
{
"status":0,"msg":"0 out of 1 Transactions Fetched

Successfully","transaction_details":{"IhfgcZnXR4o4nB":{"mihpayid":"Not Found","status":"Not Found"}}
}
Response parameters

Parameter

Description

Example

status

This parameter returns the status of web service call. The status can be any of the following:

  • 0 - If web service call failed.
  • 1 - If web service call succeeded

0

msg

This parameter returns the reason string.

For example, any of the following messages are displayed:

  • Parameter missing
  • Token is empty
  • Amount is empty
  • Transaction not exists

transaction_details

This parameter contains the response in a JSON format. For more information refer to JSON fields description for transaction_details parameter .

request_id

PayU Request ID for a request in a Transaction. For example, a transaction can have a refund request.

7800456

bank_ref_num

This parameter returns the bank reference number. If the bank provides after a successful action.

204519474956

To learn more about the possible error codes and their description, refer to Error Codes.

Check Net Banking health

You can check whether the Net Banking server is up and running using the getNetBankingStatus API. If the Net Banking server is down for a bank, you can inform your customers that the Net Banking server is down. For more information on the getNetBankingStatus API, refer to getNetBankingStatus.

Recommended integrations for Net Banking


Ask AI Beta

Hi! I am an AI Assistant. Ask me about PayU and get help with your integration.
Responses are generated by AI, may contain some mistakes.

EXAMPLE QUESTIONS