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.
Prerequisites
Complete these steps before your first API call.
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.
Add your settlement wallet
Open your profile at app.tsarapay.com/client/profile and add your wallet address in the dedicated block.
- Go to app.tsarapay.com/client/profile and log in.
- Scroll to the Settlement wallet block.
- Paste your USDC wallet address (TRC-20 or ERC-20) into the input field.
- Click Save. All future payouts will be sent to this address.
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).
- Go to app.tsarapay.com/client/api.
- Find the Callback Payin URL field in the API block.
- Enter the full HTTPS URL of your webhook endpoint (e.g.
https://yourdomain.com/webhooks/tsarapay). - Click Save.
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.How to use the API
All endpoints are served from a single production base URL. Pass your API-KEY header on every request.
| Environment | Base URL |
|---|---|
| Production | https://app.tsarapay.com |
curl -X GET "https://app.tsarapay.com/resource" \
-H "API-KEY: YOUR_API_KEY"
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.
API-KEY: 0d8d8e89a6cdcd
Credit card POST
Create a card invoice. The request is an HTTP POST and your API key travels in the API-KEY header.
https://app.tsarapay.com/api/btn-create-invoice/get/Body parameters
| Parameter | Example | Description |
|---|---|---|
| emailrequired | alice@domain.com | Your Customer's email address. |
| amountrequired | 15.04 or 42 | Invoice amount. Use . as the decimal separator. |
| deviserequired | USD | Transaction 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_urloptional | String | null | Redirect target after a failed or declined payment. |
| callbackJsonoptional | {"txId":"qktr12eqzg"} | Merchant data (JSON). Echoed back to you on the callback URL. |
| nameS2S | John Smith | Used as the cardholder name. |
| address1S2S | 1000 Lombard St | Billing address line 1. |
| address2S2S | Apt 4 | Billing address line 2. |
| cityS2S | San Francisco | Billing city. |
| countryS2S | DE | Billing country, 2-char code (ISO 3166-1 alpha-2). |
| stateoptional | New York | Billing state/region. |
| postcodeS2S | 90210 | Billing postal code. |
| date_of_birthS2S | 1990-12-31 | Cardholder date of birth. |
| card_numberS2S | 4242424242424242 | Card number. |
| card_expiry_dateS2S | 02/2025 | Card expiry (MM/YYYY). |
| card_ccvS2S | 000 | Card security code. |
| customer_ipS2S | 127.0.0.1 | Customer IPv4. Mandatory in S2S mode. |
| phoneS2S | 020 7946 0018 | Customer phone. Mandatory in S2S mode. |
| pay_modeoptional | card | Use only with support's agreement. |
| payment_solution_typeoptional | CARD | UPI | CRYPTO | Use only with support's agreement. |
| payment_solution_nameoptional | Provided by support | Use only with support's agreement. |
Response
The service returns a JSON object. errorCode: 0 means success; any other code is an error.
Error codes
| Code | Meaning |
|---|---|
50001 | API-KEY required |
50002 | email required |
50003 | amount required |
50004 | devise required |
50005 | invalid email address |
50006 | this API-KEY cannot be used from this IP address |
50007 | invalid API-KEY |
50008 | Wallet is being validated/activated; you'll get a confirmation email once done. Meanwhile you can edit it from your profile page. |
50009 | invalid devise |
50010 | No IP linked to your account. Add them in the profile → API block. |
50011 | Amount is above the allowed maximum |
50012 | Amount is below the allowed minimum |
{ "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.
{
"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>"
}
UPI POST
Create a UPI invoice. HTTP POST, API key in the API-KEY header.
https://app.tsarapay.com/api/btn-create-invoice/get/Body parameters
| Parameter | Example | Description |
|---|---|---|
| emailrequired | alice@domain.com | Your Customer's email address. |
| amountrequired | 15.04 or 42 | Invoice amount. Use . as the decimal separator. |
| deviserequired | INR | Must be INR. Convert on your side if you price in another currency. |
| nameoptional | Jaya James | Your Customer's name. |
| personal_idoptional | 45861024531 | Payer 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_urloptional | String | null | Redirect after a failed/declined payment. |
| callbackJsonoptional | {"txId":"qktr12eqzg"} | Merchant data (JSON), echoed on the callback. |
| payment_solution_typeoptional | CARD | UPI | CRYPTO | Use only with support's agreement. |
| payment_solution_nameoptional | Provided by support | Use only with support's agreement. |
Response
Returns a JSON object. Same error codes as the card endpoint (50001–50012).
{
"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>"
}
Crypto POST
Create a crypto invoice. HTTP POST, API key in the API-KEY header.
https://app.tsarapay.com/api/btn-create-invoice/get/Body parameters
| Parameter | Example | Description |
|---|---|---|
| emailrequired | alice@domain.com | Your Customer's email address. |
| amountrequired | 15.04 or 42 | Invoice amount. Use . as the decimal separator. |
| deviserequired | USD | Must be USD. Convert on your side if you price in another currency. |
| payableCurrenciesS2S | USDT_polygon | Payable 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_urloptional | String | null | Redirect after a failed/declined payment. |
| callbackJsonoptional | {"txId":"qktr12eqzg"} | Merchant data (JSON), echoed on the callback. |
| payment_solution_typeoptional | CARD | UPI | CRYPTO | Use only with support's agreement. |
| payment_solution_nameoptional | Provided by support | Use only with support's agreement. |
Response
Returns a JSON object. Same error codes as the card endpoint (50001–50012).
{
"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>"
}
Get an invoice status GET
Fetch the current status of a single invoice. HTTP GET, API key in the API-KEY header.
https://app.tsarapay.com/api/invoice/status/Query parameters
| Parameter | Example | Description |
|---|---|---|
| idrequired | 185 | The invoice ID delivered through the callback. |
Error codes
| Code | Meaning |
|---|---|
50001 | API-KEY required |
50002 | id required |
50007 | invalid API-KEY |
50010 | No IP linked to your account |
50011 | This invoice belongs to another merchant |
{
"errorCode": 0,
"invoice": { "id": "1689", "devise": "USD", "amount": "4", "status": "invoice:created" }
}
CREATED or OPENED for more than 14 days transitions automatically to invoice:expired.Get invoice info GET
Retrieve full details for one invoice. HTTP GET, API key in the API-KEY header.
https://app.tsarapay.com/api/client-invoice-info/get/Query parameters
| Parameter | Example | Description |
|---|---|---|
| idrequired | 185 | The invoice ID delivered through the callback. |
Error codes match Get an invoice status.
{
"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"
}
}
// 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 }
}
Get invoice history GET
List your invoices with filtering and pagination. HTTP GET, API key in the API-KEY header.
https://app.tsarapay.com/api/invoices/history/Query parameters
| Parameter | Example | Description |
|---|---|---|
| status | PAID | PAID · UNPAID · WAITING (awaiting approval) · EXPIRED (CREATED/OPENED > 14 days) · ALL. |
| from | 2023-06-01 | Start date filter. |
| to | 2023-06-19 | End date filter. |
| order | ASC | ASC ascending or DESC descending, by date. |
| page | 2 | Page number. Max 50 records per page. |
Error codes
| Code | Meaning |
|---|---|
50001 | API-KEY required |
50006 | You cannot use this API from this IP address |
50007 | invalid API-KEY |
50010 | No IP linked to your account |
50012 | Invalid order — must be ASC or DESC |
{
"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"
}
// 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);
}
Integration
// 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";
}
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 value | Label | Description |
|---|---|---|
| invoice:created | CREATED | Invoice successfully created. |
| invoice:opened | OPENED | Invoice created and the Customer was redirected to the payment page. |
| invoice:paid | PAID | After settlement, the equivalent USDT (POLYGON) amount is transferred to your ERC-20 wallet and the status becomes paid. |
| invoice:failed | FAILED | An error occurred. |
| invoice:awaiting_approval | WAITING SETTLEMENT | Customer payment succeeded — you may already credit their balance. |
| invoice:chargeback | CHARGEBACK | Chargeback raised. |
| invoice:refund | REFUND | Payment refunded. |
Other body fields
| Field | Type | Description |
|---|---|---|
| devise | string | Currency symbol (currently USD). |
| amount | decimal | Amount in USD. |
| id | integer | Sale / invoice ID. |
| description | string | Human-readable status description. |
| callbackJson | string | The merchant data you sent in callbackJson. |
{
"status": "invoice:paid",
"devise": "USD",
"amount": "1500.00",
"id": "15515",
"description": "Invoice paid",
"callbackJson": "{\"txId\":\"qktr12eqzg\",\"status\":\"sfrt\"}"
}
{
"status": "invoice:failed",
"description": "An error occurred",
"id": "15515",
"callbackJson": "{\"txId\":\"qktr12eqzg\",\"status\":\"sfrt\"}"
}
// ---- 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.
}
Failed reasons
Credit card — Visa & Mastercard
| Failed reason | Description |
|---|---|
| 3D authentication failed / expired | The 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 choose | Generic messages. Our error mapping keeps improving; contact us and we'll investigate specific cases. |
| Cannot authorize | Declined by the Customer's bank — possibly insufficient funds, fraud rules, or another cardholder issue. Investigate case by case. |
| Suspected fraud | Could indicate several underlying issues; investigate each transaction individually. |
| User is banned | Permanent ban triggered after attempts with more than five different cards (flagged as fraud). Do not route this user to us again. |
| User is suspended | 24-hour suspension after 5 consecutive failed/expired transactions. |
| Transaction expired without payment | The Customer had trouble reaching the payment page — often ad blockers or connectivity problems. |
| Transaction not permitted to cardholder | Usually the issuing bank does not permit this transaction. |
| Validation failed | Authentication-related error; investigate each transaction individually. |
| Card is restricted or blocked | Investigate to determine why the card is blocked. |
| Card is blacklisted on acquirer side | The card was blacklisted by the acquirer's anti-fraud system. |
| Email validation failed | The email is invalid or undeliverable. Ensure it's accurate for a successful transaction. |
| User cancelled the transaction | The Customer cancelled and abandoned the payment. |
| Do not honour | Can mean several underlying issues; investigate individually. |
| Transaction expired · Timeout | The processing window closed, usually because the Customer abandoned the flow. |
| Exceeds card limits | From the issuing bank — the Customer exceeded their card limits. Advise them to contact their bank. |
| Error from issuing bank | Bank-side issue; individual investigation required. |
Checkout — grouped rejection categories
- 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.
- General rejection. Invalid transaction, routing/system error, not permitted at terminal, general failure, timeout. The Customer can retry later or contact support.
- 3DS-related. 3-D Secure failed, challenge failed/timed out, card not 3DS-enrolled. Retry or use a 3DS-capable card.
- Payment not funded. Insufficient funds or no linked account. The Customer must top up or use another method.
- Bad scoring (fraud check). Blocked by the fraud engine as high risk. The Customer should complete KYC or contact support.
- Invalid CVV. Wrong CVV/CVC. The Customer should re-enter the correct value.
- Card blocked or expired. Expired/blocked card or invalid details. Check details or use another card.
- Edge / system errors. Unexpected system error or communication failure. Retry later or contact the bank.
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.