xPay Gateway API Reference
Welcome to the xPay Gateway REST API documentation. xPay Gateway provides a lightweight, robust UPI-focused payment gateway engine that detects actual QR payments via Paytm Business API endpoints.
Using our APIs, you can easily create checkout orders, generate dynamic payment landing links, redirect customers, verify transactions instantly, and receive real-time webhook status updates once they finish paying.
Developer Mode Detected
We are currently showing fallback demo keys in code snippets. Log in to your account to automatically populate these docs with your actual merchant credentials.
Authentication
Every request is authenticated with your API key, which you copy from the API Keys page. Send it inside the JSON body as api_key — there is no special header to set.
| Where | Field | Example |
|---|---|---|
| JSON body | api_key | api_xxxxxxxxxxxxxxxxxxxxxxxx |
| Header | Content-Type | application/json |
Keep Your API Key Confidential
Never expose your API key in client-side code, mobile apps, or public repositories. Always call our API from your backend, where the key stays hidden from end users.
Base URL
Every request goes through a single live endpoint — there's no separate test environment to switch between. Every account starts with one active API key, ready to accept real payments as soon as your Paytm Merchant account is connected.
https://xpaygateway.store/api
Create Order
https://xpaygateway.store/api/create-order
Creates a transaction order in our database and returns a unique, secure `payment_url`. Redirect your customer to this URL to trigger the checkout flow.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your merchant API key (see Authentication). |
| amount | float | Yes | The order amount in INR. Must be greater than 0.00. |
| order_id | string | Yes | Your internal unique transaction identifier (e.g. ORD98765). |
| success_url | string | No | Customer is redirected here 5 seconds after a successful payment. |
| failed_url | string | No | Customer is redirected here after a failed payment. |
| timeout_url | string | No | Customer is redirected here when the payment times out (not paid in time). |
| customer_mobile | string | No | Customer's 10-digit mobile number. |
| remark | string | No | Notes about the payment. Use | as a separator if you need several values. |
curl -X POST https://xpaygateway.store/api/create-order \
-H "Content-Type: application/json" \
-d '{
"api_key": "api_xxxxxxxxxxxxxxxxxxxxxxxx",
"amount": "100.00",
"order_id": "ORD_20261206_5587",
"customer_mobile": "9876543210",
"remark": "Order 1042 | Pro plan",
"success_url": "https://yourwebsite.com/success",
"failed_url": "https://yourwebsite.com/failed",
"timeout_url": "https://yourwebsite.com/timeout"
}'
<?php
$payload = [
'api_key' => 'api_xxxxxxxxxxxxxxxxxxxxxxxx',
'amount' => '100.00',
'order_id' => 'ORD_20261206_5587',
'customer_mobile' => '9876543210',
'remark' => 'Order 1042 | Pro plan',
'success_url' => 'https://yourwebsite.com/success',
'failed_url' => 'https://yourwebsite.com/failed',
'timeout_url' => 'https://yourwebsite.com/timeout'
];
$ch = curl_init('https://xpaygateway.store/api/create-order');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json']
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success') {
$checkoutUrl = $data['payment_url'];
// Redirect customer to $checkoutUrl
header("Location: " . $checkoutUrl);
exit;
} else {
echo "Error creating order: " . ($data['message'] ?? 'Unknown error');
}
?>
const fetch = require('node-fetch');
const payload = {
api_key: 'api_xxxxxxxxxxxxxxxxxxxxxxxx',
amount: '100.00',
order_id: 'ORD_20261206_5587',
customer_mobile: '9876543210',
remark: 'Order 1042 | Pro plan',
success_url: 'https://yourwebsite.com/success',
failed_url: 'https://yourwebsite.com/failed',
timeout_url: 'https://yourwebsite.com/timeout'
};
fetch('https://xpaygateway.store/api/create-order', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(json => {
if (json.status === 'success') {
console.log('Redirect URL:', json.payment_url);
} else {
console.error('API Error:', json.message);
}
})
.catch(err => console.error(err));
import requests
payload = {
"api_key": "api_xxxxxxxxxxxxxxxxxxxxxxxx",
"amount": "100.00",
"order_id": "ORD_20261206_5587",
"customer_mobile": "9876543210",
"remark": "Order 1042 | Pro plan",
"success_url": "https://yourwebsite.com/success",
"failed_url": "https://yourwebsite.com/failed",
"timeout_url": "https://yourwebsite.com/timeout"
}
headers = {"Content-Type": "application/json"}
response = requests.post("https://xpaygateway.store/api/create-order", json=payload, headers=headers)
data = response.json()
if data.get("status") == "success":
print("Redirect user to:", data["payment_url"])
else:
print("Error:", data.get("message"))
Success Response (201 Created)
{
"status": "success",
"message": "Order created successfully",
"order_id": "ORD_20261206_5587",
"payment_url": "https://xpaygateway.store/pay/LRd7jTFOV2sFyhMyOBzbJLL1SQzMxe5V"
}
Error Response
{
"status": "error",
"message": "Order ID already exists, Please provide a unique order ID"
}
Check Status
https://xpaygateway.store/api/check-status
Retrieves the details and verification status of a transaction using your unique `order_id` reference.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| api_key | string | Yes | Your merchant API key. |
| order_id | string | Yes | The unique order ID reference you sent during order creation. |
curl -X POST https://xpaygateway.store/api/check-status \
-H "Content-Type: application/json" \
-d '{
"api_key": "api_xxxxxxxxxxxxxxxxxxxxxxxx",
"order_id": "ORD_20261206_5587"
}'
<?php
$payload = [
'api_key' => 'api_xxxxxxxxxxxxxxxxxxxxxxxx',
'order_id' => 'ORD_20261206_5587'
];
$ch = curl_init('https://xpaygateway.store/api/check-status');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json']
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success') {
$paymentStatus = $data['data']['status']; // 'Pending', 'Success' or 'Failed'
echo "Transaction Status: " . $paymentStatus;
} else {
echo "Error checking status: " . ($data['message'] ?? 'Unknown error');
}
?>
const fetch = require('node-fetch');
fetch('https://xpaygateway.store/api/check-status', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ api_key: 'api_xxxxxxxxxxxxxxxxxxxxxxxx', order_id: 'ORD_20261206_5587' })
})
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
Success Response (200 OK)
{
"status": "success",
"message": "Transaction details fetched successfully",
"data": {
"order_id": "ORD_20261206_5587",
"status": "Pending",
"amount": 100,
"create_at": "2026-04-20 17:09:30",
"remark": "Order 1042 | Pro plan",
"utr": "",
"custumer_mobile": "9876543210"
}
}
data.status is one of Pending, Success or Failed. utr is filled once the payment is successful.
Error Response
{
"status": "error",
"message": "Order not found"
}
Webhooks
Webhooks are used to receive real-time updates directly on your server whenever a transaction is completed successfully. Instead of polling our check status API, we will send an asynchronous HTTP POST request to your configured webhook URL.
Set your webhook URL (one URL, no secret needed) and view the last 10 deliveries on your API Keys page.
When is it sent?
A webhook is sent only when a payment succeeds. It is a JSON POST to your URL. Reply with HTTP 200 to acknowledge. No secret key is involved.
Webhook Body
{
"order_id": "ORD_20261206_5587",
"status": "Success",
"amount": "1000.00",
"utr": "44345545555",
"customer_mobile": "9876543210",
"remark": "Order 1042 | Pro plan",
"create_at": "2026-04-20 08:33:55"
}
Sample PHP Webhook Receiver
<?php
$data = json_decode(file_get_contents('php://input'), true);
if (($data['status'] ?? '') === 'Success') {
$orderId = $data['order_id'];
$amount = $data['amount'];
$utr = $data['utr'];
// Optional: confirm with the Check Status API before delivering goods
// 1. Mark the order as Paid in your database
// 2. Deliver goods to the customer
}
http_response_code(200);
echo json_encode(['status' => 'ok']);
?>
Success, Failed & Timeout URLs
When you create an order you can pass three redirect URLs. After the payment finishes the checkout page shows a result sheet and, 5 seconds later, sends the customer to the matching URL:
| Outcome | Field used |
|---|---|
| Payment received | success_url |
| Payment failed | failed_url |
| Not paid in time | timeout_url |
If the URL for an outcome is not set, the customer simply stays on the result sheet. We append the details as query parameters:
https://yourwebsite.com/success?status=success&order_id=ORD_20261206_5587&amount=100.00&utr=615372849102
status is one of success, failed or timeout. utr is only sent on success.
Secure Verification Requirement
Browser redirects can easily be modified by malicious users. Never finalize transactions or deliver digital goods based solely on URL parameters. Always confirm with the Check Status API or wait for the webhook.
Automatic status updates
Even if the customer closes the payment page, a background job re-checks every pending payment every minute and marks it success or failed (timeout) on its own. On success your webhook is called, so you never miss a payment.
PHP Integration Flow
Here is a complete, step-by-step implementation showcasing how to create a payment checkout, redirect the user, and process the callback securely.
<?php
/**
* Step 1: Initialize Payment Order
*/
function initiatePayment($orderId, $amount) {
$apiKey = "api_xxxxxxxxxxxxxxxxxxxxxxxx";
$payload = [
'api_key' => $apiKey,
'amount' => number_format($amount, 2, '.', ''),
'order_id' => $orderId,
'success_url' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?action=callback',
'failed_url' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?action=callback',
'timeout_url' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?action=callback'
];
$ch = curl_init('https://xpaygateway.store/api/create-order');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json']
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success') {
// Redirect customer to xPay Gateway payment card
header("Location: " . $data['payment_url']);
exit;
} else {
die("Payment initiation failed: " . ($data['message'] ?? 'Unknown Error'));
}
}
/**
* Step 2: Handle Browser Redirect Callback
*/
function handleCallback() {
$orderId = $_GET['order_id'] ?? '';
$status = $_GET['status'] ?? '';
if (empty($orderId) || $status !== 'success') {
die("Payment was not successful or was cancelled.");
}
// Now verify status securely on the backend
$apiKey = "api_xxxxxxxxxxxxxxxxxxxxxxxx";
$ch = curl_init('https://xpaygateway.store/api/check-status');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['api_key' => $apiKey, 'order_id' => $orderId]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json']
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success' && $data['data']['status'] === 'Success') {
$amount = $data['data']['amount'];
$utr = $data['data']['utr'];
echo "<h1 style='color:green;'>Payment Successful!</h1>";
echo "<p>Thank you, your order <strong>$orderId</strong> of ₹$amount has been paid successfully.</p>";
echo "<p>UTR Reference: $utr</p>";
} else {
echo "<h1 style='color:red;'>Verification Failed</h1>";
echo "<p>The payment verification returned an unconfirmed status.</p>";
}
}
// Simple Router Trigger
$action = $_GET['action'] ?? '';
if ($action === 'pay') {
$randomOrderId = 'ORD_' . uniqid();
initiatePayment($randomOrderId, 100.00);
} elseif ($action === 'callback') {
handleCallback();
} else {
// Show initiation button
echo "<a href='?action=pay' style='padding:12px 24px; background:#0B1220; color:#fff; text-decoration:none; border-radius:8px; font-family:sans-serif; font-weight:bold;'>Pay ₹100 using xPay Gateway</a>";
}
?>