X-Api-Key & X-Api-Secret). Live payments require KYC verification, verified bank account, and provider approval.
API Sections
1. Overview & Environments
InstaPay provides a JSON REST API for UPI payment orchestration. Sandbox mode is unlocked for exploration during your free trial, while Live mode activates strictly after InstaPay KYC verification and authorized payment provider approval.
| Environment | Base URL Path | Mode |
|---|---|---|
| Sandbox (Staging) | /api/v1/payments/* (with ip_test_* key) | Paytm Staging Credentials |
| Production (Live) | /api/v1/payments/* (with ip_live_* key) | Paytm Production Direct Settlement |
2. Authentication Headers
All API requests must be made over HTTPS with server-side merchant API credentials (never expose secret keys in browser JavaScript or mobile binaries).
X-Api-Key: ip_live_<YOUR_PUBLIC_KEY> X-Api-Secret: ip_sec_<YOUR_SECRET_KEY> Content-Type: application/json
3. Create Payment Order Active API
POST /api/v1/payments/create — Creates an order with an enforced expiry window and returns Paytm Dynamic QR & UPI Intent URI.
curl -X POST https://your-domain.com/api/v1/payments/create \
-H "X-Api-Key: ip_test_example" \
-H "X-Api-Secret: ip_sec_example" \
-H "Idempotency-Key: ord_99881122_v1" \
-H "Content-Type: application/json" \
-d '{
"merchant_order_ref": "INV-2026-0041",
"amount": "499.00",
"currency": "INR",
"payment_mode": "auto_upi",
"expiry_minutes": 15,
"customer_name": "Aarav Sharma",
"customer_phone": "+919876543210"
}'
{
"status": "created",
"order_id": "ip_ord_01J9XYZ",
"merchant_order_ref": "INV-2026-0041",
"amount_paise": 49900,
"upi_intent_uri": "upi://pay?pa=merchant@psp&pn=Merchant&tr=ip_ord_01J9XYZ&am=499.00&cu=INR",
"expires_at": "2026-12-03T12:15:00Z"
}
4. Check Payment Status
GET /api/v1/payments/{order_id}/status — Authoritative server-side status check backed by Paytm S2S Order Status API. Client redirects are never accepted as proof of payment.
<?php
$ch = curl_init('https://your-domain.com/api/v1/payments/IP261204.../status');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-Api-Key: ' . getenv('INSTAPAY_API_KEY'),
'X-Api-Secret: ' . getenv('INSTAPAY_API_SECRET'),
],
]);
$response = json_decode(curl_exec($ch), true);
5. Dynamic QR & UPI Intent
Each order generates an exact-amount UPI Intent URI and Dynamic QR string bound to the unique transaction reference (`tr`) and order expiry timestamp to prevent amount tampering or stale replay.
6. Webhook HMAC Signature Verification
Every webhook includes an X-InstaPay-Signature HMAC-SHA256 digest over the raw request body plus timestamp header X-InstaPay-Timestamp.
<?php
$rawBody = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_INSTAPAY_SIGNATURE'] ?? '';
$expected = hash_hmac('sha256', $rawBody, getenv('INSTAPAY_WEBHOOK_SECRET'));
if (!hash_equals($expected, $signature)) {
http_response_code(401);
exit('Invalid signature');
}
7. Idempotency Handling
Supply a unique Idempotency-Key header on order creation requests. Duplicate requests within 24 hours return the original order record safely without creating duplicate transactions.
8. Standard Error Codes
| HTTP | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | Malformed payload or invalid amount/currency |
| 401 | UNAUTHORIZED | Missing or invalid API credentials |
| 403 | LIVE_PAYMENTS_DISABLED | KYC or provider approval incomplete, or trial expired |
| 409 | IDEMPOTENCY_CONFLICT | Same idempotency key reused with a different request payload |
| 429 | RATE_LIMIT_EXCEEDED | Exceeded plan RPM threshold |