Developer API Documentation

Integrate instant UPI payment collection, QR codes, cards, and wallets directly into your web or mobile application with our REST APIs.

API Base URL https://bharatsetu.xyz/

1. Authentication

Every API request requires a valid user_token (API Key) associated with your merchant account. You can generate and view your API Key from your Merchant Dashboard > API Details page.

Keep your API Key confidential! Do not expose your user_token in client-side HTML/JavaScript files. Always make API calls from your secure backend server.

2. Create Order API

Use this endpoint to generate a new transaction order and obtain a secure payment_url for your customer to complete the payment via UPI, GPay, PhonePe, Paytm, or Cards.

POST https://bharatsetu.xyz/api/create-order

Headers: Content-Type: application/x-www-form-urlencoded

Request Parameters (Form Data)
Parameter Type Required Description
user_token string Required Your merchant API key generated from dashboard.
order_id string Required Unique alphanumeric order identifier from your site (e.g., ORD987654).
amount numeric Required Order amount in INR (e.g. 100 or 499.50). Min ₹1.
customer_mobile string Required 10-digit mobile number of customer.
redirect_url string Required Full HTTPS URL where customer is redirected after completing payment.
remark1 string Optional Custom metadata / note (e.g., customer name or item name).
remark2 string Optional Additional custom note or internal reference.
Response Examples
{
  "status": "SUCCESS",
  "message": "ORDER_CREATED",
  "result": {
    "orderId": "ORD987654",
    "payment_url": "https://bharatsetu.xyz/payment/PAY_874125896"
  }
}

3. Check Order Status API

Query the status of any past transaction by passing your merchant order_id and user_token.

POST https://bharatsetu.xyz/api/check-order-status
Request Parameters
Parameter Type Required Description
user_token string Required Your merchant API Key.
order_id string Required The unique order ID passed during order creation.
Success Response Format
JSON Response
{
  "status": "COMPLETED",
  "message": "Transaction Successfully",
  "result": {
    "txnStatus": "COMPLETED",
    "resultInfo": "Transaction Success",
    "orderId": "ORD987654",
    "status": "SUCCESS",
    "amount": "499.00",
    "date": "2026-09-16 11:20:00",
    "utr": "4254525454245"
  }
}

4. Webhook / Callback Integration

Set up a Webhook URL under API Details. Whenever a payment completes, our system sends an instant HTTP POST request with payment details to your server.

POST https://yourdomain.com/webhook-listener.php

Payload delivered via application/x-www-form-urlencoded

Sample PHP Webhook Handler
<?php
// Retrieve POST data sent by payment gateway webhook
$status   = $_POST['status']   ?? ''; // SUCCESS or FAILED
$order_id = $_POST['order_id'] ?? '';
$amount   = $_POST['amount']   ?? '';
$utr      = $_POST['utr']      ?? ''; // Banking UTR Reference Number

if ($status === 'SUCCESS') {
    // 1. Verify transaction status via Check Order API for maximum security
    // 2. Mark order as paid in your database
    // 3. Deliver digital product or service to customer
    echo "WEBHOOK_PROCESSED_SUCCESSFULLY";
} else {
    echo "WEBHOOK_RECEIVED_FAILED_STATUS";
}
?>

5. Code Snippets & Examples

Select your programming language to copy ready-to-use integration code for creating an order.

curl -X POST "https://bharatsetu.xyz/api/create-order" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "user_token=YOUR_API_TOKEN" \
  -d "order_id=ORD_$(date +%s)" \
  -d "amount=100" \
  -d "customer_mobile=9876543210" \
  -d "redirect_url=https://yourwebsite.com/success.php" \
  -d "remark1=Order101"
<?php
$apiUrl = "https://bharatsetu.xyz/api/create-order";

$postData = [
    'user_token'      => 'YOUR_API_TOKEN',
    'order_id'        => 'ORD_' . time(),
    'amount'          => '100',
    'customer_mobile' => '9876543210',
    'redirect_url'    => 'https://yourwebsite.com/success.php',
    'remark1'         => 'Test Payment'
];

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if (isset($result['status']) && $result['status'] === 'SUCCESS') {
    $paymentUrl = $result['result']['payment_url'];
    header("Location: " . $paymentUrl);
    exit();
} else {
    echo "Order Creation Failed: " . ($result['message'] ?? 'Unknown Error');
}
?>
import requests
import time

url = "https://bharatsetu.xyz/api/create-order"

payload = {
    'user_token': 'YOUR_API_TOKEN',
    'order_id': f'ORD_{int(time.time())}',
    'amount': '100',
    'customer_mobile': '9876543210',
    'redirect_url': 'https://yourwebsite.com/success.php',
    'remark1': 'Python Order'
}

response = requests.post(url, data=payload)
data = response.json()

if data.get("status") == "SUCCESS":
    payment_url = data["result"]["payment_url"]
    print("Redirect user to:", payment_url)
else:
    print("Error:", data.get("message"))
const axios = require('axios');
const qs = require('qs');

async function createPaymentOrder() {
  const url = 'https://bharatsetu.xyz/api/create-order';
  const data = qs.stringify({
    user_token: 'YOUR_API_TOKEN',
    order_id: 'ORD_' + Date.now(),
    amount: '100',
    customer_mobile: '9876543210',
    redirect_url: 'https://yourwebsite.com/success.php',
    remark1: 'NodeJS Order'
  });

  try {
    const res = await axios.post(url, data, {
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    });
    if (res.data.status === 'SUCCESS') {
      console.log('Payment Link:', res.data.result.payment_url);
    } else {
      console.error('Error:', res.data.message);
    }
  } catch (err) {
    console.error('Request failed:', err.message);
  }
}

createPaymentOrder();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class CreateOrder {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();
        String formData = "user_token=YOUR_API_TOKEN" +
                "&order_id=ORD_" + System.currentTimeMillis() +
                "&amount=100" +
                "&customer_mobile=9876543210" +
                "&redirect_url=https://yourwebsite.com/success.php";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://bharatsetu.xyz/api/create-order"))
                .header("Content-Type", "application/x-www-form-urlencoded")
                .POST(HttpRequest.BodyPublishers.ofString(formData))
                .build();

        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println("Response: " + response.body());
    }
}

6. Interactive API Tester

Test the Create Order API live right from your browser.

API Response Output
Sending request...

7. Error Codes Reference

Status Message HTTP Code Cause & Resolution
ORDER_ID_ALREADY_EXISTS 400 Bad Request The order_id has already been used for a previous transaction. Generate a unique ID per order.
PLAN_EXPIRED_PLEASE_RENEW 400 Bad Request Your merchant subscription plan has expired. Renew your plan in the Merchant Dashboard.
MERCHANT_NOT_LINKED 400 Bad Request No payment gateway UPI app (Paytm, PhonePe, BharatPe, GPay) is linked to your account. Link a merchant UPI app in settings.
EITHER_ORDER_ID_IS_WRONG_OR_API_KEY_IS_WRONG 400 Bad Request Order ID or API key combination was not found in the transaction log. Verify parameters.
Copied to clipboard!