This section describes the request and response parameters with sample request and response for UPI One-Time mandate Intent and Collect flow. For more information on integration, refer to Merchant Hosted Integration - UPI OTM.
Note: Currently, PayU supports UPI One-Time Mandate only for the Seamless integration.
Request Parameters
Environment
Test Environment | https://test.payu.in/_payment |
Production Environment | https://secure.payu.in/_payment |
Parameter | Description | Example |
---|---|---|
key
|
| Your Test Key |
txnid
|
| fd3e847h2 |
amount
|
| 1000 |
productinfo
|
| Time Magazine Subscription |
firstname
|
| Ashish |
email
|
| |
phone
|
This information is helpful when it comes to issues related to fraud detection and chargebacks. Hence, it is must to provide the correct information Also, MIS reporting is shared with few issuing banks where email and mobile number is used to keep track of users using SI transactions. Character limit: 50 | 9843176540 |
surl
| surL is the acronym for Success URL. This parameter must contain the URL on which PayU will redirect the final response if the transaction is successful. | |
furl
| furl is the acronym for for Failure URL. This parameter must contain the URL on which PayU will redirect the final response if the transaction is failed. | |
pg
| It defines the payment category for which you wish to perform UPI One-Time Mandate. For UPI, pg= UPI | UPI |
bankcode
| It defines the bank with which you wish to perform UPI using the bank code. Use UPI or INTENT according to the use case. |
|
vpa
| This parameter contains the customer’s VPA handle. For the list UPI handles supported, refer to UPI Handles The merchant is advised to check the validity of the VPA through using the VPA Validation API. PayU extends support for the same if required. For more information on using VPA Validation API, refer to Validate VPA API. | abc@payu |
txn_s2s_flow
| This parameter must be passed with the values as 4 for UPI Intent. | 4 |
pre_authorize
| This parameter is set to1 to pre-authorize payment. | |
si_Details | This parameter contains the following information in JSON format:
| {"paymentStartDate":"2024-07-24","paymentEndDate":"2024-07-28"} |
hash
| Hash is a crucial parameter used to ensure that any date is not tampered while redirecting customer from the merchant website to PayU’s payment interface while registration transactions. It is SHA512 hash generated by encrypting values of merchant key, txnid, amount, productinfo, firstname, email, udf and si_details by merchant salt. In the case of registration transaction, the formula is used to calculate this hash is similar to the following:
|
Sample request
Intent Flow
curl --request POST
--url https://test.payu.in/_payment
--header 'accept: text/plain'
--header 'content-type: application/x-www-form-urlencoded'
--data key=JPM7Fg
--data pg=UPI
--data bankcode=INTENT
--data txn_s2s_flow=4
--data txnid=aso6787
--data siDetails="{"paymentStartDate": "2019-09-01","paymentEndDate": "2019-12-01"}"
--data pre_authorize=1 \
--data amount=100.00
--data productinfo=iPhone
--data firstname=Ashish
--data [email protected]
--data phone=9876543210
--data surl=https://apiplayground-response.herokuapp.com/
--data furl=https://apiplayground-response.herokuapp.com/
--data hash=8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b
# Python implementation using requests library
import requests
# Define the URL and headers
url = "https://test.payu.in/_payment"
headers = {
"accept": "text/plain",
"content-type": "application/x-www-form-urlencoded"
}
# Define the form data
form_data = {
"key": "JPM7Fg",
"pg": "UPI",
"bankcode": "INTENT",
"txn_s2s_flow": "4",
"txnid": "aso6787",
"siDetails": "{\"paymentStartDate\": \"2019-09-01\",\"paymentEndDate\": \"2019-12-01\"}",
"pre_authorize": "1",
"amount": "100.00",
"productinfo": "iPhone",
"firstname": "Ashish",
"email": "[email protected]",
"phone": "9876543210",
"surl": "https://apiplayground-response.herokuapp.com/",
"furl": "https://apiplayground-response.herokuapp.com/",
"hash": "8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b"
}
# Make the POST request
try:
response = requests.post(url, headers=headers, data=form_data)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
// Java implementation using OkHttp library
import okhttp3.*;
import java.io.IOException;
public class PayUClient {
private static final OkHttpClient client = new OkHttpClient();
public static void main(String[] args) {
// Define the URL
String url = "https://test.payu.in/_payment";
// Create form body
RequestBody formBody = new FormBody.Builder()
.add("key", "JPM7Fg")
.add("pg", "UPI")
.add("bankcode", "INTENT")
.add("txn_s2s_flow", "4")
.add("txnid", "aso6787")
.add("siDetails", "{\"paymentStartDate\": \"2019-09-01\",\"paymentEndDate\": \"2019-12-01\"}")
.add("pre_authorize", "1")
.add("amount", "100.00")
.add("productinfo", "iPhone")
.add("firstname", "Ashish")
.add("email", "[email protected]")
.add("phone", "9876543210")
.add("surl", "https://apiplayground-response.herokuapp.com/")
.add("furl", "https://apiplayground-response.herokuapp.com/")
.add("hash", "8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b")
.build();
// Create request
Request request = new Request.Builder()
.url(url)
.addHeader("accept", "text/plain")
.addHeader("content-type", "application/x-www-form-urlencoded")
.post(formBody)
.build();
try {
// Execute the request
Response response = client.newCall(request).execute();
System.out.println("Status Code: " + response.code());
System.out.println("Response: " + response.body().string());
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
// Define the URL
$url = "https://test.payu.in/_payment";
// Define the form data
$formData = array(
'key' => 'JPM7Fg',
'pg' => 'UPI',
'bankcode' => 'INTENT',
'txn_s2s_flow' => '4',
'txnid' => 'aso6787',
'siDetails' => '{"paymentStartDate": "2019-09-01","paymentEndDate": "2019-12-01"}',
'pre_authorize' => '1',
'amount' => '100.00',
'productinfo' => 'iPhone',
'firstname' => 'Ashish',
'email' => '[email protected]',
'phone' => '9876543210',
'surl' => 'https://apiplayground-response.herokuapp.com/',
'furl' => 'https://apiplayground-response.herokuapp.com/',
'hash' => '8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b'
);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($formData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'accept: text/plain',
'content-type: application/x-www-form-urlencoded'
));
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "Status Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
}
// Close cURL handle
curl_close($ch);
?>
// C# implementation using HttpClient
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
public class PayUClient
{
private static readonly HttpClient client = new HttpClient();
public static async Task Main(string[] args)
{
// Define the URL
string url = "https://test.payu.in/_payment";
// Set headers
client.DefaultRequestHeaders.Add("accept", "text/plain");
// Define the form data
var formData = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("key", "JPM7Fg"),
new KeyValuePair<string, string>("pg", "UPI"),
new KeyValuePair<string, string>("bankcode", "INTENT"),
new KeyValuePair<string, string>("txn_s2s_flow", "4"),
new KeyValuePair<string, string>("txnid", "aso6787"),
new KeyValuePair<string, string>("siDetails", "{\"paymentStartDate\": \"2019-09-01\",\"paymentEndDate\": \"2019-12-01\"}"),
new KeyValuePair<string, string>("pre_authorize", "1"),
new KeyValuePair<string, string>("amount", "100.00"),
new KeyValuePair<string, string>("productinfo", "iPhone"),
new KeyValuePair<string, string>("firstname", "Ashish"),
new KeyValuePair<string, string>("email", "[email protected]"),
new KeyValuePair<string, string>("phone", "9876543210"),
new KeyValuePair<string, string>("surl", "https://apiplayground-response.herokuapp.com/"),
new KeyValuePair<string, string>("furl", "https://apiplayground-response.herokuapp.com/"),
new KeyValuePair<string, string>("hash", "8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b")
});
try
{
// Make the POST request
HttpResponseMessage response = await client.PostAsync(url, formData);
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Status Code: {response.StatusCode}");
Console.WriteLine($"Response: {responseContent}");
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
Collect Flow
curl --request POST
--url https://test.payu.in/_payment
--header 'accept: text/plain'
--header 'content-type: application/x-www-form-urlencoded'
--data key=JPM7Fg
--data pg=UPI
--data bankcode=UPI
--data vpa=anything@payu
--data txn_s2s_flow=4
--data txnid=aso6787
--data siDetails="{"paymentStartDate": "2019-09-01","paymentEndDate": "2019-12-01"}"
--data pre_authorize=1 \
--data amount=100.00
--data productinfo=iPhone
--data firstname=Ashish
--data [email protected]
--data phone=9876543210
--data surl=https://apiplayground-response.herokuapp.com/
--data furl=https://apiplayground-response.herokuapp.com/
--data hash=8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b
<?php
// PHP implementation using cURL
// Define the URL
$url = "https://test.payu.in/_payment";
// Define the form data
$formData = array(
'key' => 'JPM7Fg',
'pg' => 'UPI',
'bankcode' => 'UPI',
'vpa' => 'anything@payu',
'txn_s2s_flow' => '4',
'txnid' => 'aso6787',
'siDetails' => '{"paymentStartDate": "2019-09-01","paymentEndDate": "2019-12-01"}',
'pre_authorize' => '1',
'amount' => '100.00',
'productinfo' => 'iPhone',
'firstname' => 'Ashish',
'email' => '[email protected]',
'phone' => '9876543210',
'surl' => 'https://apiplayground-response.herokuapp.com/',
'furl' => 'https://apiplayground-response.herokuapp.com/',
'hash' => '8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b'
);
// Initialize cURL
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($formData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'accept: text/plain',
'content-type: application/x-www-form-urlencoded'
));
// Execute the request
$response = curl_exec($ch);
// Check for errors
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "Status Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
}
// Close cURL handle
curl_close($ch);
?>
// Java implementation using OkHttp library
import okhttp3.*;
import java.io.IOException;
public class PayUClient {
private static final OkHttpClient client = new OkHttpClient();
public static void main(String[] args) {
// Define the URL
String url = "https://test.payu.in/_payment";
// Create form body
RequestBody formBody = new FormBody.Builder()
.add("key", "JPM7Fg")
.add("pg", "UPI")
.add("bankcode", "UPI")
.add("vpa", "anything@payu")
.add("txn_s2s_flow", "4")
.add("txnid", "aso6787")
.add("siDetails", "{\"paymentStartDate\": \"2019-09-01\",\"paymentEndDate\": \"2019-12-01\"}")
.add("pre_authorize", "1")
.add("amount", "100.00")
.add("productinfo", "iPhone")
.add("firstname", "Ashish")
.add("email", "[email protected]")
.add("phone", "9876543210")
.add("surl", "https://apiplayground-response.herokuapp.com/")
.add("furl", "https://apiplayground-response.herokuapp.com/")
.add("hash", "8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b")
.build();
// Create request
Request request = new Request.Builder()
.url(url)
.addHeader("accept", "text/plain")
.addHeader("content-type", "application/x-www-form-urlencoded")
.post(formBody)
.build();
try {
// Execute the request
Response response = client.newCall(request).execute();
System.out.println("Status Code: " + response.code());
System.out.println("Response: " + response.body().string());
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
// C# implementation using HttpClient
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
public class PayUClient
{
private static readonly HttpClient client = new HttpClient();
public static async Task Main(string[] args)
{
// Define the URL
string url = "https://test.payu.in/_payment";
// Set headers
client.DefaultRequestHeaders.Add("accept", "text/plain");
// Define the form data
var formData = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("key", "JPM7Fg"),
new KeyValuePair<string, string>("pg", "UPI"),
new KeyValuePair<string, string>("bankcode", "UPI"),
new KeyValuePair<string, string>("vpa", "anything@payu"),
new KeyValuePair<string, string>("txn_s2s_flow", "4"),
new KeyValuePair<string, string>("txnid", "aso6787"),
new KeyValuePair<string, string>("siDetails", "{\"paymentStartDate\": \"2019-09-01\",\"paymentEndDate\": \"2019-12-01\"}"),
new KeyValuePair<string, string>("pre_authorize", "1"),
new KeyValuePair<string, string>("amount", "100.00"),
new KeyValuePair<string, string>("productinfo", "iPhone"),
new KeyValuePair<string, string>("firstname", "Ashish"),
new KeyValuePair<string, string>("email", "[email protected]"),
new KeyValuePair<string, string>("phone", "9876543210"),
new KeyValuePair<string, string>("surl", "https://apiplayground-response.herokuapp.com/"),
new KeyValuePair<string, string>("furl", "https://apiplayground-response.herokuapp.com/"),
new KeyValuePair<string, string>("hash", "8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b")
});
try
{
// Make the POST request
HttpResponseMessage response = await client.PostAsync(url, formData);
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Status Code: {response.StatusCode}");
Console.WriteLine($"Response: {responseContent}");
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
# Python implementation using requests library
import requests
# Define the URL and headers
url = "https://test.payu.in/_payment"
headers = {
"accept": "text/plain",
"content-type": "application/x-www-form-urlencoded"
}
# Define the form data
form_data = {
"key": "JPM7Fg",
"pg": "UPI",
"bankcode": "UPI",
"vpa": "anything@payu",
"txn_s2s_flow": "4",
"txnid": "aso6787",
"siDetails": "{\"paymentStartDate\": \"2019-09-01\",\"paymentEndDate\": \"2019-12-01\"}",
"pre_authorize": "1",
"amount": "100.00",
"productinfo": "iPhone",
"firstname": "Ashish",
"email": "[email protected]",
"phone": "9876543210",
"surl": "https://apiplayground-response.herokuapp.com/",
"furl": "https://apiplayground-response.herokuapp.com/",
"hash": "8e8de8a3cf2ba999e16c0ffdb63a645074af4ad1aa0a8d66d81555a119c004e1791173fe6199084f256623664b250d3aeb50fc2c4cfc155e729d8811a157c98b"
}
# Make the POST request
try:
response = requests.post(url, headers=headers, data=form_data)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
Sample response
Intent Flow
Success scenario
For Intent, as part of response, Intent URL is returned. Now, merchant needs to use data received in intentURIData parameter, JSON decode the response and use URL to invoke intent at their end
{
"metaData": {
"message": null,
"referenceId": "c5161bae370de1bd4fb886c6c66567a8",
"statusCode": null,
"txnId": "a7440cc636e747b635df",
"txnStatus": "pending",
"unmappedStatus": "pending"
},
"result": {
"paymentId": "99900000000001875",
"merchantName": "Name409208872",
"merchantVpa": "paytmqr@icici",
"amount": "10000.00",
"acsTemplate": "PGh0bWw+PGJvZHk+PGZvcm0gbmFtZT0icGF5bWVudF9wb3N0IiBpZD0icGF5bWVudF9wb3N0IiBhY3Rpb249Imh0dHBzOi8vcHA3OHNlY3VyZS5wYXl1LmluLzY1OWFjNWRhNWUyZjlmNzM1NzhkZWYwYzVjNDM2MWFmOWJhMGVkYmExYjk3NDg2Mjg3ZDI2MzBjZDg1YmU3NWEvaW50ZW50U2VhbWxlc3NIYW5kbGVyLnBocCIgbWV0aG9kPSJwb3N0Ij48aW5..."
},
"otpPostUrl": "https://pp78secure.payu.in/ResponseHandler.php"
}
}
Failure scenario
For Intent, as part of response, Intent URL is returned. Now merchant needs to use data received in intentURIData parameter, JSON decode the response and use URL to invoke intent at their end
After the transaction is authorised by the customer, PayU will receive confirmation. Same will be passed to the merchant as webhook
{
"metaData": {
"message": "Transaction failed due to invalid params shared by the merchant",
"referenceId": "dde7096af9db932a9fd09b9b4383d8be",
"statusCode": "E1101",
"txnId": "0c4931ddee7a4f69227f",
"txnStatus": "failed",
"intentURIData": "upi://mandate?pa=payu24@icici&pn=Payu&tr=EZM2024042211452400151942&am=10000.00&cu=INR&orgid=400011&mc=6012&purpose=01&tn=Upi%20Mandate&validitystart=22042024&validityend=21052024&amrule=MAX&Recur=ONETIME&Rev=N&Share=Y&Block=Y&txnType=CREATE&mode=13",
"unmappedStatus": "failure"
},
"result": {}
}
Collect Flow
Success scenario
{
"metaData":{
"message":null,
""referenceId":"c5161bae370de1bd4fb886c6c66567a8",
"statusCode":null,
""txnId":"a7440cc636e747b635df",
""txnStatus":"pending",
""unmappedStatus":"pending"
},
"result":{
"postToBank":{
"useMethodGet":true
},
"issuerUrl":"https://api.payu.in/ public/#/c5161bae370de1bd4fb886c6c66567a8/upiLoader"
}
}
Failure scenarios
{
"metaData":{
"message":"Transaction failed due to invalid params shared by the merchant",
"referenceId":"dde7096af9db932a9fd09b9b4383d8be",
"statusCode":"E1101",
"txnId":"0c4931ddee7a4f69227f",
"txnStatus":"failed",
"unmappedStatus":"failure"
},
"result":{
}
}