post
https://test.payu.in/merchant/postservice.php
The Get TDR API (get_TDR API) is used to get the Transaction Discount Rate (TDR) value of a transaction with PayU. It is a simple API for which you need to provide the PayU ID of the transaction as input and the TDR value is returned in the output, var1 is Payu id (mihpayid) of the transaction.
Sample request
curl --location 'https://test.payu.in/merchant/postservice?form=2' \
--header 'accept: application/json' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: PHPSESSID=6i6633s3gknq1kvph6dtijoabu; USERTXNINFO=68ed4df291d9b7.27710642' \
--data-urlencode 'key=BmTY3G' \
--data-urlencode 'command=get_TDR' \
--data-urlencode 'var1="25779819010"' \
--data-urlencode 'hash=9ba8c5c14b1d8643053b121ce7beb556b1e81fe7f4685048008bcc9f81a35f2b03f879704c10e0999e84923701219fc507c53a57c5ea8ff033ccd4148fb3366c'import requests
try:
url = "https://test.payu.in/merchant/postservice?form=2"
headers = {
'accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'PHPSESSID=6i6633s3gknq1kvph6dtijoabu; USERTXNINFO=68ed4df291d9b7.27710642'
}
data = {
'key': 'BmTY3G',
'command': 'get_TDR',
'var1': '"25779819010"',
'hash': '9ba8c5c14b1d8643053b121ce7beb556b1e81fe7f4685048008bcc9f81a35f2b03f879704c10e0999e84923701219fc507c53a57c5ea8ff033ccd4148fb3366c'
}
response = requests.post(url, headers=headers, data=data)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
try
{
using var client = new HttpClient();
var url = "https://test.payu.in/merchant/postservice?form=2";
var postData = new List<KeyValuePair<string, string>>
{
new("key", "BmTY3G"),
new("command", "get_TDR"),
new("var1", "\"25779819010\""),
new("hash", "9ba8c5c14b1d8643053b121ce7beb556b1e81fe7f4685048008bcc9f81a35f2b03f879704c10e0999e84923701219fc507c53a57c5ea8ff033ccd4148fb3366c")
};
var content = new FormUrlEncodedContent(postData);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded");
client.DefaultRequestHeaders.Add("accept", "application/json");
client.DefaultRequestHeaders.Add("Cookie", "PHPSESSID=6i6633s3gknq1kvph6dtijoabu; USERTXNINFO=68ed4df291d9b7.27710642");
var response = await client.PostAsync(url, content);
var responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Status Code: {response.StatusCode}");
Console.WriteLine($"Response: {responseContent}");
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}async function makeRequest() {
try {
const url = 'https://test.payu.in/merchant/postservice?form=2';
const postData = new URLSearchParams({
'key': 'BmTY3G',
'command': 'get_TDR',
'var1': '"25779819010"',
'hash': '9ba8c5c14b1d8643053b121ce7beb556b1e81fe7f4685048008bcc9f81a35f2b03f879704c10e0999e84923701219fc507c53a57c5ea8ff033ccd4148fb3366c'
});
const response = await fetch(url, {
method: 'POST',
headers: {
'accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'PHPSESSID=6i6633s3gknq1kvph6dtijoabu; USERTXNINFO=68ed4df291d9b7.27710642'
},
body: postData
});
const responseText = await response.text();
console.log(`Status Code: ${response.status}`);
console.log(`Response: ${responseText}`);
} catch (error) {
console.error('Error:', error);
}
}
makeRequest();import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
public class TDRRequest {
public static void main(String[] args) {
try {
URL url = new URL("https://test.payu.in/merchant/postservice?form=2");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("accept", "application/json");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Cookie", "PHPSESSID=6i6633s3gknq1kvph6dtijoabu; USERTXNINFO=68ed4df291d9b7.27710642");
connection.setDoOutput(true);
String postData = "key=" + URLEncoder.encode("BmTY3G", StandardCharsets.UTF_8) +
"&command=" + URLEncoder.encode("get_TDR", StandardCharsets.UTF_8) +
"&var1=" + URLEncoder.encode("\"25779819010\"", StandardCharsets.UTF_8) +
"&hash=" + URLEncoder.encode("9ba8c5c14b1d8643053b121ce7beb556b1e81fe7f4685048008bcc9f81a35f2b03f879704c10e0999e84923701219fc507c53a57c5ea8ff033ccd4148fb3366c", StandardCharsets.UTF_8);
try (OutputStream os = connection.getOutputStream()) {
byte[] input = postData.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int statusCode = connection.getResponseCode();
System.out.println("Status Code: " + statusCode);
BufferedReader reader;
if (statusCode >= 200 && statusCode < 300) {
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println("Response: " + response.toString());
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}<?php
$url = 'https://test.payu.in/merchant/postservice?form=2';
$postData = array(
'key' => 'BmTY3G',
'command' => 'get_TDR',
'var1' => '"25779819010"',
'hash' => '9ba8c5c14b1d8643053b121ce7beb556b1e81fe7f4685048008bcc9f81a35f2b03f879704c10e0999e84923701219fc507c53a57c5ea8ff033ccd4148fb3366c'
);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => http_build_query($postData),
CURLOPT_HTTPHEADER => array(
'accept: application/json',
'Content-Type: application/x-www-form-urlencoded',
'Cookie: PHPSESSID=6i6633s3gknq1kvph6dtijoabu; USERTXNINFO=68ed4df291d9b7.27710642'
)
));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_error($ch)) {
echo 'Error: ' . curl_error($ch) . "\n";
} else {
echo "Status Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
}
curl_close($ch);
?>Sample response
Success scenario
{
"status": 1,
"msg": "Transaction Fetched Successfully",
"TDR_details": {
"TDR": 0
}
}Failure scenario
If mihpayid is not found:
{
"status": 0,
"msg": "Invalid PayU ID"
}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:
|
| TDR_details | This parameter contains the TDR information in JSON format. | {"TDR": 0} |
| TDR_details.TDR | The Transaction Discount Rate value for the given transaction. | 0 |
Request parameters
Sample values
Use the following sample values while trying out the API:
- var1 (Payu ID/mihpayid): 403993715521891555
200