Rivara Pay

Documentation · API v1

Accept payments with Rivara Pay

One API call creates a payment, the hosted checkout page takes the money, a webhook reports the result. Below is the whole path: from an API key to your first payout.

Your AI assistant can write the integration too: hand it /llms.txt — a self-contained specification it can turn into working code.

01 · Quick start

Three steps to your first payment

Rivara Pay hands you a link to its hosted checkout page and reports the result by webhook.

  1. 1

    Create a payment

    Your server calls POST /api/v1/payment-intents with the key and an Idempotency-Key. The response carries checkoutUrl.

  2. 2

    Send the payer to checkoutUrl

    Usually our payment page: SBP, cards or crypto, whichever the payer picks. For an H2H (“fast QR”) till it is the NSPK link https://qr.nspk.ru/... you show the payer yourself; pass payerIp on creation. Card details are entered only on our page and never reach your server or the API. For H2H the API returns the NSPK link for you to show; card details still never reach the API.

  3. 3

    Receive the payment.paid webhook

    The event arrives at your URL from the dashboard. Verify the signature and the amount — then ship the order.

Ship the order on the payment.paid webhook only The payer returning to returnUrl is not a payment signal: the tab can close, the webhook arrives anyway. Polling GET /api/v1/payment-intents/{id} is the fallback, for a “checking the payment” screen.

02 · Keys and requests

Keys and requests

Keys live in the dashboard (https://cabinet.rivarapay.io, “Settings → API keys”). The base URL: https://api.rivarapay.io/api/v1. A key is a mode, an id and a secret:

key format
live_0f1e2d3c4b5a69788796a5b4_c2VjcmV0LXNlY3JldC1zZWNyZXQ   — live
test_0f1e2d3c4b5a69788796a5b4_c2VjcmV0LXNlY3JldC1zZWNyZXQ   — test

A key carries scopes: payments:read, payments:write, payouts:read, payouts:write, payout_destinations:write, balances:read, ledger:read — every operation needs its own. payouts:write covers the payouts themselves, while payout_destinations:write covers the payout requisites (creating and deleting them). The full key is shown once: keep it in environment variables and issue a separate one per server.

A key can be bound to a till: payments and payouts made with it land on that till by themselves, and no till has to be sent in the request. A till is a separate collection area inside a shop: its own payment-page design (name and logo, once approved), its own rate and hold, its own payment lifetime. The money stays shared: the balance and withdrawals belong to the shop, and a till is only reporting.

The dashboard. Sign in with email, password and the second factor; none of it is needed for API requests.

Headers

HeaderWhenValue
X-API-Keyevery requestthe merchant key: live_… or test_…
Idempotency-Keyevery POST that creates an object or moves moneya unique string up to 200 characters; use a UUID v4
Content-Typewhen there is a bodyapplication/json

The format is JSON in UTF-8. The mode comes from the key prefix: livemode in responses, test in webhooks.

Repeating a request

Idempotency-Key is required on every POST that creates an object or moves money: /payment-intents, /payment-intents/{id}/refunds, /payouts. A repeat with the same key and body returns the original response instead of creating a second object (the record lives for 24 hours). If the network dropped, retry with the same key.

Errors

Errors share one envelope; branch on error.code, not on message. Every response carries an x-request-id header for support.

JSON · error body
{
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "Request validation failed",
    "details": { "issues": ["amount: must be a positive integer in minor units"] },
    "requestId": "5f6e4d3c2b1a098877665544"
  }
}
StatusCodesWhat to do
400VALIDATION_FAILEDfix the request
401UNAUTHENTICATEDcheck the X-API-Key header
403FORBIDDENmissing scope or access
404NOT_FOUNDthe object is not in your mode
409CONFLICT, IDEMPOTENCY_IN_PROGRESSduplicate merchantOrderId or the request is still running: retry later
422IDEMPOTENCY_KEY_REQUIRED, IDEMPOTENCY_KEY_REUSED, INVALID_STATE_TRANSITION, CHECKOUT_SESSION_EXPIRED, INSUFFICIENT_BALANCE, AMOUNT_OUT_OF_RANGE, CURRENCY_NOT_SUPPORTED, PAYMENT_METHOD_UNAVAILABLE, MERCHANT_NOT_ACTIVEthe operation is not possible; retrying will not help
429, 5xxRATE_LIMITED, INTERNAL_ERROR, PROVIDER_UNAVAILABLE, PROVIDER_ERRORretry with backoff

Limits

1200 requests per minute on the key and the client address, the stricter one applies; past it 429 RATE_LIMITED, with the remainder in the x-ratelimit-remaining header. The payment window is in “Payments”, retries in “Webhooks”.

03 · Payments

Payments

POST /api/v1/payment-intents 201 response · scope payments:write

The amount is a number in major units: "amount": 100.05. A string in kopecks ("10005") is accepted too — for compatibility.

FieldTypeRequiredDescription
amountnumber | stringyesthe amount as a number in major units: 100.05 is 100.05 ₽; a kopeck string ("10005") is accepted for compatibility. A fraction finer than the currency's decimals is a 400
currencystringyescurrency code, 2–12 characters: "RUB"
customerEmailstringyesthe payer's email — the customer identifier: their payments and refunds are found by it; no emails are sent
payerIpstring ≤64nothe payer's IP; needed for H2H (fastQr) tills, otherwise the payment falls back to the payform link. An IPv4/IPv6 literal only
merchantOrderIdstringnoyour order id, up to 160 characters; unique, a repeat is a 409
descriptionstringnowhat the payer sees on the payment page, up to 500 characters
allowedMethodsstring[]norestrict the choice: "SBP", "CARD_RU", "CARD_INTERNATIONAL", "CRYPTO"
returnUrlstringnowhere to return the payer, up to 512 characters; not a payment signal
metadataobjectnoyour data, echoed in the webhook and on reads: up to 50 keys, key ≤40 characters, value ≤500, nesting ≤3, ≤8 KB

The payment window is 15 minutes from creation; picking a method extends it from the moment of the pick: SBP — 30 minutes, crypto — 60 minutes; it is never shortened. Cards take the window of the till (its “payment lifetime” setting); with no till, the original window stays.

The method is chosen once: after the pick, the same payment will not take another — the API answers PAYMENT_METHOD_UNAVAILABLE. If the pick was wrong, create a new payment.

status, feeAmount, netAmount and merchantId are server-owned: sending them fails with 400.

A Telegram storefront — the synthetic address When the shop runs as a Telegram bot, there is no need to ask for an email: pass <telegramUserId>@telegram.org as customerEmail, for example "customerEmail": "7725349911@telegram.org". This is the customer identifier: a refund is found by it (GET /api/v1/payment-intents?query=…), and no emails are sent there.
HTTP · request
POST https://api.rivarapay.io/api/v1/payment-intents HTTP/1.1
Host: api.rivarapay.io
X-API-Key: test_0f1e2d3c4b5a69788796a5b4_c2VjcmV0LXNlY3JldC1zZWNyZXQ
Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
Content-Type: application/json

{
  "amount": 2750.00,
  "currency": "RUB",
  "merchantOrderId": "order_12345",
  "customerEmail": "payer@example.test",
  "description": "Order #12345 payment",
  "returnUrl": "https://myshop.ru/payment/success",
  "metadata": { "order_id": "12345", "user_id": "u_8813" }
}
JSON · 201 response, abridged
{
  "id": "pi_01JQ8Z3M2K9V7X4N6P0R5T8W2C",
  "merchantOrderId": "order_12345",
  "livemode": false,
  "status": "CREATED",
  "amount": { "amount": "275000", "currency": "RUB", "formatted": "2 750,00 ₽" },
  "surcharge": null,
  "total": { "amount": "275000", "currency": "RUB", "formatted": "2 750,00 ₽" },
  "fee": { "amount": "13750", "currency": "RUB", "formatted": "137,50 ₽" },
  "net": { "amount": "261250", "currency": "RUB", "formatted": "2 612,50 ₽" },
  "refunded": { "amount": "0", "currency": "RUB", "formatted": "0,00 ₽" },
  "metadata": { "order_id": "12345", "user_id": "u_8813" },
  "expiresAt": "2026-10-09T12:15:00Z",
  "createdAt": "2026-10-09T12:00:00Z",
  "checkoutUrl": "https://pay.rivarapay.io/checkout/dG9rXzlmOGU3ZDZjNWI0YTNF"
}

Store the id next to the order and send the payer to checkoutUrl. Money in responses is an object {amount, currency, formatted}: amount is minor units as a string, formatted is ready to display. Do not convert either to a float.

For an H2H (“fast QR”) till, checkoutUrl is the NSPK link (https://qr.nspk.ru/...) you show the payer yourself, not our payment page. Pass the payer's payerIp on creation: without it, without a connected SBP rail, or if the provider declines, checkoutUrl stays the payform link and creation still succeeds. The payment window is 30 minutes.

CRYPTO is a first-class method: the payer picks an asset and a network from the connected provider's catalogue (USDT on 8 networks, for one) and pays to a deposit address. Crypto acceptance is attached for the shop separately — it cannot be done from the API.

Telegram Stars

If you sell Telegram Stars, pass the number of stars starsAmount (a whole number above 0) and the recipient starsRecipient (a username, 5–32 characters; a leading @ is optional) in metadata. Without them the payment is not created: 400 VALIDATION_FAILED saying that metadata.starsAmount (a whole number above 0) and metadata.starsRecipient (a Telegram username, 5–32 characters) are required for a Telegram Stars order; an invoice created without a fee price gets the same refusal at method selection.

The payer sees the order on our payment page and confirms it — there is nothing to build on your side. Do not reuse the link for other goods.

The service fee: surcharge and total

Next to amount sit surcharge (the part of the fee the payer covers; null when they cover none) and total (what is charged to them: amount + surcharge). Who pays the fee is a shop setting, not a request field: feeBearer (MERCHANT — the shop, the default; PAYER — the payer; SPLIT — with the payer's share in feePayerShareBps). Reconcile against total: the surcharge is not refunded.

The rate is per payment method, and a till may set its own terms. An invoice without allowedMethods is created without a fee price (surcharge is null, total equals amount); the fee appears on the payment page when the payer picks a method. Do not cache the total from the create response: reconcile against the total the page shows.

Statuses

StatusMeaning
CREATEDcreated, no method chosen
PENDINGmethod chosen, waiting for the payment
PROCESSINGwith the payment system, awaiting confirmation
SUCCEEDEDpaid — ship the order
FAILEDdeclined, but confirmation may still arrive
CANCELEDcancelled
EXPIREDwindow closed, a late payment may still arrive
REFUNDEDrefunded in full
PARTIALLY_REFUNDEDpartially refunded
Webhooks use a different vocabulary Events report the status in lower case: paid instead of SUCCEEDED, plus created, processing, canceled, expired, refunded.

List, search and cancel

GET /api/v1/payment-intents/{id} scope payments:read

The same object as on creation, including checkoutUrl — for a “checking the payment” screen. For an H2H payment the NSPK link exists only in the creation response; here checkoutUrl is the fallback payform link. The webhook remains the source of truth about the result.

GET /api/v1/payment-intents cursor pagination
ParameterDescription
cursorthe cursor from meta.nextCursor of the previous page
limitpage size, 1–100, 25 by default
status, methodTypecomma-separated: SUCCEEDED,PROCESSING; SBP,CARD_RU
createdFrom, createdTo, amountFrom, amountToperiod bounds and an amount band in minor units
querysearch over the payment id, merchantOrderId and the payer's email

The response is { "data": [ … ], "meta": { "nextCursor", "hasMore", "count" } }: while nextCursor is not empty there is a next page. The same filters drive a CSV export — GET /api/v1/payment-intents/export, up to 50 000 rows.

POST /api/v1/payment-intents/{id}/cancel before payment

Cancels an unpaid payment; the reason travels in the body as { "reason": "…" }, up to 240 characters.

04 · Webhooks

Webhooks

Webhooks arrive as POST at your URL from the dashboard (https://cabinet.rivarapay.io); every endpoint has its own secret. The address must be public and fast.

Delivery headers

HeaderValue
X-SignatureHMAC-SHA256 in hex, 64 characters — the body signature
X-Timestampunix time of dispatch, seconds
X-Event-Idthe event id; identical across retries — the deduplication key
X-Event-Typethe event type; for payments it may differ from event_type in the body — go by event_type
X-Delivery-Id, X-Delivery-Attemptthe delivery id and the attempt number, from 1

Event body

The body is signed as it is, on a single line. A real payment.paid delivery — 183 bytes:

JSON · payment.paid
{"event_type":"payment.paid","status":"paid","amount":"100.00","total":"100.00","currency":"RUB","test":true,"payment_id":"pi_01M4PPHS2W9AFAFY7XQ7F1QJDA","order_id":"wh-shape-fbe9fd"}

The amounts amount and total are decimal strings in major units ("100.00"), never minor units: in REST the same fields are minor units. total is what is charged to the payer (the order amount + the surcharge); there is no separate fee field. Statuses are lower case: for payments created | processing | paid | canceled | expired | refunded; for payout.* — created | pending_review | submitted | completed | failed; for payment.refunded — processing | succeeded | failed. test: true marks the test mode; metadata arrives if you sent it. Payout events carry payout_id instead of payment_id, and payment.refunded carries refund_id and order_id; they carry no total.

Event types: payment.created, payment.paid (paid — ship the order), payment.canceled, payment.expired, payment.refunded, payout.created / submitted / completed / failed.

Outside the subscription list. An endpoint subscribed to every event also receives conversion.succeeded (a successful rouble-to-USDT conversion; the body's payment_id names the converted payment) and refund.succeeded. You cannot subscribe to them individually.

Signature verification is mandatory

The signature is computed over the string {X-Timestamp}.{raw request body} with the endpoint's secret:

algorithm
expected = HMAC_SHA256(
  key  = WEBHOOK_SECRET,
  data = X-Timestamp + "." + raw_body
).hex()

if |now − X-Timestamp| is more than 300 seconds  → reject (400)
if expected ≠ X-Signature                        → reject (400)

HMAC covers the raw bytes of the body: parsing and re-serialising JSON changes key order and whitespace, and the signature will not match. Take the body before parsing: Express — express.json({ verify: (req, _res, buf) => { req.rawBody = buf; } }), Laravel — $request->getContent(), FastAPI — await request.body(). Compare in constant time: crypto.timingSafeEqual, hash_equals, hmac.compare_digest.

Node.js / Express
const express = require('express');
const crypto = require('node:crypto');

const SECRET = process.env.RIVARAPAY_WEBHOOK_SECRET;

const app = express();

// The raw body is required: the signature covers bytes.
app.use('/rivarapay/webhook', express.json({
  verify: (req, _res, buf) => { req.rawBody = buf; },
}));

app.post('/rivarapay/webhook', async (req, res) => {
  const signature = req.get('X-Signature') ?? '';
  const timestamp = req.get('X-Timestamp') ?? '';

  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return res.sendStatus(400);

  const expected = crypto.createHmac('sha256', SECRET)
    .update(`${timestamp}.${req.rawBody}`)
    .digest('hex');

  if (signature.length !== expected.length ||
      !crypto.timingSafeEqual(Buffer.from(signature, 'hex'), Buffer.from(expected, 'hex'))) {
    return res.sendStatus(400);
  }

  const event = req.body;
  res.sendStatus(200);              // answer at once, queue the work

  if (event.event_type === 'payment.paid' && !event.test) {
    await fulfilOnce(req.get('X-Event-Id'), event);   // idempotent
  }
});
Answering and retries Answer 2xx within 10 seconds; send heavy work to a queue. If the answer is not 2xx, or the server stays silent, delivery is retried with doubling: 5, 10, 20, 40 seconds and so on, the gap capped at an hour, eight attempts in total; after that the delivery is marked undelivered in the dashboard.

05 · Refunds

Refunds

POST /api/v1/payment-intents/{id}/refunds scope payments:write · Idempotency-Key required

A paid payment can be refunded in full or in part: all refunds together never exceed the amount paid.

JSON · request and response
{
  "amount": 500.00,
  "reason": "Refund requested by the customer"
}

→ 200
{
  "id": "re_01JQ8Z9X4N2M6P0R5T8W2C1D",
  "status": "PROCESSING",
  "amount": "50000",
  "currency": "RUB"
}
  • amount — a number in major units (500.00) or a kopeck string ("50000"); without it the whole remaining amount is refunded.
  • reason — up to 240 characters. The refund is debited from the available balance; if it is short — 422 INSUFFICIENT_BALANCE.

The payment.refunded webhook reports the result. The payment becomes REFUNDED or PARTIALLY_REFUNDED; the refund goes PROCESSING → SUCCEEDED, and on FAILED the money returns to the balance. The API does not list ordinary refunds — follow the webhooks. The one exception is a refund of a payment converted to USDT: GET /api/v1/payment-intents/{id}/fx-refunds (scope payments:read).

06 · Balances and payouts

Balances and payouts

GET /api/v1/balances scope balances:read
JSON · response
{
  "merchantId": "mch_01JQ8Z0A1B2C3D4E5F6G7H8J9K",
  "livemode": false,
  "balances": [
    {
      "currency": "RUB",
      "decimals": 2,
      "available": "486500",
      "pending": "120000",
      "reserved": "0",
      "total": "606500",
      "formatted": { "available": "4 865,00 ₽" }
    }
  ]
}

available is withdrawable and refundable, pending is inside the hold, reserved is locked against submitted payouts. Amounts are minor units as strings, formatted holds display strings.

Payouts

POST /api/v1/payouts scope payouts:write · Idempotency-Key required

A payout leaves the available balance — to saved requisites (destinationId from GET /api/v1/payout-destinations) or to ones passed in the request: method (CRYPTO_ADDRESS), network and address. Payouts go to crypto only: card requisites are no longer accepted. amount is a minor-unit string; the network fee comes out of it, and the amount must exceed the fee, otherwise 422 AMOUNT_OUT_OF_RANGE. The recipient receives the amount minus the network fee. The platform considers a withdrawal request. Payouts are processed by hand: the platform reviews the request, sends the funds and marks the status. The “Sent” mark is final — it moves the payout straight to “Completed” and closes the obligation to the recipient; a manual transfer has no separate “Sent” state. Until it is marked sent the payout stays in PROCESSING (“In progress”). A payout can be cancelled while it has not been sent (submitted: false); after the mark the answer is 422 INVALID_STATE_TRANSITION. Manual path: Pending → In progress → Completed; Cancelled.

For USDT networks the fee is fixed per network — it does not follow blockchain load, so it can be shown before the payout is created:

NetworkFee
TON0 USDT
TRC-203 USDT
ERC-206 USDT
GET /api/v1/payout-fees scope payouts:read

The table is machine-readable: fee is in minor units of the payout currency, feeDecimals is their scale (from the currency directory), formatted is a ready string. The recipient receives the amount minus the network fee from the table. The table is fixed: payouts are available only in USDT and only on these networks — a pair outside the table is rejected when the payout is created.

GET /api/v1/payouts is the list, GET /api/v1/payouts/{id} the status. A manual payout reports payout.created and payout.completed; payout.submitted belongs to the provider rail only. The response carries submitted: boolean — “already sent”; providerId and complianceReason are platform-internal, are never sent to a merchant and are always null. The transfer hash and the staff note are not published either. In CREATED or PENDING_REVIEW a payout can be cancelled: POST /api/v1/payouts/{id}/cancel. An approved (PROCESSING, “In progress”) payout can be cancelled while submitted: false; after the “Sent” mark it is COMPLETED, and cancellation is 422 INVALID_STATE_TRANSITION. The emergency close POST /api/v1/payouts/{id}/terminate is for a provider payout in SUBMITTED only: returning money for crypto already sent by hand is not allowed.

07 · Test mode and launch

Test mode and launch

On a test_… key the sandbox runs the whole cycle: payments, the payment page, statuses, refunds, payouts and webhooks.

  • The modes are separate: test_ and live_ have their own payments and balances; a test payment never reaches a live balance.
  • Do not enter a real card on the test payment page.
  • An event with "test": true must not ship a real order — check it before going live.
Going live Swap the key for a live live_… one and the webhook URL — the code does not change. Run the checklist on the first live payment.

Launch checklist

  • amount is a number in major units (or a kopeck string); nothing does floating-point arithmetic on money.
  • Every creating POST carries an Idempotency-Key, reused on a retry; the key and the webhook secret live in environment variables.
  • The payer goes to the checkoutUrl, and the order ships on payment.paid only.
  • The handler takes the raw body, verifies HMAC-SHA256 with a ±300 second window and constant-time comparison, answers 2xx, deduplicates by X-Event-Id, checks the amount against the order, and never ships on "test": true.
  • Errors are handled by HTTP status and error.code; retries happen only on 429 and 5xx.