Merchant Hosted Checkout Integration
This section describes how to integrate Dynamic Currency Conversion with Merchant Hosted Checkout Integration (Seamless Integration).
Note: You need to contact your PayU Key Account Manager to enable Dynamic Currency Conversion.
Before you begin:Register for a account with PayU before you start integration. For more information, refer to Register for a Merchant Account.
Steps to Integrate:
Step 1: Check the card BIN
Check if the card number of the customer is international or domestic using the Check is Domestic API. This is to avoid payment failure and validation of the card BIN. For more information, refer to Check is Domestic API under API Reference.
Step 2: Post the parameters to PayU
Make the transaction request with the payment details provided by the customer to PayU. For the description of the request and response parameters, refer to Collect Payments API.
Note: It is recommended to collect the customer’s e-mail address, phone, address, city, state, and country and then post those details along with the payment request with PayU. This will help in checking the risk of the transaction based on these data.
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 --request POST \
--url https://test.payu.in/_payment \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'accept: text/plain' \
--data key=JPM7Fg \
--data surl=https://test-payment-middleware.payu.in/simulatorResponse \
--data furl=https://test-payment-middleware.payu.in/simulatorResponse \
--data pg=CC \
--data bankcode=CC \
--data txnid=sdjkfd133 \
--data amount=100 \
--data productinfo=iPhone \
--data firstname=Raghuram \
--data [email protected] \
--data phone=9876543210 \
--data ccnum=54265X5211123499 \
--data ccvv=123 \
--data ccname=Ashish \
--data ccexpmon=05 \
--data ccexpyr=2033 \
--data hash=6f3a91964acc3788fbefee71f628e8924ca1dc06c6142aadf81b0311cea5e748f771d0d14a5daf6c6585de117b79612fb43a41e2eb3b0db1f0ae12b3f281d9fe
Step 3: Check the 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
Array
(
[mihpayid] => 4***9371***40***25
[mode] => NB
[status] => success
[unmappedstatus] => captured
[key] => JPM7Fg
[txnid] => bvRCCBO4YiGGHE
[amount] => 10.00
[discount] => 0.00
[net_amount_debit] => 10
[addedon] => 2021-09-06 13:59:39
[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] => fa7bb889d25b2a60bcf32316d1c9346589ff3de012dd0c66aa47ec12f1349837163ef8a603bd8b357de610b768f08dc4fb3bb4702d1ca6d9751300667fd763a6
[field1] =>
[field2] =>
[field3] =>
[field4] =>
[field5] =>
[field6] =>
[field7] =>
[field8] =>
[field9] => Transaction Completed Successfully
[payment_source] => payu
[PG_TYPE] => CC-PG
[bank_ref_num] => ae67e632-f4eb-4121-b47b-2d35dce5ec2e
[bankcode] => CC
[error] => E000
[error_Message] => No Error
)
Step 4: Verify the payment
Verify the transaction details using the Verification Payment API. For more information, For API reference, refer to Verify Payment API
Note: The transaction ID that you posted in Step 1 with PayU must be used here.
Environment
Test Environment | https://test.payu.in/merchant/postservice.php?form=2 |
Production Environment | https://info.payu.in/merchant/postservice.php?form=2 |
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
}
}
}
**Failure Responses**
* If txnID is not found, the response is similar to the following:
```plaintext
{
"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 |
msg | This parameter returns the reason string. | For example, any of the following messages are displayed:
|
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.
Updated 3 days ago