# Royal Pay API: full documentation Every page of https://docs.royalpe.site, in order, as Markdown. API base URL: https://api.royalpe.site. Updated 2026-11-30. # Royal Pay API Royal Pay takes deposits from your users through a hosted checkout. You create a pay-in from your server, send the user to the checkout link, and Royal Pay tells your server the result by webhook. | | | |---|---| | **API base URL** | `https://api.royalpe.site` | | **Checkout** | `https://pay.royalpe.site/gateway/…`, a link you get for each pay-in | | **Format** | JSON over HTTPS. Amounts are in rupees (INR), up to 2 decimals. | | **Times** | ISO 8601, UTC (for example `2026-11-30T10:15:00.000Z`) | ## How a pay-in works 1. **Create** the pay-in from your server: [`POST /merchant/initial-payment`](https://docs.royalpe.site/payins/create). You get a `paymentUrl` and a `transactionId`. 2. **Redirect** your user to `paymentUrl`. The checkout shows a UPI QR, the UPI ID, app buttons, or bank details. 3. The user **pays** in their UPI app and uploads the payment screenshot. Royal Pay reads the UTR from it. 4. Royal Pay **verifies** the payment and sends your `webhookUrl` the result: `approved`, `rejected` or `cancelled`. See [Webhooks](https://docs.royalpe.site/webhooks). 5. You **credit** the user once, on `approved`. When you're unsure, ask [`GET /merchant/transaction-status`](https://docs.royalpe.site/payins/status). ## Quick start ```bash title="cURL" curl -X POST https://api.royalpe.site/merchant/initial-payment \ -H "Content-Type: application/json" \ -d '{ "accessKey": "YOUR_ACCESS_KEY", "secretKey": "YOUR_SECRET_KEY", "amount": 500, "orderId": "ORDER-10045", "userId": "USER-881", "webhookUrl": "https://shop.example.com/royalpay/webhook", "redirectUrl": "https://shop.example.com/deposit/done" }' ``` ```json title="Response" { "success": true, "message": "Payment URL generated successfully", "data": { "paymentUrl": "https://pay.royalpe.site/gateway/Xq3v9KfP2mZt7LbR8sWn4cYd1HgJ6aEu0oTi5kNp", "orderId": "ORDER-10045", "transactionId": "RP-7f3a9c21d84e5b02", "amount": 500, "status": "progress", "userId": "USER-881" } } ``` ## Pages - [Authentication](https://docs.royalpe.site/authentication): your access key, secret key and webhook signing key. - [Create a pay-in](https://docs.royalpe.site/payins/create), [Pay-in status](https://docs.royalpe.site/payins/status), [Submit a UTR](https://docs.royalpe.site/payins/manual-utr). - [Webhooks](https://docs.royalpe.site/webhooks): payload, signature check, retries. - [Hosted checkout](https://docs.royalpe.site/checkout): what your user sees, the secure session, cancellation. - [Statuses](https://docs.royalpe.site/statuses), [Errors](https://docs.royalpe.site/errors), [Payouts](https://docs.royalpe.site/payouts), [Going live](https://docs.royalpe.site/going-live), [Changelog](https://docs.royalpe.site/changelog). ## For AI agents These docs are plain HTML that reads without JavaScript. Every page is also available as Markdown: add `.md` to its address, or send `Accept: text/markdown`. - [`/llms.txt`](https://docs.royalpe.site/llms.txt): an index of every page. - [`/llms-full.txt`](https://docs.royalpe.site/llms-full.txt): all the docs in one Markdown file. - [`/openapi.json`](https://docs.royalpe.site/openapi.json): the API as OpenAPI 3.1. # Authentication Your merchant workspace has three keys. Find them under **View keys** in the merchant portal. | Key | Looks like | Used for | |---|---|---| | Access key | `access-…` | Identifies your merchant account in every request. | | Secret key | a long random string | Proves the request is yours. It's shown **once**, when you rotate it. | | Webhook signing key | 64 hex characters | Checks that a webhook really came from Royal Pay. See [Webhooks](https://docs.royalpe.site/webhooks#verify-the-signature). | ## Sending the keys Pay-in endpoints take the keys in the request: in the JSON body for `POST`, in the query string for `GET`. ```json title="POST body" { "accessKey": "YOUR_ACCESS_KEY", "secretKey": "YOUR_SECRET_KEY", "…": "…" } ``` ```bash title="GET query" https://api.royalpe.site/merchant/transaction-status?accessKey=YOUR_ACCESS_KEY&secretKey=YOUR_SECRET_KEY&transactionId=RP-7f3a9c21d84e5b02 ``` Payout endpoints take them as the `accessKey` and `secretKey` **headers**. See [Payouts](https://docs.royalpe.site/payouts). A wrong or missing key answers `401` with `Invalid access key or secret key`. ## Keeping keys safe - Call the API **from your server only**. Never put the secret key in a web page, mobile app or URL your users can see. - `GET` requests carry the keys in the URL, so keep your server's outgoing request logs private. - **Rotate** the secret key in the merchant portal (**Rotate keys**) if it may have leaked. The old secret stops working at once. The access key and the signing key stay the same. - Every call is over HTTPS. Plain HTTP is refused. # Going live Your integration is ready when all of these hold. ## Creating pay-ins - [ ] Pay-ins are created **from your server**. The secret key never reaches a browser or app. - [ ] Each deposit has its own `orderId`, and a timed-out create call is retried with the **same** `orderId`. - [ ] `transactionId` is stored with your order. - [ ] The user is redirected to `paymentUrl` in the browser they'll pay from, and nothing else opens it first. ## Webhooks - [ ] `webhookUrl` is HTTPS, on the public internet, and answers 2xx within 8 seconds. - [ ] Every webhook's **signature is checked** with the signing key, over the raw body, and old timestamps (over 5 minutes) are refused. - [ ] Crediting happens **once**, only on `approved`, keyed on `transactionId`, after checking `orderId`, `userId` and `amount`. - [ ] `rejected` and `cancelled` are shown to the user, who can start a new deposit. ## Reconciling - [ ] Deposits still in `progress` or `pending` after an hour are checked with [Pay-in status](https://docs.royalpe.site/payins/status). - [ ] Your support team can [submit a UTR](https://docs.royalpe.site/payins/manual-utr) a user sends them. ## Keys - [ ] Keys are kept in a secret store or environment variables, not in code. - [ ] You know how to rotate the secret key (merchant portal → **Rotate keys**). # Create a pay-in `POST https://api.royalpe.site/merchant/initial-payment` Creates a pay-in for one of your users and returns the checkout link to send them to. ## Request Send JSON with `Content-Type: application/json`. | Field | Type | Required | Description | |---|---|---|---| | `accessKey` | string | yes | Your access key. | | `secretKey` | string | yes | Your secret key. | | `amount` | number | yes | Amount in rupees: more than 0, at most 2 decimals (`500`, `499.50`). | | `orderId` | string | yes | Your own ID for this deposit, unique in your account (max 2048 characters). Makes the call safe to retry. | | `userId` | string | yes | Your ID for the user who pays. It comes back in the webhook. | | `webhookUrl` | string | yes | HTTPS address on your server that receives this pay-in's results. It must be on the public internet. | | `redirectUrl` | string | yes | HTTPS address the checkout's "Return to …" button takes your user to. | ```bash title="cURL" curl -X POST https://api.royalpe.site/merchant/initial-payment \ -H "Content-Type: application/json" \ -d '{"accessKey":"YOUR_ACCESS_KEY","secretKey":"YOUR_SECRET_KEY","amount":500,"orderId":"ORDER-10045","userId":"USER-881","webhookUrl":"https://shop.example.com/royalpay/webhook","redirectUrl":"https://shop.example.com/deposit/done"}' ``` ```javascript title="Node.js" const res = await fetch("https://api.royalpe.site/merchant/initial-payment", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ accessKey: process.env.ROYALPAY_ACCESS_KEY, secretKey: process.env.ROYALPAY_SECRET_KEY, amount: 500, orderId: "ORDER-10045", userId: "USER-881", webhookUrl: "https://shop.example.com/royalpay/webhook", redirectUrl: "https://shop.example.com/deposit/done", }), }); const { success, message, data } = await res.json(); if (!success) throw new Error(message); // Save data.transactionId with your order, then redirect the user to data.paymentUrl ``` ```php title="PHP" $ch = curl_init("https://api.royalpe.site/merchant/initial-payment"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode([ "accessKey" => getenv("ROYALPAY_ACCESS_KEY"), "secretKey" => getenv("ROYALPAY_SECRET_KEY"), "amount" => 500, "orderId" => "ORDER-10045", "userId" => "USER-881", "webhookUrl" => "https://shop.example.com/royalpay/webhook", "redirectUrl" => "https://shop.example.com/deposit/done", ]), ]); $res = json_decode(curl_exec($ch), true); // header("Location: " . $res["data"]["paymentUrl"]); ``` ```python title="Python" import os, requests res = requests.post("https://api.royalpe.site/merchant/initial-payment", json={ "accessKey": os.environ["ROYALPAY_ACCESS_KEY"], "secretKey": os.environ["ROYALPAY_SECRET_KEY"], "amount": 500, "orderId": "ORDER-10045", "userId": "USER-881", "webhookUrl": "https://shop.example.com/royalpay/webhook", "redirectUrl": "https://shop.example.com/deposit/done", }, timeout=15).json() payment_url = res["data"]["paymentUrl"] ``` ## Response `200 OK` ```json title="200" { "success": true, "message": "Payment URL generated successfully", "data": { "paymentUrl": "https://pay.royalpe.site/gateway/Xq3v9KfP2mZt7LbR8sWn4cYd1HgJ6aEu0oTi5kNp", "orderId": "ORDER-10045", "transactionId": "RP-7f3a9c21d84e5b02", "amount": 500, "status": "progress", "userId": "USER-881" } } ``` | Field | Type | Description | |---|---|---| | `paymentUrl` | string | The hosted checkout for this pay-in. Redirect your user here, in the same browser they'll pay from. | | `transactionId` | string | Royal Pay's ID for the pay-in (`RP-…`). Store it: status calls and webhooks use it. | | `orderId` | string | Your `orderId`, as sent. | | `amount` | number | The amount in rupees. | | `status` | string | Always `progress` for a new pay-in. See [Statuses](https://docs.royalpe.site/statuses). | | `userId` | string | Your `userId`, as sent. | ## Retrying safely `orderId` makes this call **idempotent**. If a call times out, send the exact same request again: - **Same `orderId`, same details** (`userId`, `amount`, `webhookUrl`, `redirectUrl`): you get the **same** pay-in back, with the same `paymentUrl`. - **Same `orderId`, different details**: `409` with `Order ID already used with different details`. Use a new `orderId` for a new deposit. ## Things to know - **One link, one browser.** The first browser that opens `paymentUrl` owns that checkout. Don't open it yourself (for example in a test or link-preview step). See [Hosted checkout](https://docs.royalpe.site/checkout). - **Leaving cancels.** If your user closes the checkout before paying, the pay-in is `cancelled` and you get a webhook. Create a new pay-in (with a new `orderId`) if they try again. - **Limits.** Pay-ins outside your account's deposit limits, or while new payments are paused (`409`), are refused. Ask Royal Pay for your limits. ## Errors | HTTP | `message` | |---|---| | 400 | `Access key is required`, `Secret key is required`, `orderId is required`, `userId is required`, `webhookUrl is required`, `redirectUrl is required` | | 400 | `Invalid amount`, `A valid HTTPS URL is required` | | 401 | `Invalid access key or secret key` | | 409 | `Order ID already used with different details`, `New payments are paused for this merchant` | All errors: [Errors](https://docs.royalpe.site/errors). # Pay-in status `GET https://api.royalpe.site/merchant/transaction-status` Returns a pay-in's current status. Use it to **reconcile**: when a webhook is late, when your server was down, or before crediting a large deposit. Webhooks remain the main way to learn the result; don't poll every second. ## Query parameters | Parameter | Required | Description | |---|---|---| | `accessKey` | yes | Your access key. | | `secretKey` | yes | Your secret key. | | `transactionId` | yes | The `transactionId` from [Create a pay-in](https://docs.royalpe.site/payins/create). | ```bash title="cURL" curl "https://api.royalpe.site/merchant/transaction-status?accessKey=YOUR_ACCESS_KEY&secretKey=YOUR_SECRET_KEY&transactionId=RP-7f3a9c21d84e5b02" ``` ```javascript title="Node.js" const q = new URLSearchParams({ accessKey: process.env.ROYALPAY_ACCESS_KEY, secretKey: process.env.ROYALPAY_SECRET_KEY, transactionId: "RP-7f3a9c21d84e5b02", }); const { data } = await (await fetch("https://api.royalpe.site/merchant/transaction-status?" + q)).json(); ``` ```python title="Python" import os, requests data = requests.get("https://api.royalpe.site/merchant/transaction-status", params={ "accessKey": os.environ["ROYALPAY_ACCESS_KEY"], "secretKey": os.environ["ROYALPAY_SECRET_KEY"], "transactionId": "RP-7f3a9c21d84e5b02", }, timeout=15).json()["data"] ``` ## Response ```json title="200" { "success": true, "message": "Transaction status retrieved successfully", "data": { "transactionId": "RP-7f3a9c21d84e5b02", "status": "approved", "amount": 500, "remarks": "Payment successful", "updatedAt": "2026-11-30T10:16:42.118Z", "orderId": "ORDER-10045", "userId": "USER-881", "utrNumber": "531512345678" } } ``` | Field | Type | Description | |---|---|---| | `transactionId` | string | Royal Pay's ID for the pay-in. | | `status` | string | `progress`, `pending`, `approved`, `rejected` or `cancelled`. See [Statuses](https://docs.royalpe.site/statuses). | | `amount` | number | Amount in rupees. | | `remarks` | string \| null | Why it ended this way: `Payment successful`, the rejection reason, or the cancellation reason (`Cancelled by the payer`, `Payer left the checkout`, `Checkout timed out: …`). | | `updatedAt` | string | When the status last changed (ISO 8601, UTC). | | `orderId` | string | Your `orderId`. | | `userId` | string | Your `userId`. | | `utrNumber` | string \| null | The payer's UTR (bank reference), once they've submitted it. | This is the same object a [webhook](https://docs.royalpe.site/webhooks) sends. ## Errors | HTTP | `message` | |---|---| | 400 | `Access key is required`, `Secret key is required`, `transactionId is required` | | 401 | `Invalid access key or secret key` | | 403 | `Transaction does not belong to this merchant` | | 404 | `Transaction not found` | # Submit a UTR `POST https://api.royalpe.site/merchant/manual-utr-upload` Submits the payer's UTR (the bank reference of their UPI payment) for a pay-in. Use it when your user gives the UTR to you, for example through your support team, instead of uploading it at the checkout. The pay-in moves to `pending` and is verified like any other. ## Request | Field | Type | Required | Description | |---|---|---|---| | `accessKey` | string | yes | Your access key. | | `secretKey` | string | yes | Your secret key. | | `transactionId` | string | yes | The pay-in's `transactionId`. | | `utrNumber` | string | yes | The UTR exactly as the payer's app shows it, usually 12 digits. Up to 128 characters. | ```bash title="cURL" curl -X POST https://api.royalpe.site/merchant/manual-utr-upload \ -H "Content-Type: application/json" \ -d '{"accessKey":"YOUR_ACCESS_KEY","secretKey":"YOUR_SECRET_KEY","transactionId":"RP-7f3a9c21d84e5b02","utrNumber":"531512345678"}' ``` ## Response ```json title="200" { "success": true, "message": "UTR number updated successfully", "data": { "transactionId": "RP-7f3a9c21d84e5b02", "status": "pending" } } ``` You'll get a `pending` webhook, then the result (`approved` or `rejected`). Sending the same UTR again for a pending pay-in changes nothing. Sending a different one restarts the check with the new UTR. ## Errors | HTTP | `message` | Meaning | |---|---|---| | 400 | `This payment is already accepted` | The pay-in is already `approved`. | | 400 | `A payment has already been accepted with this UTR number` | That UTR was used for another approved pay-in. | | 400 | `Invalid UTR number` | Empty, or over 128 characters. | | 401 | `Invalid access key or secret key` | | | 403 | `Transaction does not belong to this merchant` | | | 404 | `Transaction not found` | | | 409 | `Payment cannot be submitted in this state` | The pay-in is `rejected` or `cancelled`. Create a new pay-in. | # Webhooks Royal Pay sends a `POST` to the pay-in's `webhookUrl` each time its status changes. Credit your user when you receive `approved`, after checking the signature. ## When webhooks are sent | `status` | Sent when | |---|---| | `pending` | The payer submitted their payment proof (screenshot or UTR). Verification has started. Again if they submit a different UTR. | | `approved` | The payment is verified. **Credit the user.** | | `rejected` | The payment was not accepted. `remarks` says why. | | `cancelled` | The payer cancelled, left the checkout, or it timed out, before submitting a payment. `remarks` says which. | No webhook is sent for `progress` (the pay-in was just created). ## Request ```http title="Headers" POST /royalpay/webhook HTTP/1.1 Content-Type: application/json User-Agent: RoyalPay-Webhooks/1.0 X-Event-Id: EV-3c9d1f0a7b2e4d58 X-Timestamp: 1796040981 X-Signature: 6f1e0b0c4a1d0c9f7b0d3c2e5a8b1f4d6c9e2a5b8d1f4c7a0e3b6d9c2f5a8e1b ``` ```json title="Body" { "transactionId": "RP-7f3a9c21d84e5b02", "status": "approved", "amount": 500, "remarks": "Payment successful", "updatedAt": "2026-11-30T10:16:42.118Z", "orderId": "ORDER-10045", "userId": "USER-881", "utrNumber": "531512345678" } ``` | Header | Description | |---|---| | `X-Event-Id` | Unique ID of this event (`EV-…`). Retries of the same event keep the same ID. | | `X-Timestamp` | When this attempt was signed, in Unix seconds. | | `X-Signature` | HMAC-SHA256 of the event, hex-encoded. See below. | The body fields are the same as [Pay-in status](https://docs.royalpe.site/payins/status). ## Verify the signature Compute HMAC-SHA256 with your **webhook signing key** (merchant portal → **View keys**) over: ```text title="Signed text" X-Event-Id + "." + X-Timestamp + "." + raw request body ``` Compare it with `X-Signature` in constant time, and reject the request if the timestamp is more than 5 minutes old. Use the **raw body bytes** as received: parsing and re-encoding the JSON changes them. ```javascript title="Node.js" import crypto from "node:crypto"; import express from "express"; const app = express(); // Keep the raw body: the signature is over the exact bytes. app.post("/royalpay/webhook", express.raw({ type: "application/json" }), (req, res) => { const id = req.get("X-Event-Id"), ts = req.get("X-Timestamp"), sig = req.get("X-Signature") || ""; const expected = crypto .createHmac("sha256", process.env.ROYALPAY_SIGNING_KEY) .update(`${id}.${ts}.`) .update(req.body) .digest("hex"); const fresh = Math.abs(Date.now() / 1000 - Number(ts)) < 300; if (!fresh || sig.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected))) { return res.status(401).end(); } const event = JSON.parse(req.body); // Idempotent: credit once per transactionId, only on "approved". handle(event).then(() => res.status(200).end()); }); ``` ```php title="PHP" $raw = file_get_contents("php://input"); $id = $_SERVER["HTTP_X_EVENT_ID"] ?? ""; $ts = $_SERVER["HTTP_X_TIMESTAMP"] ?? ""; $sig = $_SERVER["HTTP_X_SIGNATURE"] ?? ""; $expected = hash_hmac("sha256", $id . "." . $ts . "." . $raw, getenv("ROYALPAY_SIGNING_KEY")); if (abs(time() - (int)$ts) > 300 || !hash_equals($expected, $sig)) { http_response_code(401); exit; } $event = json_decode($raw, true); // Credit once per transactionId when $event["status"] === "approved". http_response_code(200); ``` ```python title="Python" import hashlib, hmac, os, time from flask import Flask, request, abort app = Flask(__name__) @app.post("/royalpay/webhook") def royalpay_webhook(): raw = request.get_data() # the exact bytes received event_id = request.headers.get("X-Event-Id", "") ts = request.headers.get("X-Timestamp", "0") expected = hmac.new(os.environ["ROYALPAY_SIGNING_KEY"].encode(), f"{event_id}.{ts}.".encode() + raw, hashlib.sha256).hexdigest() if abs(time.time() - int(ts)) > 300 or not hmac.compare_digest(expected, request.headers.get("X-Signature", "")): abort(401) event = request.get_json() # Credit once per transactionId when event["status"] == "approved". return "", 200 ``` ## Responding and retries - Answer with any **2xx** within **8 seconds**. Do slow work (crediting, emails) after answering, or in a queue. - Anything else (another status, a timeout, a connection or TLS error) is retried with the **same `X-Event-Id`**, 10 s, 30 s, 1 min, 5 min, 15 min, 30 min, 1 h, 3 h and 6 h after each failed attempt: 10 tries over about 12 hours. - Redirects are **not followed**. Give the final HTTPS address. - A `webhookUrl` whose host resolves to a private, loopback or link-local address is never called, and isn't retried. ## Handling them correctly - **Credit once.** You can receive the same event more than once, for example a retry after your answer was lost. Key your crediting on `transactionId` and credit only the first `approved`. - **Check the details.** Before crediting, check that `orderId`, `userId` and `amount` match the deposit you created. - **Order isn't guaranteed.** Act on the status, not the arrival order: `approved` is final and wins over a late `pending`. - **Missed one?** Ask [Pay-in status](https://docs.royalpe.site/payins/status). It always has the current answer. # Hosted checkout `paymentUrl` opens Royal Pay's hosted checkout at `https://pay.royalpe.site`. It works like other hosted payment pages: it runs on its own address, apart from everything else, and needs no sign-in. ## What your user sees - **UPI:** a QR code with the amount filled in, the UPI ID to copy, the amount, and buttons for UPI apps (PhonePe, Google Pay, Paytm, BHIM, Amazon Pay, CRED). - **Bank transfer:** the account holder, bank, account number and IFSC to copy. - **Proof:** the user uploads the payment screenshot. Royal Pay reads the UTR from it, or asks the user to type it when it can't. - A **15-minute session timer** for the QR. A payment made in time can still be submitted after it ends. - After submitting, the page follows the check live and shows the result. **Return to …** takes the user to your `redirectUrl`. ## A secure session | | | |---|---| | **Own origin** | The checkout runs only on `https://pay.royalpe.site`, which serves nothing else. Your user's other Royal Pay sessions never reach it. | | **One browser** | The first browser that opens the link owns the checkout. In any other browser (a forwarded or leaked link), the page shows only "This payment page is already open in another browser" and can neither show the details nor take a payment. Link previews in chat apps don't count as opening it. | | **Live** | While it's open, the page reports in every 2 seconds. Royal Pay always knows whether the checkout is still open. | | **No framing** | It can't be shown inside an iframe or another site. Open it as a full page, or a full-screen web view in an app. | ## When a checkout is cancelled A pay-in nobody has submitted proof for is cancelled, and you get a `cancelled` webhook, when: | `remarks` | What happened | |---|---| | `Cancelled by the payer` | The user pressed **Cancel payment** and confirmed. | | `Payer left the checkout` | The user closed the tab, pressed back or went to another page, and the checkout didn't come back within 10 seconds. A refresh, or the same checkout open in another tab, keeps it open. | | `Checkout timed out: the payment page stopped responding` | The page stopped reporting in for 30 minutes (the browser was closed or lost its connection). | These **never** cancel it: - **Switching to a UPI app to pay.** That only hides the page. Coming back resumes it. - Anything after the user has **submitted proof**. A submitted pay-in always gets a final `approved` or `rejected`. - A link that was **never opened**. On a cancelled checkout the QR, UPI ID and app buttons are gone, and the page tells the user not to pay. If a user does pay a cancelled pay-in, they contact you with the UTR, and the payment can be traced from it. ## Integration tips - Redirect to `paymentUrl` **in the browser the user pays from**. Don't open it from your server, a bot or a preview tool first. - For a retry after `cancelled`, create a **new** pay-in with a new `orderId`. - In a mobile app, open the checkout in the system browser or a full-screen web view that keeps cookies. # Statuses | `status` | Final | Meaning | What you do | |---|---|---|---| | `progress` | no | Created. The user hasn't submitted proof yet. | Wait. | | `pending` | no | Proof submitted. Royal Pay is verifying the payment. | Wait. Don't create a second pay-in for the same deposit. | | `approved` | yes | Payment verified. | **Credit the user**, once. | | `rejected` | yes | Not accepted. `remarks` gives the reason. | Don't credit. | | `cancelled` | yes | Ended before any proof was submitted: cancelled, left, or timed out. | Don't credit. Create a new pay-in if the user retries. | ## How a pay-in moves ```text title="Lifecycle" progress ──proof submitted──▶ pending ──verified──▶ approved │ │ │ └──not accepted──▶ rejected │ └──cancelled / left / timed out──▶ cancelled ``` - `pending` can receive a new UTR (the user corrects it), which restarts the check. It stays `pending`. - `approved`, `rejected` and `cancelled` never change again. - Every change after `progress` sends a [webhook](https://docs.royalpe.site/webhooks). # Payouts > **Enabled on request.** Payouts are switched on per merchant, for requests from server IP addresses you register with Royal Pay. Until then these endpoints answer `403`. Ask your Royal Pay contact to enable them. Payout endpoints take your keys as **headers**, `accessKey` and `secretKey`, and answer with `status` (not `success`) in the envelope. ## Create a payout `POST https://api.royalpe.site/payout/merchant/api/generate-payout` | Field | Type | Required | Description | |---|---|---|---| | `amount` | number | yes | Rupees, at least `1000`. | | `accountNumber` | string | yes | 9 to 18 digits. | | `accountHolderName` | string | yes | 2 to 100 letters, spaces and dots. | | `ifscCode` | string | yes | IFSC, for example `HDFC0001234`. | | `orderId` | string | yes | Your unique ID. The same `orderId` with the same details returns the same payout. With different details: `409`. | | `remarks` | string | no | Up to 200 characters. | | `callbackUrl` | string | no | HTTPS address, kept with the payout. | ```bash title="cURL" curl -X POST https://api.royalpe.site/payout/merchant/api/generate-payout \ -H "Content-Type: application/json" \ -H "accessKey: YOUR_ACCESS_KEY" -H "secretKey: YOUR_SECRET_KEY" \ -d '{"amount":1500,"accountNumber":"000123456789","accountHolderName":"Asha Verma","ifscCode":"HDFC0001234","orderId":"PO-2291","remarks":"Withdrawal"}' ``` ```json title="201" { "status": true, "message": "Payout request generated successfully", "data": { "orderId": "PO-2291", "transactionId": "PO-1a2b3c4d5e6f7a8b", "amount": 1500, "status": "processing" } } ``` The amount is reserved from your available balance at once. Royal Pay's team completes the transfer. ## Payout status `GET https://api.royalpe.site/payout/merchant/api/payout-status?transactionId=PO-1a2b3c4d5e6f7a8b` (or `?orderId=PO-2291`), with the key headers. ```json title="200" { "status": true, "message": "Payout transaction status retrieved successfully", "data": { "transactionId": "PO-1a2b3c4d5e6f7a8b", "orderId": "PO-2291", "amount": 1500, "status": "processing", "remarks": "Withdrawal", "utr": "" } } ``` `utr` is filled in once the transfer is made. Payout webhooks are **not** sent yet, so check the payout status to follow a payout. ## Errors | HTTP | `message` | |---|---| | 400 | `orderId is required`, `Minimum payout amount is 1000`, `Invalid beneficiary details`, `Invalid remarks`, `Insufficient balance for this payout`, `No payout approver assigned to this merchant`, `transactionId or orderId is required` | | 401 | `Access key and secret key are required`, `Invalid access key or secret key` | | 403 | Payouts not enabled for this server address. | | 404 | `Payout transaction not found` | | 409 | `Order ID already used with different details` | # Errors Every error answers with a non-2xx HTTP status and this body: ```json title="Pay-in endpoints" { "success": false, "message": "Invalid access key or secret key" } ``` ```json title="Payout endpoints" { "status": false, "message": "Invalid access key or secret key" } ``` Show `message` in your logs. Decide what to do from the **HTTP status**, and for `400` and `409` from the `message`. | HTTP | Meaning | Retry? | |---|---|---| | 400 | A field is missing or invalid. | No: fix the request. | | 401 | Wrong or missing access key or secret key. | No: check your keys. | | 403 | The transaction belongs to another merchant, or the request came from somewhere not allowed. | No. | | 404 | No such transaction, or no such endpoint. | No. | | 409 | Conflicts with the current state: the `orderId` was used with different details, new payments are paused, or the pay-in can't take a UTR any more. | No. | | 415 | The body isn't JSON: send `Content-Type: application/json`. | No: fix the request. | | 500 | Something failed on our side (`Something went wrong`). | Yes, with backoff. Pay-in creation is safe to retry with the same `orderId`. | ## Messages | Message | HTTP | Where | |---|---|---| | `Access key is required` / `Secret key is required` | 400 | pay-ins | | `orderId is required`, `userId is required`, `webhookUrl is required`, `redirectUrl is required` | 400 | create | | `transactionId is required`, `utrNumber is required` | 400 | status, UTR | | `Invalid amount` | 400 | create, payouts | | `A valid HTTPS URL is required` | 400 | create, payouts | | `Invalid UTR number` | 400 | UTR | | `This payment is already accepted` | 400 | UTR | | `A payment has already been accepted with this UTR number` | 400 | UTR | | `Invalid request` / `Expected a JSON object` | 400 | any | | `Invalid access key or secret key` | 401 | any | | `Access key and secret key are required` | 401 | payouts | | `Transaction does not belong to this merchant` | 403 | status, UTR | | `Transaction not found` | 404 | status, UTR | | `Order ID already used with different details` | 409 | create, payouts | | `New payments are paused for this merchant` | 409 | create | | `Payment cannot be submitted in this state` | 409 | UTR | | `Expected JSON` | 415 | any POST | | `Something went wrong` | 500 | any | # Changelog ## 30 November 2026 - **New status `cancelled`.** A pay-in nobody has submitted proof for is cancelled when the payer cancels, leaves the checkout, or the checkout stops responding for 30 minutes. You get a `cancelled` webhook. See [Hosted checkout](https://docs.royalpe.site/checkout#when-a-checkout-is-cancelled). - **Webhooks are delivered to your server**, signed with your webhook signing key (now shown under **View keys**), and retried for about 12 hours. See [Webhooks](https://docs.royalpe.site/webhooks). - **The checkout runs on `https://pay.royalpe.site`** and is locked to the first browser that opens it. - These docs, plus `/llms.txt`, `/llms-full.txt`, Markdown pages and `/openapi.json`.