Integration examples
Minimal API and official iframe examples for cURL, PHP, Laravel, Node.js, and Python.
cURL
curl -X POST https://i-pay.im/api/v1/payments \
-H 'Authorization: Bearer ipl_REPLACE_PUBLIC.ips_REPLACE_SECRET' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: order_2026_0001_create' \
--data-raw '{"merchant_order_id":"order_2026_0001","amount":"499.00","currency":"INR"}'
PHP
$payload = json_encode([
'merchant_order_id' => 'order_2026_0001',
'amount' => '499.00',
'currency' => 'INR',
], JSON_THROW_ON_ERROR);
$ch = curl_init('https://i-pay.im/api/v1/payments');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ipl_REPLACE_PUBLIC.ips_REPLACE_SECRET',
'Content-Type: application/json',
'Idempotency-Key: order_2026_0001_create',
],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_TIMEOUT => 15,
]);
$response = curl_exec($ch);
if ($response === false) { throw new RuntimeException(curl_error($ch)); }
$payment = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
$checkoutUrl = $payment['data']['checkout_url'] ?? null;
Laravel, Node.js, and Python
$response = Http::withToken(config('services.ipay.secret'))
->withHeaders(['Idempotency-Key' => 'order_2026_0001_create'])
->post('https://i-pay.im/api/v1/payments', [
'merchant_order_id' => 'order_2026_0001', 'amount' => '499.00', 'currency' => 'INR',
]);
$response->throw();
$checkoutUrl = $response->json('data.checkout_url');
const response = await fetch('https://i-pay.im/api/v1/payments', {
method: 'POST',
headers: {
Authorization: 'Bearer ipl_REPLACE_PUBLIC.ips_REPLACE_SECRET',
'Content-Type': 'application/json',
'Idempotency-Key': 'order_2026_0001_create'
},
body: JSON.stringify({ merchant_order_id: 'order_2026_0001', amount: '499.00', currency: 'INR' })
});
if (!response.ok) throw new Error(`iPay returned ${response.status}`);
const payment = await response.json();
import requests
response = requests.post(
'https://i-pay.im/api/v1/payments',
headers={
'Authorization': 'Bearer ipl_REPLACE_PUBLIC.ips_REPLACE_SECRET',
'Idempotency-Key': 'order_2026_0001_create',
},
json={'merchant_order_id': 'order_2026_0001', 'amount': '499.00', 'currency': 'INR'},
timeout=15,
)
response.raise_for_status()
payment = response.json()
Safe fulfillment
All examples are server-side. Redirect the browser to data.checkout_url, but fulfill only after a server-side status read returns SUCCESS or after a verified, duplicate-safe webhook event. Never trust a browser redirect.
Official iframe checkout
iPay renders the same official hosted checkout inside your iframe or as a standalone page. Your server creates the payment with its API credential and passes the returned checkout URL to the browser. The browser must never receive your merchant API key.
The iframe uses the same public checkout URL and renderer as a standalone payment. Append ?embed=1 to the URL returned by payment creation. A parent page cannot set the amount, UPI account, payment reference, theme, or verification result. Treat iframe messages as display hints only and fulfil from GET /api/v1/payments/{payment_id} or a verified webhook.