PaySeren API

Accept local payments and send payouts across Asia with one integration. JSON over HTTPS, signed with HMAC-SHA256.

Base URL

https://api.example.com

Your Merchant ID and API secret are in the merchant portal under API & webhooks. The secret is shown once when created or rotated. Keep it on your server only, never in a browser or mobile app.

Flow in short: create a pay-in, redirect the player to payment_url, wait for our webhook, credit the player when the status is success.

Authentication

Every request carries three headers:

HeaderValue
X-Merchant-IdYour Merchant ID, for example BP0101
X-TimestampCurrent Unix time in seconds. Requests older or newer than 5 minutes are refused.
X-SignatureLower-case hex HMAC-SHA256 of the string below, keyed with your API secret

String to sign: the four parts joined with dots, no spaces.

{timestamp}.{METHOD}.{path_with_query}.{raw_body}

path_with_query is the path exactly as sent, for example /v1/orders/M-1001. For GET requests raw_body is empty. Sign the exact bytes you send: serialize the JSON once, sign that string, send that string.

const crypto = require('crypto');
const MERCHANT_ID = 'BP0101', SECRET = process.env.PAYSEREN_SECRET;

async function payseren(method, path, payload) {
  const body = payload ? JSON.stringify(payload) : '';
  const ts = Math.floor(Date.now() / 1000).toString();
  const sig = crypto.createHmac('sha256', SECRET)
    .update(`${ts}.${method}.${path}.${body}`).digest('hex');
  const res = await fetch('https://api.example.com' + path, {
    method, body: body || undefined,
    headers: { 'content-type': 'application/json', 'x-merchant-id': MERCHANT_ID, 'x-timestamp': ts, 'x-signature': sig },
  });
  return res.json();
}

If you set allowed IPs in the portal, requests from any other IP are refused with ip_not_whitelisted.

Amounts & idempotency

Amounts are decimal strings in the main currency unit with up to 2 decimals: "1449.00", "500". Responses always use 2 decimals.

merchant_order_no is your own unique reference. Sending the same one twice never creates a second order: you get the original back with "duplicate": true. If a request times out, retry it with the same merchant_order_no.

Create pay-in

POST/v1/payin
FieldTypeRequiredDescription
merchant_order_nostring, max 64yesYour unique order reference
currencystringyesINR, BDT, PKR ... see methods
methodstringyesFor example UPI, BKASH, NAGAD
amountstringyesWithin your limits for this method
callback_urlstringnoWebhook URL for this order. Defaults to the one in the portal.
customerobjectnoid (your player ID), ip, return_url (where to send the player after paying)
{
  "merchant_order_no": "M-1001",
  "currency": "INR",
  "method": "UPI",
  "amount": "10000.00",
  "customer": { "id": "player-77", "ip": "103.21.4.10", "return_url": "https://casino.example/cashier" }
}

Response 201 Created (or 200 with "duplicate": true):

{
  "order_no": "PIMX3JEL6I4FE0646C",
  "merchant_order_no": "M-1001",
  "direction": "payin", "currency": "INR", "method": "UPI",
  "amount": "10000.00", "fee": "325.00",
  "status": "pending",
  "payment_url": "https://pay.example/checkout/...",
  "utr": null, "failure_reason": null,
  "created_at": "2026-12-01T10:15:00.000Z", "completed_at": null, "duplicate": false
}

Redirect the player to payment_url. Do not credit anything yet: the final result comes by webhook.

Create payout

POST/v1/payout

Amount plus fee is reserved from your available balance at once. If the payout fails, it is returned in full.

FieldTypeRequiredDescription
merchant_order_nostringyesYour unique reference
currency, method, amountstringyesAs for pay-in
beneficiaryobjectyesBank: name, account, ifsc. UPI: name, upi. Wallets (bKash, Nagad...): name, account (wallet number)
callback_urlstringnoWebhook URL for this order
{
  "merchant_order_no": "W-5512",
  "currency": "BDT", "method": "BKASH", "amount": "2500",
  "beneficiary": { "name": "Rahim Uddin", "account": "01712345678" }
}
A payout can stay pending for a while if the bank is slow. Never send the same money again under a new reference while one is pending: query it, or wait for the webhook.

Get order

GET/v1/orders/{order_no or merchant_order_no}

Returns the same object as the create calls. Use it to check an order if you missed a webhook.

Get balance

GET/v1/balance
{ "INR": { "available": "9675.00", "payout_hold": "2040.00" } }

available can be paid out or settled. payout_hold is reserved for payouts still in progress.

Receiving webhooks

When an order reaches success or failed we send a POST with the order object (same fields as above) to your webhook URL, with two headers:

HeaderValue
X-TimestampUnix seconds
X-Signaturehex HMAC-SHA256 of {timestamp}.{raw_body} with your API secret

Verify the signature on the raw body before trusting it, then answer with any 2xx. Otherwise we retry: 10 attempts over about 4 hours. The same order can arrive more than once: process it idempotently by order_no. You can resend any webhook from the portal.

app.post('/payseren/webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const raw = req.body.toString('utf8');
  const ts = req.get('x-timestamp');
  const expected = crypto.createHmac('sha256', SECRET).update(`${ts}.${raw}`).digest('hex');
  const got = Buffer.from(req.get('x-signature') || '');
  if (got.length !== expected.length || !crypto.timingSafeEqual(got, Buffer.from(expected))) return res.sendStatus(401);
  const order = JSON.parse(raw);
  // credit or refund once per order.order_no
  res.sendStatus(200);
});

Order statuses

StatusMeaningFinal
pendingCreated, waiting for the payer or the bankno
successMoney received (pay-in) or delivered (payout). utr holds the bank reference.yes
failedNot completed. failure_reason says why. Payout funds are back in your balance.yes

A final status never changes.

Methods

The methods, limits and prices enabled for your account are listed in the portal under API & webhooks. Common codes:

CurrencyPay-inPayout
INRUPIIMPS, UPI
BDTBKASH, NAGAD, ROCKET, UPAYBKASH, NAGAD, ROCKET, UPAY
PKRJAZZCASH, EASYPAISAJAZZCASH, EASYPAISA

Errors

Errors return a non-2xx status and a JSON body {"error": "code", "message": "..."}.

HTTPerrorWhat to do
400validation_error, invalid_amount, invalid_jsonFix the request; details lists the fields
400method_not_enabledCurrency or method not enabled for you. Contact support.
400amount_out_of_rangeOutside your limits for this method; message gives them
400insufficient_balanceNot enough available balance for payout plus fee
400daily_limit_exceededYour daily limit for this direction is reached; message gives it
400payin_rejected_risk, payout_rejected_riskRefused by risk rules (blocked account, too many attempts). Do not retry the same details.
403payouts_frozenPayouts are on hold for your account. Contact support.
401missing_auth_headers, invalid_signature, timestamp_out_of_rangeCheck the signing string, secret and server clock
403ip_not_whitelisted, merchant_suspendedCheck allowed IPs, or contact support
404order_not_foundWrong reference
503no_channel_availableTemporarily unavailable for this amount or method. Retry later.
500internal_errorRetry with the same merchant_order_no

Go-live checklist

  • Secret stored on your server only, never in frontend code
  • Signature uses the exact body bytes you send
  • Server clock synced (NTP); timestamps within 5 minutes
  • Webhook signature verified on the raw body; duplicates handled by order_no
  • Players credited only on success webhooks, never on redirect back from the payment page
  • Allowed IPs set in the portal
  • Timeouts retried with the same merchant_order_no
  • Tested end to end on your sandbox account (ask us for YOURCODE_TEST credentials; it uses a test bank, no real money)

Good to know

  • Large or unusual payouts can stay pending a little longer while our team approves them. Your balance is held during that time and released if the payout fails.
  • If a customer pays a different amount than requested, the webhook carries the real amount and the original requested_amount. Credit the player with amount.
  • Rarely, a pay-in reported as failed (for example the customer paid a different amount) is later confirmed by the bank. You then receive a second webhook with success for the same order_no. Credit it at that point. A success never turns into failed.
  • Service status and maintenance notes: /status (JSON at /status.json).