GuruPay API Reference
Welcome to the GuruPay REST API documentation. GuruPay 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
All REST API endpoints require secure authentication headers. Your credentials consist of a live public Key and a secret Key which you must generate inside your API Settings page.
Include the keys as custom HTTP headers with every request:
| Header Name | Description | Example |
|---|---|---|
| X-Guru-Key | Your unique Gurukey for authentication. | guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| Content-Type | Payload type indicator (must be JSON). | application/json |
Keep Your Gurukey Confidential
Never share your API Secret or commit it to client-side code repositories. Always trigger requests to our API endpoint servers from your backend server application.
Environments
GuruPay supports two environments. You can toggle your environment mode within your Merchant Developer Console.
- Sandbox Mode (Test): Used during integration testing. Checkout links will load a simulated payment page where you can trigger a successful payment callback instantly without transferring money. Use headers containing your sandbox credentials.
- Production Mode (Live): Process actual transaction amounts. Integrates directly with your connected Paytm Merchant accounts to generate live UPI codes and poll transaction records.
The base endpoint URL remains the same for both test and live environments:
https://gurupaygateway.com/api
Create Order
https://gurupaygateway.com/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 |
|---|---|---|---|
| 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). |
| customer_name | string | Yes | The billing customer's full name. |
| callback_url | string | No | Redirect destination URL once payment completes. |
| description | string | No | Payment remarks shown to the customer (e.g. Pro plan renewal). |
| customer_mobile | string | No | Customer's phone number. |
| is_reusable | boolean | No | Set to true if you want this link to accept multiple customer payments (default: false). |
curl -X POST https://gurupaygateway.com/api/create-order \
-H "X-Guru-Key: guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"amount": "100.00",
"order_id": "ORD_20260911_7948",
"customer_name": "Raushan Kumar",
"description": "Order simulation purchase",
"callback_url": "https://yourwebsite.com/callback.php"
}'
<?php
$payload = [
'amount' => '100.00',
'order_id' => 'ORD_20260911_7948',
'customer_name' => 'Raushan Kumar',
'description' => 'Order simulation purchase',
'callback_url' => 'https://yourwebsite.com/callback.php'
];
$ch = curl_init('https://gurupaygateway.com/api/create-order');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Guru-Key: guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
]
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success') {
$checkoutUrl = $data['data']['payment_url'];
// Redirect customer to $checkoutUrl
header("Location: " . $checkoutUrl);
exit;
} else {
echo "Error creating order: " . ($data['error'] ?? 'Unknown error');
}
?>
const fetch = require('node-fetch');
const payload = {
amount: '100.00',
order_id: 'ORD_20260911_7948',
customer_name: 'Raushan Kumar',
description: 'Order simulation purchase',
callback_url: 'https://yourwebsite.com/callback.php'
};
fetch('https://gurupaygateway.com/api/create-order', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Guru-Key': 'guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(json => {
if (json.status === 'success') {
console.log('Redirect URL:', json.data.payment_url);
} else {
console.error('API Error:', json.error);
}
})
.catch(err => console.error(err));
import requests
payload = {
"amount": "100.00",
"order_id": "ORD_20260911_7948",
"customer_name": "Raushan Kumar",
"description": "Order simulation purchase",
"callback_url": "https://yourwebsite.com/callback.php"
}
headers = {
"Content-Type": "application/json",
"X-Guru-Key": "guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
response = requests.post("https://gurupaygateway.com/api/create-order", json=payload, headers=headers)
data = response.json()
if data.get("status") == "success":
print("Redirect user to:", data["data"]["payment_url"])
else:
print("Error:", data.get("error"))
Success Response Schema (201 Created)
{
"status": "success",
"message": "Order created successfully",
"data": {
"payment_url": "https://gurupaygateway.com/pay/LRd7jTFOV2sFyhMyOBzbJLL1SQzMxe5V",
"order_id": "ORD_20260911_7948",
"token": "LRd7jTFOV2sFyhMyOBzbJLL1SQzMxe5V",
"amount": 100.00,
"currency": "INR",
"customer_name": "Raushan Kumar",
"expires_at": "2026-06-06 11:15:30",
"created_at": "2026-06-05 11:15:30"
}
}
Check Status
https://gurupaygateway.com/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 |
|---|---|---|---|
| order_id | string | Yes | The unique order ID reference you sent during order creation. |
curl -X POST https://gurupaygateway.com/api/check-status \
-H "X-Guru-Key: guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"order_id": "ORD_20260911_7948"
}'
<?php
$payload = [
'order_id' => 'ORD_20260911_7948'
];
$ch = curl_init('https://gurupaygateway.com/api/check-status');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Guru-Key: guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
]
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success') {
$paymentStatus = $data['data']['payment_status']; // 'success', 'pending', or 'failed'
echo "Transaction Status: " . strtoupper($paymentStatus);
} else {
echo "Error checking status: " . ($data['error'] ?? 'Unknown error');
}
?>
const fetch = require('node-fetch');
fetch('https://gurupaygateway.com/api/check-status', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Guru-Key': 'guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
},
body: JSON.stringify({ order_id: 'ORD_20260911_7948' })
})
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));
Success Response Schema (200 OK)
{
"status": "success",
"data": {
"order_id": "ORD_20260911_7948",
"amount": 100.00,
"currency": "INR",
"payment_status": "success",
"customer_name": "Raushan Kumar",
"customer_mobile": "9999999999",
"utr": "615372849102",
"payment_method": "UPI QR",
"provider": "paytm",
"gateway_txn_id": "TXN_9201938561",
"paid_at": "2026-06-05 11:16:45",
"payment_url": "https://gurupaygateway.com/pay/LRd7jTFOV2sFyhMyOBzbJLL1SQzMxe5V",
"callback_url": "https://yourwebsite.com/callback.php",
"expires_at": "2026-06-06 11:15:30",
"created_at": "2026-06-05 11:15:30"
}
}
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.
You can manage and add webhooks in your Webhooks Portal.
Signature Validation
To ensure webhook payloads are authentically generated by GuruPay, every webhook request contains a custom header named `X-GuruPay-Signature`.
This signature represents the HMAC-SHA256 hash of the raw POST body payload, signed using your unique **Webhook Secret Key**.
Sample PHP Webhook Receiver & Verification
<?php
// Retrieve the signature header
$signature = $_SERVER['HTTP_X_PAYINDIA_SIGNATURE'] ?? '';
// Get Webhook Secret from your settings
$webhookSecret = "your_webhook_secret_key";
// Read raw POST body payload
$payload = file_get_contents('php://input');
// Calculate expected signature
$expectedSignature = hash_hmac('sha256', $payload, $webhookSecret);
// Verify match
if (hash_equals($expectedSignature, $signature)) {
// Valid request! Parse JSON
$data = json_decode($payload, true);
$orderId = $data['order_id'];
$amount = $data['amount'];
$utr = $data['utr'];
$status = $data['status']; // 'success'
if ($data['event'] === 'payment.success') {
// 1. Mark order as Paid in your database
// 2. Deliver goods to customer
}
// Respond with 200 OK to acknowledge receipt
http_response_code(200);
echo json_encode(['received' => true]);
} else {
// Invalid signature, ignore/fail
http_response_code(400);
echo "Invalid signature";
}
?>
WHMCS Module
Accept UPI payments directly on your WHMCS billing panel using our official GuruPay Payment Gateway module. Just download, upload to your WHMCS installation, and configure your API key from the admin area.
Installation Steps
| # | Step |
|---|---|
| 1 | Extract the ZIP file. It contains gurupay.php and a callback/ folder. |
| 2 | Upload gurupay.php to /modules/gateways/ in your WHMCS root. |
| 3 | Upload the callback/ folder to /modules/gateways/callback/. |
| 4 | In WHMCS Admin, go to Setup → Payments → Payment Gateways and activate GuruPay - UPI Payment Gateway. |
| 5 | Enter your API Key (X-Guru-Key) from your GuruPay dashboard and save. |
Callbacks & Redirect
If you passed a `callback_url` when creating the order, GuruPay will automatically redirect your customer's browser to this URL immediately after a successful checkout verification.
When redirecting, we append key transaction details as URL query parameters:
https://yourwebsite.com/callback.php?status=success&order_id=ORD_20260911_7948&amount=100.00&utr=615372849102
Secure Verification Requirement
Browser redirects can easily be modified by malicious users. Never finalize transactions or deliver digital goods based solely on URL parameter states. Always run a backend status check API call or wait for the webhook trigger to confirm the payment was captured.
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, $customerName) {
$guruKey = "guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$payload = [
'amount' => number_format($amount, 2, '.', ''),
'order_id' => $orderId,
'customer_name' => $customerName,
'callback_url' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?action=callback'
];
$ch = curl_init('https://gurupaygateway.com/api/create-order');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Guru-Key: ' . $guruKey,
]
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success') {
// Redirect customer to GuruPay payment card
header("Location: " . $data['data']['payment_url']);
exit;
} else {
die("Payment initiation failed: " . ($data['error'] ?? '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
$guruKey = "guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$ch = curl_init('https://gurupaygateway.com/api/check-status');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['order_id' => $orderId]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Guru-Key: ' . $guruKey,
]
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
if (isset($data['status']) && $data['status'] === 'success' && $data['data']['payment_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, 'Raushan Kumar');
} elseif ($action === 'callback') {
handleCallback();
} else {
// Show initiation button
echo "<a href='?action=pay' style='padding:12px 24px; background:#1B1F3B; color:#C9A227; text-decoration:none; border-radius:8px; font-family:sans-serif; font-weight:bold;'>Pay ₹100 using GuruPay</a>";
}
?>
AI Integration Prompt
Building on a no-backend / single-file setup? Copy the ready-made prompt below and paste it into your favourite AI code generator (ChatGPT, Claude, etc.). It already contains your live X-Guru-Key and API endpoints, and instructs the AI to generate a complete, working, single HTML file with the full GuruPay checkout, redirect, callback verification and subscription-unlock flow.
Client-Side Key Notice
This prompt embeds your X-Guru-Key directly in a single HTML file, which means the key is visible to anyone who views the page source. This is fine for quick prototypes, internal tools, or sandbox testing. For production sites handling real customer payments, prefer a server-side integration (see PHP Integration Flow) so your key never reaches the browser.
Mujhe apni website/app me "GuruPay Payment Gateway" fully integrate karna hai apne single HTML file me.
Pehle mera diya gaya code/structure dhyan se padho, uske hisaab se banao. Jaha "Add Amount" ya "Pay Now" jaisa option hoga, wahan payment start hoga aur success hone par payment success redirect/confirmation dikhna chahiye. Agar ye subscription ka payment hai, to success confirm hone ke baad us subscription ko turant unlock kar do (locked content/features ka lock hata do, "Subscribed" status show karo).
Requirements:
- Sirf EK single HTML file me pura kaam (inline CSS + inline JS ek hi file me), koi separate file nahi.
- Error-free, fully working, production-style code do — incomplete ya example-only snippet mat do.
- Neeche di gayi API details ke basis par pura end-to-end payment flow banao:
1. Create Order — user amount enter kare ya plan select kare, us par click karte hi create-order API call ho.
2. Payment Page Redirect — API response me mile "payment_url" par user ko redirect karo.
3. Callback Handling — payment ke baad wapas is page par aane par URL params (order_id, status) read karo.
4. Status Verification — sirf URL params par bharosa mat karo, hamesha check-status API call karke confirm karo ki payment fully successful hai.
5. Amount Payment Flow — normal amount payment success hone par "Payment Successful" confirmation screen dikhao.
6. Subscription Payment Flow — subscription payment success confirm hone ke baad subscription unlock karo aur locked/premium content ko turant accessible bana do.
- Loading state, error state, aur success state teeno cleanly handle karo.
- UI clean, simple aur mobile-friendly rakho.
- Final pura single HTML code ek hi baar me do jo copy-paste karte hi directly kaam kare.
=== API DETAILS ===
1) CREATE ORDER API
Endpoint: POST https://gurupaygateway.com/api/create-order
Headers:
X-Guru-Key: guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Content-Type: application/json
Body (JSON):
{
"amount": "100.00",
"order_id": "ORD_20260911_XXXX",
"customer_name": "Customer Name",
"description": "Order description",
"callback_url": "https://yourwebsite.com/your-page.html"
}
Success Response (201):
{
"status": "success",
"data": {
"payment_url": "https://gurupaygateway.com/pay/xxxxxxxxxxxx",
"order_id": "ORD_20260911_XXXX",
"amount": 100.00,
"currency": "INR"
}
}
2) CHECK STATUS API
Endpoint: POST https://gurupaygateway.com/api/check-status
Headers:
X-Guru-Key: guru_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Content-Type: application/json
Body (JSON):
{
"order_id": "ORD_20260911_XXXX"
}
Success Response (200):
{
"status": "success",
"data": {
"order_id": "ORD_20260911_XXXX",
"amount": 100.00,
"payment_status": "success",
"utr": "615372849102",
"paid_at": "2026-08-09 21:41:09"
}
}
Is API key aur endpoint ko exactly isi tarah hardcode karke use karo. Ab upar diye gaye structure/design ke hisaab se pura single HTML file bana kar do.