API documentation
Base URL http://localhost:8000 · JSON · Authorization: Bearer <secret key> (server-side only)
1. Create an order
POST /api/v1/orders
{"order_id": "ORDER-1001", "amount": "499.00", "return_url": "https://yourshop.com/thanks", "metadata": {"customer": "Ravi"}}
Returns payable_amount (charge exactly this), payment_page, upi_uri, qr_svg, status_url, expires_in. Repeating the same pending order returns the same order.
2. Show the payment
Hosted popup:
<script src="http://localhost:8000/checkout.js"></script>
DhanSetu.open({ paymentUrl: order.payment_page,
onSuccess: r => verifyOnServer(r.order_id),
onFailure: r => showRetry() });
Your own UI: render qr_svg and payable_amount, open upi_uri on mobile, and poll status_url every 3 s from your registered domain.
3. Confirm on your server
Webhook events payment.success, payment.expired, payment.cancelled with headers X-DhanSetu-Signature: sha256=HMAC(secret, timestamp + "." + body), X-DhanSetu-Timestamp, X-DhanSetu-Delivery-Id. Retries for ~24 h until you return 2xx. Or poll GET /api/v1/orders/<order_id>.
4. Errors
| HTTP | code | Meaning |
|---|---|---|
| 401 | — | Missing or invalid API key |
| 403 | ip_not_allowed | Request IP is not in the key's allowlist |
| 400 | invalid_request | Bad amount / order_id / metadata |
| 402 | trial_over / plan_expired / quota_exceeded | Renew or upgrade the plan |
| 409 | order_exists | Order ID already used with another amount/status |
| 503 | amount_slots_exhausted | Too many open orders at this amount; retry in a minute |
Logged-in merchants see full examples (PHP, Python, Node) under Dashboard → Integration.