Dynamic Bharat QR Generation API

The Dynamic QR Generation API is used to generate Dynamic UPI/Bharat QR for the pre-filled amount. This API by default returns the Bharat QR image.

Environment

EnvironmentURL
Production<https://info.payu.in/merchant/postservice.php>

Request parameters

ParameterDescriptionSample value
key
mandatory
string This parameter must include the merchant key that was provided by PayU.
Reference: For more information on how to generate the Key and Salt, refer to any of the following:
Production: Generate Production Merchant Key and Sat.
Test: Generate Test Merchant Key and Salt.
Your Test Key
command
mandatory
string The parameter must contain the name of the web service.generate_dynamic_bharat_qr
hash
mandatory
string This parameter must contain the hash value to be calculated at your end. The string used for calculating the hash is mentioned below:
sha512(key|command|var1|salt)
sha512 is the encryption method used here.
ajh84babvav
var1
mandatory
json This parameter will include a JSON format of the transaction details. For more information, refer to the Fields in var1 Parameter Description.Refer the var1 Sample.

Fields in var1 parameter description

FieldDescriptionExample
transactionId
mandatory
string This must contain the merchant transaction Identifier. This must be unique (after a successful transaction) & alphanumeric special (less than 40 characters & excluding >,<, &, ‘)1234_abcdedf
transactionAmount
mandatory
float This must contain the amount for which QR needs to be generated. This must be greater than or equal to 1.00.1005, 1042.23, 95494.4, 10000.00
merchantVpa
optional
string This must contain the merchant's VPA in which payment will be collected. If not sent, VPA registered against given merchant Key is used.yellowqr.payu@hdfc
expiryTime
optional
numeric This must contain the 
time in seconds for which the QR is active. If empty, merchant level expiry is used. If there is no merchant level value, the global value is used.3600
qrName
merchantVpa
optional
string This field is used to post the merchant's name to be embedded in the QR. If the value is not posted, the merchant’s name registered during the onboarding process will be used.PayU
qrCity
merchantVpa
optional
string This parameter is used to post the merchant's city that will be embedded in the QR. If the value not posted, merchant’s city registered during the onboarding process will be used.Gurgaon
qrPinCode
optional
string This field is used to post the merchant's PIN code to be embedded in the QR. If not sent, merchant’s PIN code registered during the onboarding process will be used.122001
customerName
optional
string This field must contain the customer name.Ravi
customerCity
optional
string This field must contain the customer city.122001
customerPhone
optional
string This field must contain the customer phone number.9833207164
customerEmail
optional
string This field must contain the customer email address.[email protected]
customerAddress
optional
string Customer Address.It can be up to 100 characters. Anything after the first 100 characters will be ignoredPayu, Bestech Business Tower, Gurgaon
udf3 - udf5
optional
string This field contain the user-defined fields such as udf3, udf4 and udf5 can be sent in request to include any transactional information.
qrType
optional
string This field is used to indicate whether BQR or UPI QR need to be generated and can contain any of the following values:
bqr and upi
upi or bqr
outputType
optional
string This field is used to indicate the QR output format and contain any of the following:
base64
string
image format
base64, string, image
gst
optional
string This must contain the applicable GST amount for that transaction. Only applicable in case you want to embed gst specific details in the QR.100.25
cgst
optional
string This is the applicable CFST amount for that transaction. Only applicable in case you want to embed GST specific details.25.45
sgst
optional
string This must contain the SGST amount for that transaction. Only applicable in case you want to embed GST specific details in the QR.25.45
igst
optional
string This must contain the IGST amount for that transaction. Only applicable in case you want to embed GST specific details in the QR.50.9
cess
optional
string This must contain the cess amount for that transaction. Only applicable in case you want to embed gst specific details in the QR.10.2
gstIncentive
optional
string This must contain the GST Incentive amount for that transaction. Only applicable in case you want to embed GST specific details in the QR.10.2
gstPercentage
optional
string This must contain the GST percentage for that transaction. Only applicable in case you want to embed GST specific details in the QR.18
gstIn
optional
string This is the GSTIN of the legal entity of the merchant. Only applicable in case you want to embed GST specific details in the QR.24AAACC1206D1ZM
invoiceName
optional
string This is the name of the invoice for which QR will be used. Only applicable in case you want to embed GST specific details in the QR.Bill
invoiceNo
optional
string This is the invoice number for which QR will be used. Only applicable in case you want to embed GST specific details in the QR.78457637
invoiceDate
optional
string This is the invoice date for which QR will be used. It should always be in GMT format. Only applicable in case you want to embed GST specific details in the QR.2021-05-21T13:21:50+05:30
purpose
optional
string This is the purpose for which QR will be used. This param will have fixed values basis your business type. Please take the value from our integration team.3
refUrl
optional
string This field can be used to share invoice copy or any other transaction related information/documents to customer for their reference.https://payu.in/
category
optional
string This field is mandatory when refUrl is passed. Use 01 for advertisement & 02 for invoice.01 or 02

Var1 sample

The var1 parameter is similar to the following JSON format and description of fields in the JSON is described in the following table:

{
   "transactionId":"DBQR1981",
   "transactionAmount":"1",
   "merchantVpa":"gauravdua1.payu@indus",
   "expiryTime":"3600",
   "qrName":"payu",
   "qrCity":"Gurgaon",
   "qrPinCode":"122001",
   "customerName":"Ravi",
   "customerCity":"Ranchi",
   "customerPinCode":"834001",
   "customerPhoe":"7800078000",
   "customerEmail":"[email protected]",
   "customerAddress":"Ggn",
   "udf3":"deliveryboy1",
   "udf4":"sector14",
   "udf5":"cod",
   "outputType":"string"
}

Sample Request

Dynamic UPI QR

curl --location --request POST 'https://info.payu.in/merchant/postservice.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'command=generate_dynamic_bharat_qr' \
--data-urlencode 'key=vDy3i7' \
--data-urlencode 'hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846' \
--data-urlencode 'var1={"transactionId":"DBQR1981","transactionAmount":"1","merchantVpa":"gauravdua1.payu@indus","expiryTime":"3600","qrName":"payu","qrCity":"Gurgaon","qrPinCode":"122001","customerName":"Ravi","customerCity":"Ranchi","customerPinCode":"834001","customerPhoe":"7800078000","customerEmail":"[email protected]","customerAddress":"Ggn","udf3":"deliveryboy1","udf4":"sector14","udf5":"cod","outputType":"string"}'
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "command=generate_dynamic_bharat_qr&key=vDy3i7&hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846&var1={\"transactionId\":\"DBQR1981\",\"transactionAmount\":\"1\",\"merchantVpa\":\"gauravdua1.payu@indus\",\"expiryTime\":\"3600\",\"qrName\":\"payu\",\"qrCity\":\"Gurgaon\",\"qrPinCode\":\"122001\",\"customerName\":\"Ravi\",\"customerCity\":\"Ranchi\",\"customerPinCode\":\"834001\",\"customerPhoe\":\"7800078000\",\"customerEmail\":\"[email protected]\",\"customerAddress\":\"Ggn\",\"udf3\":\"deliveryboy1\",\"udf4\":\"sector14\",\"udf5\":\"cod\",\"outputType\":\"string\"}");
Request request = new Request.Builder()
  .url("https://info.payu.in/merchant/postservice.php")
  .method("POST", body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();
Response response = client.newCall(request).execute();
import http.client

conn = http.client.HTTPSConnection("info.payu.in")
payload = 'command=generate_dynamic_bharat_qr&key=vDy3i7&hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846&var1=%7B%22transactionId%22%3A%22DBQR1981%22%2C%22transactionAmount%22%3A%221%22%2C%22merchantVpa%22%3A%22gauravdua1.payu%40indus%22%2C%22expiryTime%22%3A%223600%22%2C%22qrName%22%3A%22payu%22%2C%22qrCity%22%3A%22Gurgaon%22%2C%22qrPinCode%22%3A%22122001%22%2C%22customerName%22%3A%22Ravi%22%2C%22customerCity%22%3A%22Ranchi%22%2C%22customerPinCode%22%3A%22834001%22%2C%22customerPhoe%22%3A%227800078000%22%2C%22customerEmail%22%3A%22hello%40payu.in%22%2C%22customerAddress%22%3A%22Ggn%22%2C%22udf3%22%3A%22deliveryboy1%22%2C%22udf4%22%3A%22sector14%22%2C%22udf5%22%3A%22cod%22%2C%22outputType%22%3A%22string%22%7D'
headers = {
  'Content-Type': 'application/x-www-form-urlencoded'
}
conn.request("POST", "/merchant/postservice.php", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://info.payu.in/merchant/postservice.php');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/x-www-form-urlencoded'
));
$request->addPostParameter(array(
  'command' => 'generate_dynamic_bharat_qr',
  'key' => 'vDy3i7',
  'hash' => '87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846',
  'var1' => '{"transactionId":"DBQR1981","transactionAmount":"1","merchantVpa":"gauravdua1.payu@indus","expiryTime":"3600","qrName":"payu","qrCity":"Gurgaon","qrPinCode":"122001","customerName":"Ravi","customerCity":"Ranchi","customerPinCode":"834001","customerPhoe":"7800078000","customerEmail":"[email protected]","customerAddress":"Ggn","udf3":"deliveryboy1","udf4":"sector14","udf5":"cod","outputType":"string"}'
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
require "uri"
require "net/http"

url = URI("https://info.payu.in/merchant/postservice.php")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/x-www-form-urlencoded"
request.body = "command=generate_dynamic_bharat_qr&key=vDy3i7&hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846&var1=%7B%22transactionId%22%3A%22DBQR1981%22%2C%22transactionAmount%22%3A%221%22%2C%22merchantVpa%22%3A%22gauravdua1.payu%40indus%22%2C%22expiryTime%22%3A%223600%22%2C%22qrName%22%3A%22payu%22%2C%22qrCity%22%3A%22Gurgaon%22%2C%22qrPinCode%22%3A%22122001%22%2C%22customerName%22%3A%22Ravi%22%2C%22customerCity%22%3A%22Ranchi%22%2C%22customerPinCode%22%3A%22834001%22%2C%22customerPhoe%22%3A%227800078000%22%2C%22customerEmail%22%3A%22hello%40payu.in%22%2C%22customerAddress%22%3A%22Ggn%22%2C%22udf3%22%3A%22deliveryboy1%22%2C%22udf4%22%3A%22sector14%22%2C%22udf5%22%3A%22cod%22%2C%22outputType%22%3A%22string%22%7D"

response = https.request(request)
puts response.read_body

Dynamic Bharat QR

curl --location --request POST 'https://info.payu.in/merchant/postservice.php' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'command=generate_dynamic_bharat_qr' \
--data-urlencode 'key=J****g' \
--data-urlencode 'hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846' \
--data-urlencode 'var1={"transactionId":"DBQR1981","transactionAmount":"1","merchantVpa":"gauravdua1.payu@indus","expiryTime":"3600","qrName":"payu","qrCity":"Gurgaon","qrPinCode":"122001","customerName":"Ravi","customerCity":"Ranchi","customerPinCode":"834001","customerPhoe":"7800078000","customerEmail":"[email protected]","customerAddress":"Ggn","udf3":"deliveryboy1","udf4":"sector14","udf5":"cod","outputType":"string","qrType":"bqr"}'
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "command=generate_dynamic_bharat_qr&key=J****g&hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846&var1={\"transactionId\":\"DBQR1981\",\"transactionAmount\":\"1\",\"merchantVpa\":\"gauravdua1.payu@indus\",\"expiryTime\":\"3600\",\"qrName\":\"payu\",\"qrCity\":\"Gurgaon\",\"qrPinCode\":\"122001\",\"customerName\":\"Ravi\",\"customerCity\":\"Ranchi\",\"customerPinCode\":\"834001\",\"customerPhoe\":\"7800078000\",\"customerEmail\":\"[email protected]\",\"customerAddress\":\"Ggn\",\"udf3\":\"deliveryboy1\",\"udf4\":\"sector14\",\"udf5\":\"cod\",\"outputType\":\"string\",\"qrType\":\"bqr\"}");
Request request = new Request.Builder()
  .url("https://info.payu.in/merchant/postservice.php")
  .method("POST", body)
  .addHeader("Content-Type", "application/x-www-form-urlencoded")
  .build();
Response response = client.newCall(request).execute();
import http.client

conn = http.client.HTTPSConnection("info.payu.in")
payload = 'command=generate_dynamic_bharat_qr&key=vDy3i7&hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846&var1=%7B%22transactionId%22%3A%22DBQR1981%22%2C%22transactionAmount%22%3A%221%22%2C%22merchantVpa%22%3A%22gauravdua1.payu%40indus%22%2C%22expiryTime%22%3A%223600%22%2C%22qrName%22%3A%22payu%22%2C%22qrCity%22%3A%22Gurgaon%22%2C%22qrPinCode%22%3A%22122001%22%2C%22customerName%22%3A%22Ravi%22%2C%22customerCity%22%3A%22Ranchi%22%2C%22customerPinCode%22%3A%22834001%22%2C%22customerPhoe%22%3A%227800078000%22%2C%22customerEmail%22%3A%22hello%40payu.in%22%2C%22customerAddress%22%3A%22Ggn%22%2C%22udf3%22%3A%22deliveryboy1%22%2C%22udf4%22%3A%22sector14%22%2C%22udf5%22%3A%22cod%22%2C%22outputType%22%3A%22string%22%2C%22qrType%22%3A%22bqr%22%7D'
headers = {
  'Content-Type': 'application/x-www-form-urlencoded'
}
conn.request("POST", "/merchant/postservice.php", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://info.payu.in/merchant/postservice.php');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/x-www-form-urlencoded'
));
$request->addPostParameter(array(
  'command' => 'generate_dynamic_bharat_qr',
  'key' => 'J****g',
  'hash' => '87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846',
  'var1' => '{"transactionId":"DBQR1981","transactionAmount":"1","merchantVpa":"gauravdua1.payu@indus","expiryTime":"3600","qrName":"payu","qrCity":"Gurgaon","qrPinCode":"122001","customerName":"Ravi","customerCity":"Ranchi","customerPinCode":"834001","customerPhoe":"7800078000","customerEmail":"[email protected]","customerAddress":"Ggn","udf3":"deliveryboy1","udf4":"sector14","udf5":"cod","outputType":"string"}'
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
require "uri"
require "net/http"

url = URI("https://info.payu.in/merchant/postservice.php")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/x-www-form-urlencoded"
request.body = "command=generate_dynamic_bharat_qr&key=J****g&hash=87617bd37d7f2d627c5117ce0f1a97839200870c3281764bad542c90fc9684a2e2108257dfebbb32cfc4c2a83aa4b9bfe7761da745b14b3df2525e75a4eb6846&var1=%7B%22transactionId%22%3A%22DBQR1981%22%2C%22transactionAmount%22%3A%221%22%2C%22merchantVpa%22%3A%22gauravdua1.payu%40indus%22%2C%22expiryTime%22%3A%223600%22%2C%22qrName%22%3A%22payu%22%2C%22qrCity%22%3A%22Gurgaon%22%2C%22qrPinCode%22%3A%22122001%22%2C%22customerName%22%3A%22Ravi%22%2C%22customerCity%22%3A%22Ranchi%22%2C%22customerPinCode%22%3A%22834001%22%2C%22customerPhoe%22%3A%227800078000%22%2C%22customerEmail%22%3A%22hello%40payu.in%22%2C%22customerAddress%22%3A%22Ggn%22%2C%22udf3%22%3A%22deliveryboy1%22%2C%22udf4%22%3A%22sector14%22%2C%22udf5%22%3A%22cod%22%2C%22outputType%22%3A%22string%22%2C%22qrType%22%3A%22bqr%22%7D"

response = https.request(request)
puts response.read_body

Response parameters

ParameterDescription
imageImage of the QR code will be returned, either BQR or UPI QR
stringQR String is plain text will be returned in response along with QR ID & VPA associated to the QR, the QR string can be converted into image and used for accepting transactions.
base64Base 64 encoded string will be returned in response along with QR ID & VPA associated to the QR, the encoded string provides a layer of security which can be eventually converted into image and used for accepting transactions

🚧

Callouts

  • The var1 parameter is a JSON. All the sub parameters are to be sent as a JSON in var1. Note that the whole JSON string is to be used in hash generation rule.
  • The gst, cgst, sgst, igst, cess, gstIncentive, gstPercentage, gstIn, invoiceName, invoiceNo and invoiceDate parameters are mandatory parameters when you embed GST related details in QR and this is only applicable for UPI QR and not for Bharat QR.
  • The purpose, refUrl, category and txnNote parameters are relevant for only UPI QR but not Bharat QR.
  • The QrName, qrCity and qrPincode parameters are optional. The following values for these parameters are embedded in the QR when these parameters is empty or not set, merchant details are used as follows:
    • qrName: Merchant’s name registered during the onboarding process.
    • qrCity: Merchant’s city registered during the onboarding process.
    • qrPinCode: Merchant’s pincode registered during the onboarding process.
  • The customer details are optional. If not posted, the default value is null. The following rules are to be followed while sending customer details:
    • Phone number and email address are to be sent in their respective formats.
    • customerAddress can be up to 100 characters. The first 100 characters will be truncated if the value is more than 100 characters for this parameter.
  • The response sent for QR generation request is an image, in case the outputType value is not shared.

Failed responses

For the list of error messages for failed response, refer to ERROR CODES.

Sample response

Dynamic UPI QR

{
  "qrString": "upi://pay?pa=gauravdua1.payu@indus&pn=smsplus&mc=7399&tr=DYQ13845198863&ver=01&mode=15&orgid=000000&qrMedium=06&cu=INR&purpose=02&pinCode=122002&am=1.00&QRexpire=2021-08-20T17:48:19+05:30"
}

Dynamic Bharat QR

{
    "qrString": "000201010211021644038470007469080415522024070007469061661000307000746960825HDFC00006225020001855322626470010A0000005240129yellowqr.payutest.94@hdfcbank27370010A0000005240119STQ9y45z1cv3z5450925204569153033565802IN5910vendorName6010vendorCity610650017262350519STQ9y45z1cv3z545092070870007469630417EF",
}