The GaisPay API.
A small, predictable REST API: create a payment, send your customer to the checkout, fulfil the order on a signed webhook. JSON over HTTPS, nothing more.
curl https://api.gaispay.com/v1/payments \
-u "$GAISPAY_API_KEY:" \
-H "Idempotency-Key: order-1042" \
-d amount=249.00 \
-d currency=USD \
-d order_id=1042const res = await fetch("https://api.gaispay.com/v1/payments", {
method: "POST",
headers: { Authorization: `Bearer ${KEY}` },
body: JSON.stringify({
amount: "249.00", currency: "USD", order_id: "1042"
})
});r = requests.post(
"https://api.gaispay.com/v1/payments",
auth=(os.environ["GAISPAY_API_KEY"], ""),
json={"amount": "249.00", "currency": "USD",
"order_id": "1042"})
print(r.json()["checkout_url"])
{ "id": "inv_8f2c…41a7", "status": "pending",
"checkout_url": "https://pay.gaispay.com/pay/inv_8f2c…" }webhook → invoice.paid200 OK ✓Introduction
The API uses resource-oriented URLs and standard HTTP status codes. Send requests as application/json or application/x-www-form-urlencoded; responses are always JSON. Amounts are decimal strings ("249.00") and timestamps are Unix seconds.
Every response includes an X-Request-Id header — quote it when you contact support.
Authentication
Authenticate with the API key from your dashboard (Developers → API key). Send it as the HTTP Basic user name with an empty password, or as a Bearer token. Rotating the key in the dashboard disables the old one immediately.
# Basic: key as user name, empty password curl https://api.gaispay.com/v1/balances -u "$GAISPAY_API_KEY:" # or Bearer curl https://api.gaispay.com/v1/balances -H "Authorization: Bearer $GAISPAY_API_KEY"
Quickstart
1. Create a payment from your server. 2. Redirect the customer to checkout_url. 3. When invoice.paid arrives at your webhook, verify the signature and fulfil the order.
curl https://api.gaispay.com/v1/payments \ -u "$GAISPAY_API_KEY:" \ -H "Idempotency-Key: order-1042" \ -d amount=249.00 \ -d currency=USD \ -d order_id=1042 \ -d description="Order 1042" \ -d success_url="https://shop.example/thanks"
// Node.js const res = await fetch("https://api.gaispay.com/v1/payments", { method: "POST", headers: { Authorization: `Bearer ${process.env.GAISPAY_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-1042", }, body: JSON.stringify({ amount: "249.00", currency: "USD", order_id: "1042" }), }); const payment = await res.json(); // redirect the customer to payment.checkout_url
Payment lifecycle
The status field of a payment is one of the values below. Status changes send the webhooks listed under Webhook events.
| Status | Meaning |
|---|---|
pending | Waiting for the customer to pay. |
confirming | The transfer was seen on-chain and is being confirmed. |
paid | Confirmed and credited to your balance. A paid payment never changes status again. |
underpaid | Less than requested arrived. The received amount is still credited; you decide whether to fulfil or refund. |
expired | The 30-minute window passed without payment. |
Extra detail is returned in flags: overpaid (more than requested arrived) and late (paid after the window). A refund sent for a payment triggers invoice.refunded and is shown on the payment in the dashboard.
Idempotency
Add an Idempotency-Key header (1–128 printable characters) when creating a payment. Retrying with the same key returns the original payment with 200 and Idempotent-Replayed: true instead of creating a second one. Reusing a key with different parameters returns 409 idempotency_key_reused.
Pagination
List endpoints return the newest records first and accept limit (1–100, default 25) and offset. total is the number of records matching your filter. Payments can be filtered by status and order_id.
curl -G https://api.gaispay.com/v1/payments -u "$GAISPAY_API_KEY:" -d status=paid -d limit=25 { "total": 132, "limit": 25, "offset": 0, "data": [ … ] }
Errors
Errors return a non-2xx status and a body with a machine-readable code and a human-readable message.
{ "error": { "code": "invalid_amount", "message": "amount must be between 1.00 and 1000000.00" } }| HTTP | Code | What to do |
|---|---|---|
| 400 | invalid_amount | Amount must be 1.00–1,000,000.00 with at most two decimals. |
| 400 | invalid_currency | Use USD, EUR, GBP or TRY. |
| 400 | invalid_asset | Use an asset code from GET /v1/assets. |
| 400 | invalid_body | The body is not valid JSON or form data. |
| 401 | unauthorized | The API key is missing or invalid. |
| 403 | merchant_suspended | The account is suspended — contact support. |
| 404 | not_found | The record does not exist or belongs to another account. |
| 409 | idempotency_key_reused | Same key, different parameters. |
| 409 | plan_inactive | The plan is not available for new subscriptions. |
| 409 | already_canceled | The subscription is already canceled. |
| 429 | rate_limited | Too many requests — retry with increasing delays. |
| 503 | rates_unavailable | Exchange rates are briefly unavailable — retry shortly. |
| 500 | internal_error | Retry with the same idempotency key. |
Rate limits
Each API key may make 300 requests per minute. Prefer webhooks over polling for payment status.
Payments
POST/v1/payments creates a payment and returns its checkout_url. The same resource is also available as /v1/invoices.
amountdecimal string · required"249.00". Between 1.00 and 1,000,000.00.currencystring · requiredUSD, EUR, GBP or TRY.order_idstring · optionaldescriptionstring · optionalassetstring · optionalUSDT_TRC20, USDC_SPL, BTC); the address and exact amount are returned immediately. Otherwise the customer chooses on the checkout.success_urlurl · optionalredirect_url).// 201 Created { "id": "inv_e64d63c31bf396a0e5c2dacb", "status": "pending", "order_id": "1042", "amount": "249.00", "currency": "USD", "asset": "USDT_TRC20", "network": "TRON", "address": "TH6qkv3B8qnDX1BSXbD4e3Etg5pLdtrt2t", "amount_due": "249.41", "amount_paid": "0.00", "credited": { "gross": "0", "commission": "0", "net": "0" }, "checkout_url": "https://pay.gaispay.com/pay/inv_e64d63c31bf396a0e5c2dacb", "payments": [], "created_at": 1795289407, "expires_at": 1795291207 }
Retrieve and list
GET/v1/payments/{id} returns the current status, the on-chain transfers in payments and what was credited after the fee. GET/v1/payments lists payments.
Balances
GET/v1/balances returns your balance per asset with its withdrawal minimum and flat withdrawal fee.
{ "data": [ { "id": "USDT_TRC20", "symbol": "USDT", "network": "TRON", "withdraw_min": "10", "withdraw_fee": "3", "balance": "1240.50" } ] }Rates
GET/v1/rates returns the value of one unit of each enabled asset in base (default USD). A payment's rate is locked when the customer chooses the asset; this endpoint is informational.
curl -G https://api.gaispay.com/v1/rates -u "$GAISPAY_API_KEY:" -d base=USD { "base": "USD", "data": [ { "asset": "USDT_TRC20", "rate": "0.998261" }, { "asset": "TRX", "rate": "0.304594" } ] }
Withdrawals
GET/v1/withdrawals lists your withdrawal and refund requests (status, limit, offset). Requests themselves can only be created in the dashboard with your password, and are sent after GaisPay review.
All endpoints
| Endpoint | Description |
|---|---|
| POST/v1/payments | Create a payment |
| GET/v1/payments | List payments |
| GET/v1/payments/{id} | Retrieve a payment |
| GET/v1/assets | Assets enabled for your account |
| GET/v1/balances | Balances |
| GET/v1/rates | Rates |
| GET/v1/withdrawals | List withdrawals and refunds |
| POST/v1/plans | Create a plan |
| GET/v1/plans | List plans |
| GET/v1/plans/{id} | Retrieve a plan |
| POST/v1/plans/{id} | Update a plan (name, description, redirect, availability) |
| POST/v1/subscriptions | Create a subscription |
| GET/v1/subscriptions | List subscriptions |
| GET/v1/subscriptions/{id} | Retrieve a subscription with its period payments |
| POST/v1/subscriptions/{id}/cancel | Cancel now or at period end |
| POST/v1/subscriptions/{id}/resume | Undo a scheduled cancellation |
Subscriptions: how it works
Crypto has no card-style automatic charges, so GaisPay collects recurring payments with a payment link every period. You create a plan (price and billing period); each customer gets a subscription on that plan.
| When | What happens |
|---|---|
| Start | The customer pays the first period (or starts a free trial). On confirmation the subscription becomes active. |
| Period ends | A new period is due: the customer is e-mailed a payment link and you receive subscription.payment_due. |
| Day 1 unpaid | Reminder e-mail. |
| Day 3 unpaid | Status becomes past_due (subscription.past_due). |
| Day 7 unpaid | Status becomes canceled with cancel_reason: "unpaid". |
| Paid | The next period starts where the previous one ended, so a late payment does not shorten it (subscription.renewed). |
Customers can subscribe themselves on the plan's subscribe_url, or you create the subscription from the dashboard or API. Every e-mail contains the customer's payment_url, where they can pay, see the status and cancel. Each period is a normal payment (with subscription_id), so the usual invoice.* webhooks, balances and the 0.5% fee apply.
| Status | Meaning |
|---|---|
incomplete | Waiting for the first payment. Expires after 7 days (1 day if started from the subscribe link). |
trialing | In a free trial; the first payment is due when it ends. |
active | Paid for the current period. Stays active while a renewal is due, for up to 3 days. |
past_due | The renewal is 3+ days late. |
canceled | Ended by you, by the customer, or for non-payment. |
incomplete_expired | The first payment was never made. |
Plans
POST/v1/plans creates a plan. Price and period cannot be changed later; create a new plan for a different price. POST/v1/plans/{id} updates name, description, redirect_url and active (set false to stop new subscriptions; existing ones continue).
namestring · requiredamountdecimal string · required"29.00".currencystring · requiredUSD, EUR, GBP or TRY.intervalstring · requiredday, week, month or year.interval_countinteger · optional3 with month for quarterly.trial_daysinteger · optionaldescriptionstring · optionalredirect_urlurl · optionalcurl https://api.gaispay.com/v1/plans \ -u "$GAISPAY_API_KEY:" \ -d name="Pro monthly" -d amount=29.00 -d currency=USD -d interval=month // 201 Created { "id": "plan_4b73…", "name": "Pro monthly", "amount": "29.00", "currency": "USD", "interval": "month", "interval_count": 1, "trial_days": 0, "active": true, "subscribe_url": "https://pay.gaispay.com/subscribe/plan_4b73…", "subscribers": { "active": 0, "past_due": 0, "canceled": 0 } }
Share subscribe_url anywhere: the customer enters their e-mail and goes straight to the checkout for the first payment.
Subscriptions
POST/v1/subscriptions subscribes a customer to a plan and e-mails them the first payment link (or starts the trial). Send the returned payment_url yourself if you prefer.
plan_idstring · requiredemailstring · optionalpayment_url yourself.namestring · optionalreferencestring · optionalorder_id on period payments.// 201 Created { "id": "sub_e323…", "status": "incomplete", "plan": { "id": "plan_4b73…", "name": "Pro monthly", "amount": "29.00", "currency": "USD", "interval": "month", "interval_count": 1 }, "customer": { "email": "ada@example.com", "name": "Ada" }, "reference": "cust-42", "current_period_start": null, "current_period_end": null, "payment_due": { "since": 1795435400, "period": 1, "amount": "29.00", "currency": "USD" }, "payment_url": "https://pay.gaispay.com/sub/IzrJ…", "cancel_at_period_end": false }
Retrieve, list and cancel
GET/v1/subscriptions/{id} returns the subscription with its period payments in invoices. GET/v1/subscriptions lists them and accepts status, plan_id, email and reference filters.
POST/v1/subscriptions/{id}/cancel ends the subscription now, or with at_period_end=true at the end of the paid period. POST/v1/subscriptions/{id}/resume undoes a scheduled cancellation. The customer is e-mailed either way.
Subscription events
Subscription webhooks are signed and retried like payment webhooks. The data object is the subscription.
subscription.created | Created from the dashboard or API, or a trial started |
subscription.activated | First payment confirmed — grant access |
subscription.renewed | A renewal was paid — extend access |
subscription.payment_due | A new period started; payment link sent |
subscription.past_due | Renewal 3 days late |
subscription.updated | Cancellation scheduled or undone |
subscription.canceled | Ended — revoke access at the end of the period |
subscription.activated and subscription.renewed, and use current_period_end as the paid-until date.Webhook events
Set your endpoint in Developers → Webhook. GaisPay sends a POST for each payment event below (and for the subscription events); return 2xx within 10 seconds and do heavy work asynchronously. De-duplicate with the X-Delivery-Id header.
invoice.confirming | Transfer seen on-chain, confirming |
invoice.paid | Payment final — fulfil the order |
invoice.underpaid | Less than requested arrived |
invoice.expired | Window passed without payment |
invoice.refunded | A refund was sent |
POST /webhooks/gaispay GaisPay-Signature: t=1795289461,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd X-Event: invoice.paid X-Delivery-Id: 418 { "event": "invoice.paid", "created_at": 1795289461, "data": { "id": "inv_e64d…", "status": "paid", "order_id": "1042", "amount_paid": "249.41", "credited": { "gross": "249.41", "commission": "1.25", "net": "248.16" } } }
Verifying signatures
The GaisPay-Signature header holds a timestamp t and an HMAC-SHA256 signature v1 of t + "." + raw_body, computed with your whsec_ secret. Verify against the raw body and reject timestamps older than five minutes.
import crypto from "node:crypto"; export function verifyGaisPay(rawBody, header, secret) { const p = Object.fromEntries(header.split(",").map((kv) => kv.split("="))); const expected = crypto.createHmac("sha256", secret).update(p.t + "." + rawBody).digest("hex"); const fresh = Math.abs(Date.now() / 1000 - Number(p.t)) < 300; return fresh && expected.length === (p.v1 || "").length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(p.v1)); }
<?php function gaispay_verify(string $raw, string $header, string $secret): bool { parse_str(str_replace(',', '&', $header), $p); $expected = hash_hmac('sha256', ($p['t'] ?? '') . '.' . $raw, $secret); return abs(time() - (int) ($p['t'] ?? 0)) < 300 && hash_equals($expected, $p['v1'] ?? ''); }
Retries
If your endpoint does not answer with 2xx, the event is retried, with 10 attempts in total. Retries start after about one minute and the delay doubles each time, up to six hours apart. Every attempt is visible on the payment detail page in your dashboard.
Assets & networks
| Asset code | Asset | Network | Status |
|---|---|---|---|
USDT_TRC20 | TRON (TRC-20) | Live | |
TRX | TRON | Live | |
USDT_ERC20 | Ethereum (ERC-20) | Live · from 50 USD | |
USDC_ERC20 | Ethereum (ERC-20) | Live · from 50 USD | |
ETH | Ethereum | Live · from 50 USD | |
USDT_BEP20 | BNB Chain (BEP-20) | Live | |
USDC_BEP20 | BNB Chain (BEP-20) | Live | |
BNB | BNB Chain | Live | |
USDT_SPL | Solana (SPL) | Live | |
USDC_SPL | Solana (SPL) | Live | |
SOL | Solana | Live | |
BTC | Bitcoin | Live · from 20 USD |
Call GET/v1/assets for the list enabled on your account. Customers must send the asset shown on the checkout, on the network shown — transfers in another asset or on another network are not detected automatically.

