TsaraPay
Sign in Contact us
PAYIN API · Documentation

Payments built for casinos and forex.

One API for card, UPI and crypto deposits. Create an invoice, redirect your Customer to the hosted payment page, settle in USDC, and reconcile with signed webhook callbacks.

Trusted by iGaming & forex operators worldwide
PAYIN · Environment LIVE
BASE URL  https://app.tsarapay.com
~2 min
Payouts
3
Methods
USDC
Settled
CARDVisa · Mastercard
UPIINR
CRYPTOUSDT · POLYGON
Getting started · I

Prerequisites

Complete these steps before your first API call.

01

Create your account

Register your merchant account at app.tsarapay.com/signup, or request access via tsarapay.com/#contact. The form takes under 5 minutes — have your company name, website URL, and operating vertical (casino, forex, etc.) on hand.

API access requires manual activation. After sign-up, email contact@tsarapay.com to go live. Our team will (1) issue your API-KEY and (2) register the IP address(es) your server will call the API from. Requests from unregistered IPs are rejected at the gateway level.
02

Add your settlement wallet

Open your profile at app.tsarapay.com/client/profile and add your wallet address in the dedicated block.

  1. Go to app.tsarapay.com/client/profile and log in.
  2. Scroll to the Settlement wallet block.
  3. Paste your USDC wallet address (TRC-20 or ERC-20) into the input field.
  4. Click Save. All future payouts will be sent to this address.
03

Set your callback URL

In the API block (app.tsarapay.com/client/api), enter your Callback Payin URL. TsaraPay calls this URL to notify you of each invoice's status — once right after creation (invoice:created) and again after payment (invoice:paid).

  1. Go to app.tsarapay.com/client/api.
  2. Find the Callback Payin URL field in the API block.
  3. Enter the full HTTPS URL of your webhook endpoint (e.g. https://yourdomain.com/webhooks/tsarapay).
  4. Click Save.
Note. Your callback endpoint must accept an HTTP POST and always reply quickly with 200 OK. TsaraPay will call it once on invoice creation (invoice:created) and again on payment (invoice:paid). For WooCommerce, use the dedicated plugin available from your profile page.
Getting started · II

How to use the API

All endpoints are served from a single production base URL. Pass your API-KEY header on every request.

EnvironmentBase URL
Productionhttps://app.tsarapay.com
request.sh
curl -X GET "https://app.tsarapay.com/resource" \
  -H "API-KEY: YOUR_API_KEY"
Getting started

Authentication

Authenticate every request with the API key TsaraPay issued to you, passed as an HTTP header named API-KEY. Calls are additionally restricted to the IP address(es) registered on your account.

header
API-KEY: 0d8d8e89a6cdcd
Keep it server-side. Never expose your API key in front-end or browser code — see Integration. Treat it like a password.
Create an invoice

Credit card POST

Create a card invoice. The request is an HTTP POST and your API key travels in the API-KEY header.

POSThttps://app.tsarapay.com/api/btn-create-invoice/get/

Body parameters

ParameterExampleDescription
emailrequiredalice@domain.comYour Customer's email address.
amountrequired15.04 or 42Invoice amount. Use . as the decimal separator.
deviserequiredUSDTransaction currency (ISO 4217). Supported: USD, EUR, GBP, INR, ZAR.
success_urloptional…/service/pay/success/Redirect target after a successful payment.
cancel_urloptional…/service/pay/cancel/Redirect target after a cancelled payment.
pending_urloptional…/service/pay/pending/Redirect target when the payment is still pending.
failure_urloptionalString | nullRedirect target after a failed or declined payment.
callbackJsonoptional{"txId":"qktr12eqzg"}Merchant data (JSON). Echoed back to you on the callback URL.
nameS2SJohn SmithUsed as the cardholder name.
address1S2S1000 Lombard StBilling address line 1.
address2S2SApt 4Billing address line 2.
cityS2SSan FranciscoBilling city.
countryS2SDEBilling country, 2-char code (ISO 3166-1 alpha-2).
stateoptionalNew YorkBilling state/region.
postcodeS2S90210Billing postal code.
date_of_birthS2S1990-12-31Cardholder date of birth.
card_numberS2S4242424242424242Card number.
card_expiry_dateS2S02/2025Card expiry (MM/YYYY).
card_ccvS2S000Card security code.
customer_ipS2S127.0.0.1Customer IPv4. Mandatory in S2S mode.
phoneS2S020 7946 0018Customer phone. Mandatory in S2S mode.
pay_modeoptionalcardUse only with support's agreement.
payment_solution_typeoptionalCARD | UPI | CRYPTOUse only with support's agreement.
payment_solution_nameoptionalProvided by supportUse only with support's agreement.
S2S = server-to-server direct mode. Those fields are required only if you collect card data yourself; for the hosted redirect flow you can omit them.

Response

The service returns a JSON object. errorCode: 0 means success; any other code is an error.

Error codes

CodeMeaning
50001API-KEY required
50002email required
50003amount required
50004devise required
50005invalid email address
50006this API-KEY cannot be used from this IP address
50007invalid API-KEY
50008Wallet is being validated/activated; you'll get a confirmation email once done. Meanwhile you can edit it from your profile page.
50009invalid devise
50010No IP linked to your account. Add them in the profile → API block.
50011Amount is above the allowed maximum
50012Amount is below the allowed minimum
error.json
{ "errorCode": 50003, "errorMessage": "amount required" }

Success example

On success you receive a redirectUrl (use it for automatic redirection, and to complete 3-D Secure in S2S direct) and an html anchor snippet you can drop into your page. In S2S direct mode you also receive status and ID.

success.json
{
  "errorCode": 0,
  "redirectUrl": "https://app.tsarapay.com/widget/sale/create/?token=cyR0YnNOe...",
  "html": "<a href='https://app.tsarapay.com/widget/sale/create/?token=cyR0YnNOe...'></a>"
}
Create an invoice

UPI POST

Create a UPI invoice. HTTP POST, API key in the API-KEY header.

POSThttps://app.tsarapay.com/api/btn-create-invoice/get/

Body parameters

ParameterExampleDescription
emailrequiredalice@domain.comYour Customer's email address.
amountrequired15.04 or 42Invoice amount. Use . as the decimal separator.
deviserequiredINRMust be INR. Convert on your side if you price in another currency.
nameoptionalJaya JamesYour Customer's name.
personal_idoptional45861024531Payer identity ID (11 digits).
success_urloptional…/service/pay/success/Redirect after a successful payment.
cancel_urloptional…/service/pay/cancel/Redirect after a cancelled payment.
pending_urloptional…/service/pay/pending/Redirect while the payment is pending.
failure_urloptionalString | nullRedirect after a failed/declined payment.
callbackJsonoptional{"txId":"qktr12eqzg"}Merchant data (JSON), echoed on the callback.
payment_solution_typeoptionalCARD | UPI | CRYPTOUse only with support's agreement.
payment_solution_nameoptionalProvided by supportUse only with support's agreement.

Response

Returns a JSON object. Same error codes as the card endpoint (5000150012).

success.json
{
  "errorCode": 0,
  "redirectUrl": "https://app.tsarapay.com/widget/sale/create/?token=cyR0YnNOe...",
  "html": "<a href='https://app.tsarapay.com/widget/sale/create/?token=cyR0YnNOe...'></a>"
}
Create an invoice

Crypto POST

Create a crypto invoice. HTTP POST, API key in the API-KEY header.

POSThttps://app.tsarapay.com/api/btn-create-invoice/get/

Body parameters

ParameterExampleDescription
emailrequiredalice@domain.comYour Customer's email address.
amountrequired15.04 or 42Invoice amount. Use . as the decimal separator.
deviserequiredUSDMust be USD. Convert on your side if you price in another currency.
payableCurrenciesS2SUSDT_polygonPayable currency value (e.g. USDT_polygon). Mandatory in S2S mode.
success_urloptional…/service/pay/success/Redirect after a successful payment.
cancel_urloptional…/service/pay/cancel/Redirect after a cancelled payment.
failure_urloptionalString | nullRedirect after a failed/declined payment.
callbackJsonoptional{"txId":"qktr12eqzg"}Merchant data (JSON), echoed on the callback.
payment_solution_typeoptionalCARD | UPI | CRYPTOUse only with support's agreement.
payment_solution_nameoptionalProvided by supportUse only with support's agreement.

Response

Returns a JSON object. Same error codes as the card endpoint (5000150012).

success.json
{
  "errorCode": 0,
  "redirectUrl": "https://app.tsarapay.com/widget/sale/create/?token=cyR0YnNOe...",
  "html": "<a href='https://app.tsarapay.com/widget/sale/create/?token=cyR0YnNOe...'></a>"
}
Read invoices

Get an invoice status GET

Fetch the current status of a single invoice. HTTP GET, API key in the API-KEY header.

GEThttps://app.tsarapay.com/api/invoice/status/

Query parameters

ParameterExampleDescription
idrequired185The invoice ID delivered through the callback.

Error codes

CodeMeaning
50001API-KEY required
50002id required
50007invalid API-KEY
50010No IP linked to your account
50011This invoice belongs to another merchant
status.json
{
  "errorCode": 0,
  "invoice": { "id": "1689", "devise": "USD", "amount": "4", "status": "invoice:created" }
}
Auto-expiry. An invoice left in CREATED or OPENED for more than 14 days transitions automatically to invoice:expired.
Read invoices

Get invoice info GET

Retrieve full details for one invoice. HTTP GET, API key in the API-KEY header.

GEThttps://app.tsarapay.com/api/client-invoice-info/get/

Query parameters

ParameterExampleDescription
idrequired185The invoice ID delivered through the callback.

Error codes match Get an invoice status.

info.json
{
  "errorCode": 0,
  "merchant_id": "1",
  "invoice_id": "1689",
  "data": {
    "status": "invoice:paid",
    "id": 1736,
    "devise": "USD",
    "amount": 5,
    "description": "Payment of the invoice has been made successfully",
    "callbackJson": null,
    "fiat_amount": 409.71,
    "fiat_currency": "INR",
    "totalAmount": 4,
    "totalCurrency": "USDC",
    "datetime": "2023-04-12 19:09:48"
  }
}
info.php
// Install php-curl-class: composer require php-curl-class/php-curl-class
require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;

$API_KEY = ''; // Your API-KEY (issued by TsaraPay)

$url = 'https://app.tsarapay.com/api/client-invoice-info/get/';
$data = [ 'id' => 185 ];

$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setHeader('API-KEY', $API_KEY);
$curl->post($url, $data);

if ($curl->error) {
    echo 'Error: ' . $curl->errorMessage;
} else if ($curl->response->errorCode == 0) {
    var_dump($curl->response); // invoice info payload
} else {
    var_dump($curl->response); // { errorCode, errorMessage }
}
Read invoices

Get invoice history GET

List your invoices with filtering and pagination. HTTP GET, API key in the API-KEY header.

GEThttps://app.tsarapay.com/api/invoices/history/

Query parameters

ParameterExampleDescription
statusPAIDPAID · UNPAID · WAITING (awaiting approval) · EXPIRED (CREATED/OPENED > 14 days) · ALL.
from2023-06-01Start date filter.
to2023-06-19End date filter.
orderASCASC ascending or DESC descending, by date.
page2Page number. Max 50 records per page.

Error codes

CodeMeaning
50001API-KEY required
50006You cannot use this API from this IP address
50007invalid API-KEY
50010No IP linked to your account
50012Invalid order — must be ASC or DESC
history.json
{
  "errorCode": 0,
  "status": "PAID",
  "from": "2023-06-01",
  "to": "2023-06-19",
  "page": 2,
  "order": "DESC",
  "list": [
    {
      "id": "1932",
      "email": "buyer@gmail.com",
      "status": "PAID",
      "amount": "1.00",
      "symbol": "USD",
      "create_date": "2023-06-15 10:39:34",
      "status_date": "2023-06-15 10:40:38",
      "tx_hash": "0xda4fd344e6310738db73dabdb42a213a38f14d2379b13c27fe86f8452002d4c5",
      "exchange_currency_symbol": "USDC",
      "paid_amount": "1.00",
      "merchant_amount": "0.900",
      "fee_amount": "0.100",
      "ip": "102.117.124.254",
      "country": "United Arab Emirates",
      "success_url": null,
      "pending_url": null,
      "cancel_url": null
    }
  ],
  "total": "51"
}
history.php
// composer require php-curl-class/php-curl-class
require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;

$API_KEY = ''; // Your API-KEY
$url = 'https://app.tsarapay.com/api/invoices/history/';

$data = [
  'status' => 'PAID',
  'from'   => '2023-06-01',
  'to'     => '2023-06-19',
  'order'  => 'ASC',
  'page'   => 2,
];

$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setHeader('API-KEY', $API_KEY);
$curl->post($url, $data);

if ($curl->error) {
    echo 'Error: ' . $curl->errorMessage;
} else {
    var_dump($curl->response);
}
Integrate · III

Integration

Server-to-server only. Do not call the API directly from AJAX or any browser request — those are rejected, and calls from unknown or unregistered IPs are blocked. If you need to trigger a request from the browser, call a script on your server, which then calls TsaraPay.
create-invoice.php
// composer require php-curl-class/php-curl-class
require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;

$API_KEY = ''; // Your API-KEY (issued by TsaraPay)

// Invoice creation endpoint (IP-restricted call)
$url = 'https://app.tsarapay.com/api/btn-create-invoice/get/';

$data = [
  'email'  => 'buyer' . date('His') . '@example.com',
  'amount' => 1,
  'devise' => 'USD',
];

$curl = new Curl();
$curl->setHeader('Content-Type', 'application/json');
$curl->setHeader('API-KEY', $API_KEY);
$curl->post($url, $data);

if ($curl->error) {
    echo 'Error: ' . $curl->errorMessage . "\n";
} else if ($curl->response->errorCode == 0) {
    echo 'redirectUrl: ' . $curl->response->redirectUrl . "\n";
    echo 'html: ' . $curl->response->html . "\n";
} else {
    echo $curl->response->errorMessage . "\n";
}
Integrate · IV

Webhook notifications (callbacks)

Once you set a callback URL in your dashboard, TsaraPay notifies it on every payment operation — success or failure. Each notification is an HTTP POST with a JSON body and a signature header.

  • Header X-Signature — HMAC signature you use to confirm the notification really came from TsaraPay (see the PHP verification below).
  • Header Content-Type: application/json
  • Body — POST variables in JSON.

Status values

status valueLabelDescription
invoice:createdCREATEDInvoice successfully created.
invoice:openedOPENEDInvoice created and the Customer was redirected to the payment page.
invoice:paidPAIDAfter settlement, the equivalent USDT (POLYGON) amount is transferred to your ERC-20 wallet and the status becomes paid.
invoice:failedFAILEDAn error occurred.
invoice:awaiting_approvalWAITING SETTLEMENTCustomer payment succeeded — you may already credit their balance.
invoice:chargebackCHARGEBACKChargeback raised.
invoice:refundREFUNDPayment refunded.

Other body fields

FieldTypeDescription
devisestringCurrency symbol (currently USD).
amountdecimalAmount in USD.
idintegerSale / invoice ID.
descriptionstringHuman-readable status description.
callbackJsonstringThe merchant data you sent in callbackJson.
notification.paid.json
{
  "status": "invoice:paid",
  "devise": "USD",
  "amount": "1500.00",
  "id": "15515",
  "description": "Invoice paid",
  "callbackJson": "{\"txId\":\"qktr12eqzg\",\"status\":\"sfrt\"}"
}
notification.failed.json
{
  "status": "invoice:failed",
  "description": "An error occurred",
  "id": "15515",
  "callbackJson": "{\"txId\":\"qktr12eqzg\",\"status\":\"sfrt\"}"
}
Whitelist the source IP. Callbacks originate from TsaraPay's dedicated notification IP. Confirm the current address with your account manager before whitelisting it.
verify-signature.php
// ---- Read POST parameters
$id           = intval($_POST['id']);
$status       = $_POST['status'];
$devise       = $_POST['devise'];
$amount       = floatval($_POST['amount']);
$description  = $_POST['description'];
$callbackJson = $_POST['callbackJson'];

// ---- Read the signature header
$signatureKey = 'X-Signature';
$headers = [];
if (function_exists('apache_request_headers')) {
    $headers = apache_request_headers();
} else {
    foreach ($_SERVER as $key => $value) {
        if (substr($key, 0, 5) == "HTTP_") {
            $key = str_replace(" ", "-",
                ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
            $headers[$key] = $value;
        }
    }
}
$signature = $headers[$signatureKey];

// ---- Recompute the HMAC-SHA256 hash with YOUR API key
$hashData = hash_hmac('sha256',
    json_encode([
        'id'     => $id,
        'amount' => $amount,
        'devise' => $devise,
        'status' => $status,
    ]),
    $YOUR_API_KEY // the API-KEY TsaraPay issued to you
);

// ---- Compare
if (hash_equals($hashData, $signature)) {
    // OK — trusted. Insert / update your records.
} else {
    // KO — reject the notification.
}
Reference · V

Failed reasons

Credit card — Visa & Mastercard

Failed reasonDescription
3D authentication failed / expiredThe Customer did not complete the extra security step (e.g. one-time password) — often due to wrong details, a timeout, or a technical issue.
Unknown error · Generic decline · No acquirers to chooseGeneric messages. Our error mapping keeps improving; contact us and we'll investigate specific cases.
Cannot authorizeDeclined by the Customer's bank — possibly insufficient funds, fraud rules, or another cardholder issue. Investigate case by case.
Suspected fraudCould indicate several underlying issues; investigate each transaction individually.
User is bannedPermanent ban triggered after attempts with more than five different cards (flagged as fraud). Do not route this user to us again.
User is suspended24-hour suspension after 5 consecutive failed/expired transactions.
Transaction expired without paymentThe Customer had trouble reaching the payment page — often ad blockers or connectivity problems.
Transaction not permitted to cardholderUsually the issuing bank does not permit this transaction.
Validation failedAuthentication-related error; investigate each transaction individually.
Card is restricted or blockedInvestigate to determine why the card is blocked.
Card is blacklisted on acquirer sideThe card was blacklisted by the acquirer's anti-fraud system.
Email validation failedThe email is invalid or undeliverable. Ensure it's accurate for a successful transaction.
User cancelled the transactionThe Customer cancelled and abandoned the payment.
Do not honourCan mean several underlying issues; investigate individually.
Transaction expired · TimeoutThe processing window closed, usually because the Customer abandoned the flow.
Exceeds card limitsFrom the issuing bank — the Customer exceeded their card limits. Advise them to contact their bank.
Error from issuing bankBank-side issue; individual investigation required.

Checkout — grouped rejection categories

  1. Contact bank. Declined by the issuer ("do not honour", restricted card, not permitted, issuer inoperative, lost/stolen, suspected fraud). The Customer should contact their bank to authorize.
  2. General rejection. Invalid transaction, routing/system error, not permitted at terminal, general failure, timeout. The Customer can retry later or contact support.
  3. 3DS-related. 3-D Secure failed, challenge failed/timed out, card not 3DS-enrolled. Retry or use a 3DS-capable card.
  4. Payment not funded. Insufficient funds or no linked account. The Customer must top up or use another method.
  5. Bad scoring (fraud check). Blocked by the fraud engine as high risk. The Customer should complete KYC or contact support.
  6. Invalid CVV. Wrong CVV/CVC. The Customer should re-enter the correct value.
  7. Card blocked or expired. Expired/blocked card or invalid details. Check details or use another card.
  8. Edge / system errors. Unexpected system error or communication failure. Retry later or contact the bank.
MCC-related rejections. When a bank blocks based on the Merchant Category Code, it usually surfaces as "declined by the card issuer" or "not permitted at terminal" — mapping to the Contact bank or General rejection categories above.
Support

API-first, never alone

Stuck on an integration, or need your API key and IP whitelisted? A dedicated engineer will get you live. Manage your keys, wallet and callbacks anytime at app.tsarapay.com.

Ready to get paid, properly?

Request integration access and we'll set up your keys and IP whitelist.