PayU Hosted Checkout Integration
The following diagram depicts the steps involved in the end-to-end integration process of International payments.
Notes:
- You need to contact your PayU Key Account Manager to enable international payments.
- For the list of supported currencies, Supported Currencies for International Payments.
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
Send the transaction request to PayU and handle the initial response from the payment gateway
Process and validate the detailed response received from PayU after transaction submission
Confirm the payment status and ensure successful transaction completion
Step 1: Make the transaction request to PayU
With the POST REQUEST, the customer will be redirected to the PayU's payment page. The customer now selects the credit card payment option on PayU's page and clicks the Pay Now button. PayU redirects the customer to the chosen payment method. The customer enters an international credit card number, and PayU displays the conversion. For the description of the request and response parameters, refer to Response Parameters section of Collect Payment API - PayU Hosted Checkout.
PayU marks the transaction status based on the response received from the bank. PayU provides the final transaction response string to the merchant through a POST RESPONSE. The parameters in this response are covered in the subsequent sections.
Reference: For a list of card details for testing dynamic currency conversion, refer to Test Cards, UPI ID and Wallets.
Notes:
- For DCC eligible transactions, no changes are required in the existing integration of Query transactions or Refund transactions. In case of refunds, the merchant can initiate refunds in INR (original amount and currency) only. PayU will internally convert the same into the final amount and currency charged to the consumer using the FX rate, which was applied on the date of sale.
- There is no change required in handling the response from PayU as the response parameters are similar to the regular transaction
- 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.
Request parameters
| Parameter | Description | Example |
|---|---|---|
keymandatory | String Merchant key provided by PayU during onboarding. | JP***g |
txnidmandatory | String The transaction ID is a reference number for a specific order that is generated by the merchant. | PQI6MqpYrjEefU |
amountmandatory | String The payment amount for the transaction. | 10.00 |
productinfomandatory | String A brief description of the product. | iPhone |
firstnamemandatory | String The first name of the customer. | PayU User |
emailmandatory | String The email address of the customer. | [email protected] |
phonemandatory | String The phone number of the customer. | 9876543210 |
surlmandatory | String The success URL, which is the page PayU will redirect to if the transaction is successful. | https://apiplayground-response.herokuapp.com/ |
furlmandatory | String The failure URL, which is the page PayU will redirect to if the transaction is failed. | https://apiplayground-response.herokuapp.com |
hashmandatory | String It is the hash calculated by the merchant. The hash calculation logic is:`sha512(key\ | txnid\ |
transactionCurrencyoptional (mandatory for multi-currency merchants) | String The payment currency for the transaction. Merchants initiating multi-currency payments must pass a valid 3-alpha currency code (ISO 4217 code) in this field. For more information, refer to MCC Currency Codes. | INR, USD, AED, OR GBP |
address1optional | 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. | 123 Main Street |
address2optional | String The second line of the billing address. | Apt 4B |
cityoptional | String The city where your customer resides as part of the billing address. | New Delhi |
stateoptional | String The state where your customer resides as part of the billing address. | Delhi |
countryoptional | String The country where your customer resides. | India |
zipcodeoptional | String Billing address zip code is mandatory for the cardless EMI option.Character Limit: 20 | 110001 |
udf1optional | 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. | Custom Data 1 |
udf2optional | 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. | Custom Data 2 |
udf3optional | String User-defined fields (udf) are used to store any information corresponding to a particular transaction. | Custom Data 3 |
udf4optional | String User-defined fields (udf) are used to store any information corresponding to a particular transaction. | Custom Data 4 |
udf5optional | String User-defined fields (udf) are used to store any information corresponding to a particular transaction. | Custom Data 5 |
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" \
-d "txnid=PQI6MqpYrjEefU" \
-d "amount=10.00" \
-d "firstname=PayU User" \
-d "[email protected]" \
-d "phone=9876543210" \
-d "productinfo=iPhone" \
-d "surl=https://apiplayground-response.herokuapp.com/" \
-d "furl=https://apiplayground-response.herokuapp.com/" \
-d "hash=05a397501918ec5c36ae52daa3b3e49b43e986b86940e109d060076e467c3ea7536617df7420e0e6863dced8c5b45f9fff15c13bdf0335512c05f0210b31b072"import requests
url = "https://test.payu.in/_payment"
headers = {
"accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"key": "JP***g",
"txnid": "PQI6MqpYrjEefU",
"amount": "10.00",
"firstname": "PayU User",
"email": "[email protected]",
"phone": "9876543210",
"productinfo": "iPhone",
"surl": "https://apiplayground-response.herokuapp.com/",
"furl": "https://apiplayground-response.herokuapp.com/",
"hash": "05a397501918ec5c36ae52daa3b3e49b43e986b86940e109d060076e467c3ea7536617df7420e0e6863dced8c5b45f9fff15c13bdf0335512c05f0210b31b072"
}
response = requests.post(url, headers=headers, data=data)
print("Status Code:", response.status_code)
print("Response:", response.text)import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class PayUBasicPayment {
public static void main(String[] args) throws IOException, InterruptedException {
String url = "https://test.payu.in/_payment";
Map<String, String> params = new HashMap<>();
params.put("key", "JP***g");
params.put("txnid", "PQI6MqpYrjEefU");
params.put("amount", "10.00");
params.put("firstname", "PayU User");
params.put("email", "[email protected]");
params.put("phone", "9876543210");
params.put("productinfo", "iPhone");
params.put("surl", "https://apiplayground-response.herokuapp.com/");
params.put("furl", "https://apiplayground-response.herokuapp.com/");
params.put("hash", "05a397501918ec5c36ae52daa3b3e49b43e986b86940e109d060076e467c3ea7536617df7420e0e6863dced8c5b45f9fff15c13bdf0335512c05f0210b31b072");
String formData = params.entrySet().stream()
.map(e -> URLEncoder.encode(e.getKey(), StandardCharsets.UTF_8) + "="
+ URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
.collect(Collectors.joining("&"));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("accept", "application/json")
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(formData))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println("Response: " + response.body());
}
}<?php
$url = "https://test.payu.in/_payment";
$data = array(
'key' => 'JP***g',
'txnid' => 'PQI6MqpYrjEefU',
'amount' => '10.00',
'firstname' => 'PayU User',
'email' => '[email protected]',
'phone' => '9876543210',
'productinfo' => 'iPhone',
'surl' => 'https://apiplayground-response.herokuapp.com/',
'furl' => 'https://apiplayground-response.herokuapp.com/',
'hash' => '05a397501918ec5c36ae52daa3b3e49b43e986b86940e109d060076e467c3ea7536617df7420e0e6863dced8c5b45f9fff15c13bdf0335512c05f0210b31b072'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'accept: application/json',
'Content-Type: application/x-www-form-urlencoded'
));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($error) {
echo "cURL Error: " . $error . "\n";
} else {
echo "Status Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
// Parse JSON response if applicable
$jsonResponse = json_decode($response, true);
if ($jsonResponse) {
print_r($jsonResponse);
}
}
?>#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
my $url = "https://test.payu.in/_payment";
my %data = (
key => 'JP***g',
txnid => 'PQI6MqpYrjEefU',
amount => '10.00',
firstname => 'PayU User',
email => '[email protected]',
phone => '9876543210',
productinfo => 'iPhone',
surl => 'https://apiplayground-response.herokuapp.com/',
furl => 'https://apiplayground-response.herokuapp.com/',
hash => '05a397501918ec5c36ae52daa3b3e49b43e986b86940e109d060076e467c3ea7536617df7420e0e6863dced8c5b45f9fff15c13bdf0335512c05f0210b31b072'
);
my $ua = LWP::UserAgent->new;
$ua->timeout(30);
my $response = $ua->post($url,
Content_Type => 'application/x-www-form-urlencoded',
Content => \%data
);
if ($response->is_success) {
print "Status Code: " . $response->code . "\n";
print "Response: " . $response->decoded_content . "\n";
} else {
print "Error: " . $response->status_line . "\n";
print "Response: " . $response->decoded_content . "\n";
}Step 2: Check the response from PayU
Sample response
The formatted response is similar to the following:
Array
(
[mihpayid] => 403993715527769337
[mode] => CC
[status] => success
[unmappedstatus] => captured
[key] => smsplus
[txnid] => 86e836b84be8dc6f7894
[amount] => 10.00
[cardCategory] => domestic
[discount] => 0.00
[net_amount_debit] => 10
[addedon] => 2022-11-25 11:30:36
[productinfo] => Product Info
[firstname] => Payu-Admin
[lastname] =>
[address1] =>
[address2] =>
[city] =>
[state] =>
[country] =>
[zipcode] =>
[email] => [email protected]
[phone] => 1234567890
[udf1] =>
[udf2] =>
[udf3] =>
[udf4] =>
[udf5] =>
[udf6] =>
[udf7] =>
[udf8] =>
[udf9] =>
[udf10] =>
[hash] => df565fdcbdd0172c42bf1ba1429c3f48e7215933574f932f37bb133ec4ac89d93535a1bf7674ec4514ffd238ec36e39524142b8d2415554ac7ced49707ea6940
[field1] =>
[field2] =>
[field3] =>
[field4] =>
[field5] =>
[field6] =>
[field7] =>
[field8] =>
[field9] => Transaction Completed Successfully
[payment_source] => payu
[PG_TYPE] => CC-PG
[bank_ref_num] => e0e4a0ca-e356-412a-8f3a-9d69cede5a04
[bankcode] => MASTCC
[error] => E000
[error_Message] => No Error
[success_at] => 2022-11-25 11:33:41
[cardnum] => XXXXXXXXXXXX1287
[cardhash] => This field is no longer supported in postback params.
)Step 3: Verify the payment
Upon receiving the response, PayU recommends you performing a reconciliation step to validate all transaction details. You can verify your payments using either of the following methods:
Configure the webhooks to monitor the status of payments.
Webhooks enable a server to communicate with another server by sending an HTTP callback or message.
These callbacks are triggered by specific events or instances and operate at the server-to-server (S2S) level.
👉 For more details, refer to Webhooks for Payments.
Updated 7 days ago
