This page is a real integration in a single PHP file. It creates an order through the API, shows the payment inside this page — or on the hosted payment page, your choice — and verifies the result on the server.
Open demo.php in an editor — every step is commented.
POST /api/create-order with the amount, your own order_id and a callback_url.AntoPay.open({ url: payment_url }) shows the QR in a box on top of your page. Payment page: you redirect to payment_url. Either way they scan the QR in any UPI app.callback_url you call POST /api/check-status. Deliver only when payment_status is success.// the two calls this page makes
[$code, $res] = gateway_call($apiBase . '/create-order', $apiKey, [
'amount' => '10.00',
'order_id' => $orderId,
'customer_name'=> $name,
'callback_url' => $selfUrl . '?action=callback',
]);
header('Location: ' . $res['data']['payment_url']);
// …after the customer comes back
[$code, $res] = gateway_call($apiBase . '/check-status', $apiKey,
['order_id' => $orderId]);
$paid = $res['data']['payment_status'] === 'success';