UPI Omnichannel S2S Integration
This section describes how to integrate UPI for Omnichannel with S2S integration:
Initiate the UPI Omnichannel payment request with required parameters
Monitor and check the real-time status of the UPI transaction
Receive and handle the server-to-server callback response from PayU
Verify the payment status and ensure successful transaction completion
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 payment
Environment
| Test Environment | https://test.payu.in/_payment |
| Production Environment | https://secure.payu.in/_payment |
The Omni Channel API allows you to call the service request using the specific bank codes.
For the complete list of parameters, refer to UPI Collection – S2S.
Mandatory Parameters
| Parameter | Description | Example |
|---|---|---|
| key | String The merchant key is provided by PayU and acts as a unique identifier for a specific merchant account in PayU's database. | Your Test Key |
| txnid | String The transaction ID is the order reference number generated by the merchant to track a particular order. It can be used only once and PayU's system does not accept a duplicate Transaction ID. | s7hhDQVWvbhBdN |
| amount | float It should contain the payment amount of the particular transaction. The amount must be greater than Rs. 8000 for the cardless EMI option. | 10.00 |
| productinfo | String It should be a string containing a brief description of the product. | iPhone |
String The email of the customer. | [email protected] | |
| phone | String The phone number of the customer. | 9876543210 |
| surl | String Success URL – PayU will redirect the final response here if the transaction is successful. | https://apiplayground-response.herokuapp.com/ |
| furl | String Failure URL – PayU will redirect the final response here if the transaction fails. | https://apiplayground-response.herokuapp.com/ |
| hash | String It is the hash calculated by the merchant. SHA-512(key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5||||||Salt) | — |
| pg | String The payment gateway. For UPI Omnichannel, use UPI. | UPI |
| bankcode | String The bank code identifying the payment option. Contact PayU Support for the list of bank codes. | UPITEZ |
| vpa | String The Virtual Payment Address of the customer. | test@okhdfcbank |
| s2s_client_ip | String The IP address of the client device initiating the transaction. | 10.200.12.12 |
| s2s_device_info | String Device information/user-agent string of the client. | Mozilla/5.0 |
Optional Parameters
| Parameter | Description | Example |
|---|---|---|
| api_version | String The API version for this API. | 1 |
| address1 | String The first line of the billing address. | — |
| address2 | String The second line of the billing address. | — |
| city | String The city where the customer resides. | — |
| state | String The state where the customer resides. | — |
| country | String The country where the customer resides. | — |
| zipcode | String Billing address zip code. Mandatory for cardless EMI option. Character Limit: 20. | — |
| udf1–udf5 | String User Defined Fields used to store any information corresponding to a particular transaction. | — |
| notifyurl | String The URL where PayU sends the server-to-server callback response. | https://yourwebsite.com/notify |
curl --location 'https://test.payu.in/_payment' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'key=YOUR_MERCHANT_KEY' \
--data-urlencode 'txnid=TXN_12345' \
--data-urlencode 'amount=10.00' \
--data-urlencode 'productinfo=iPhone' \
--data-urlencode 'firstname=Ashish' \
--data-urlencode '[email protected]' \
--data-urlencode 'phone=9876543210' \
--data-urlencode 'pg=UPI' \
--data-urlencode 'bankcode=UPITEZ' \
--data-urlencode 'vpa=test@okhdfcbank' \
--data-urlencode 'surl=https://apiplayground-response.herokuapp.com/' \
--data-urlencode 'furl=https://apiplayground-response.herokuapp.com/' \
--data-urlencode 's2s_client_ip=10.200.12.12' \
--data-urlencode 's2s_device_info=Mozilla/5.0' \
--data-urlencode 'hash=YOUR_HASH_VALUE'import requests
url = "https://test.payu.in/_payment"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = {
"key": "YOUR_MERCHANT_KEY",
"txnid": "TXN_12345",
"amount": "10.00",
"productinfo": "iPhone",
"firstname": "Ashish",
"email": "[email protected]",
"phone": "9876543210",
"pg": "UPI",
"bankcode": "UPITEZ",
"vpa": "test@okhdfcbank",
"surl": "https://apiplayground-response.herokuapp.com/",
"furl": "https://apiplayground-response.herokuapp.com/",
"s2s_client_ip": "10.200.12.12",
"s2s_device_info": "Mozilla/5.0",
"hash": "YOUR_HASH_VALUE"
}
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.text)<?php
$url = "https://test.payu.in/_payment";
$data = http_build_query([
"key" => "YOUR_MERCHANT_KEY",
"txnid" => "TXN_12345",
"amount" => "10.00",
"productinfo" => "iPhone",
"firstname" => "Ashish",
"email" => "[email protected]",
"phone" => "9876543210",
"pg" => "UPI",
"bankcode" => "UPITEZ",
"vpa" => "test@okhdfcbank",
"surl" => "https://apiplayground-response.herokuapp.com/",
"furl" => "https://apiplayground-response.herokuapp.com/",
"s2s_client_ip" => "10.200.12.12",
"s2s_device_info"=> "Mozilla/5.0",
"hash" => "YOUR_HASH_VALUE"
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/x-www-form-urlencoded"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo "Status: " . curl_getinfo($ch, CURLINFO_HTTP_CODE) . "\n";
echo $response;
curl_close($ch);
?>import java.net.URI;
import java.net.URLEncoder;
import java.net.http.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class UpiOmnichannelS2S {
public static void main(String[] args) throws Exception {
Map<String, String> params = new LinkedHashMap<>();
params.put("key","YOUR_MERCHANT_KEY"); params.put("txnid","TXN_12345");
params.put("amount","10.00"); params.put("productinfo","iPhone");
params.put("firstname","Ashish"); params.put("email","[email protected]");
params.put("phone","9876543210"); params.put("pg","UPI");
params.put("bankcode","UPITEZ"); params.put("vpa","test@okhdfcbank");
params.put("surl","https://apiplayground-response.herokuapp.com/");
params.put("furl","https://apiplayground-response.herokuapp.com/");
params.put("s2s_client_ip","10.200.12.12"); params.put("s2s_device_info","Mozilla/5.0");
params.put("hash","YOUR_HASH_VALUE");
StringJoiner sj = new StringJoiner("&");
for (Map.Entry<String,String> e : params.entrySet())
sj.add(URLEncoder.encode(e.getKey(),StandardCharsets.UTF_8)+"="+URLEncoder.encode(e.getValue(),StandardCharsets.UTF_8));
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://test.payu.in/_payment"))
.header("Content-Type","application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString(sj.toString())).build();
HttpResponse<String> response = client.send(request,HttpResponse.BodyHandlers.ofString());
System.out.println("Status: "+response.statusCode()); System.out.println(response.body());
}
}using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
class UpiOmnichannelS2S {
static async Task Main() {
using var client = new HttpClient();
var data = new FormUrlEncodedContent(new Dictionary<string,string> {
{"key","YOUR_MERCHANT_KEY"},{"txnid","TXN_12345"},{"amount","10.00"},
{"productinfo","iPhone"},{"firstname","Ashish"},{"email","[email protected]"},
{"phone","9876543210"},{"pg","UPI"},{"bankcode","UPITEZ"},
{"vpa","test@okhdfcbank"},
{"surl","https://apiplayground-response.herokuapp.com/"},
{"furl","https://apiplayground-response.herokuapp.com/"},
{"s2s_client_ip","10.200.12.12"},{"s2s_device_info","Mozilla/5.0"},
{"hash","YOUR_HASH_VALUE"}
});
var response = await client.PostAsync("https://test.payu.in/_payment", data);
Console.WriteLine("Status: "+(int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}Step 2: Check UPI Transaction Status
After initiating the payment, check the UPI transaction status using the getNetBankingStatus API or polling mechanism. For more information, refer to UPI Collection – S2S.
Step 3: PayU Sends S2S Callback Response
S2S Callback Details
The server to server response would be sent by PayU on a pre-set URL, which has to be provided by the merchant. PayU will configure it at the back-end for the merchant.
This response would be sent in key/value pair separated by the ampersand (&) character.
Sample response
unmappedstatus=success&phone=9999999999&txnid=FCDA1R100870163781&status=success&mode=DC&amount=800.00&mihpayid=175477248Whitelisting required
Whitelisting is required at both merchant's and PayU's end to establish this connection.
- You need to white list the following IP address on your Firewall:
- 180.179.174.1
- 180.179.174.2
- PayU will white list merchant server side IP address that you have provided to PayU.
Step 4. 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.
Know how to manage Webhooks for Payments.
Environment
| Test Environment | https://test.payu.in/merchant/postservice.php?form=2 |
| Production Environment | https://info.payu.in/merchant/postservice.php?form=2 |
Note: The hash logic for Verify Payment API is:
sha512(key|command|var1|salt) sha512
Sample request
curl --request POST
--url 'https://test.payu.in/merchant/postservice?form=2'
--header 'Content-Type: application/x-www-form-urlencoded'
--data key=JPM7Fg
--data command=verify_payment
--data var1=IhfgcZnXR4o4nB
--data hash=a0ae79fdd66c875af6e9b21c4a67f1822deb00f2df5e9f0b1948f3222f536a9bf741b24efbb1874ca0f84f76b036e6c0d641581d0100f7abe4aeed2f3264f5c9
Sample response
If credit card payment is made, 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"
}
}
}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 |
| 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
