SpotEx Pay for developers
Merchant API
Take crypto payments on your own site, in your own design, and pay out from your merchant wallet. JSON over HTTPS, with SDKs for Node.js, Python and PHP.
https://spotex.trade/api/merchant/v1No code at all?
Quickstart
Three steps from nothing to a paid test order.
- 01
Get keys
Apply at Merchant, then make a test key (
sk_test_) under Developers. - 02
Create a checkout
One call with the price and your order number. Send the buyer to its
url. - 03
Hear it was paid
Set a webhook address. Check its signature, then fulfil the order on
checkout.paid.
curl -X POST https://spotex.trade/api/merchant/v1/checkout-sessions \
-H "Authorization: Bearer $SPOTEX_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1043" \
-d '{ "price": "25.00", "currency": "USD",
"item": "Gift box", "order_id": "1043",
"return_url": "https://yourshop.com/thanks" }'With a test key that is all real except the money: open the session's url, press Pay in full, and your webhook gets checkout.paid with "livemode": false.
SDKs
Official, open source and dependency-free. Each verifies webhooks and handles idempotency keys for you. Or call the API directly: it is plain JSON over HTTPS.
Node.js
TypeScript types, no dependencies
npm install github:SpotEx-trade/spotex-pay-nodeREADME and examples on GitHubPython
Standard library only, 3.8+
pip install git+https://github.com/SpotEx-trade/spotex-pay-pythonREADME and examples on GitHubPHP
PHP 7.4+, curl
composer config repositories.spotex vcs https://github.com/SpotEx-trade/spotex-pay-php && composer require spotex/payREADME and examples on GitHubWooCommerce
A payment method for WordPress shops, classic and block checkout
Plugins → Add New → Upload Plugin: the repository's zipREADME and examples on GitHubWHMCS
A payment gateway for WHMCS invoices
Copy the repository's modules folder into WHMCS, then activate SpotEx Pay under Payment GatewaysREADME and examples on GitHub
Keys and permissions
Every request carries your secret key as a bearer token: Authorization: Bearer sk_live_….
- Every key can create and read checkouts and read your balance. Nothing more unless you choose it.
- Transfer and withdraw are separate permissions, off unless you tick them. A key with either must have an IP allowlist: requests from any other address are refused.
- A withdraw key can be whitelist-only: it then sends only to addresses on your withdrawal whitelist, which you add in the Merchant Center with the identity check.
- A test key (
sk_test_…) works in test mode. It can never pay out. - Revoke a key and it stops working at once. Keys see only your own merchant account. Keep them on your server, never in a web page or an app.
- 300 requests a minute per key; past that, 429 with a Retry-After header.
Endpoints
All under the base URL. Amounts are decimal strings, never numbers, so nothing is lost to floating point.
| Request | Key needs | Does |
|---|---|---|
| POST/checkout-sessions | any key | One order paid on SpotEx's own page: send the buyer to its url; they choose the coin and how to pay |
| GET/checkout-sessions/:id | any key | A session: open, paid (with its checkout id) or expired |
| GET/coins | any key | The coins you accept, their USD rate, and the networks each can be sent on from any wallet |
| POST/checkouts | any key | An on-chain checkout with its own address and exact amount, to show in your design |
| GET/checkouts/:id | any key | One checkout: status, what arrived, what is still confirming, what is left |
| GET/checkouts | any key | Your checkouts, newest first. ?status=paid|released|pending, ?limit (max 100), ?before=<id> |
| POST/checkouts/:id/simulate | test key | Test mode only: { "outcome": "paid" | "partial" | "expired" } |
| POST/invoices | live key | An invoice with its own page to send your customer: lines, currency, due date, note |
| GET/invoices/:id | live key | One invoice: open, overdue, paid (with its checkout) or void |
| GET/invoices | live key | Your invoices, newest first. ?limit (max 100), ?before=<id> |
| POST/invoices/:id/void | live key | Cancel an unpaid invoice: its page stops taking payments |
| POST/plans | live key | A plan to subscribe to: { name, price, currency, interval: "week" | "month" | "year" } |
| GET/plans | live key | Your plans, with each one's subscribe url |
| GET/subscriptions | live key | Your subscribers, newest first. ?status=active|past_due|canceled, ?limit, ?before=<id> |
| GET/subscriptions/:id | live key | One subscription: status, periods paid, next charge |
| POST/subscriptions/:id/cancel | live key | End a subscription: no more charges |
| GET/balance | live key | What is in your merchant wallet, which payouts are paid from |
| POST/payouts/transfers | transfer | Pay a SpotEx user from the merchant wallet, by username or email. Instant |
| GET/payouts/transfers/:id | live key | One transfer you sent |
| POST/payouts/withdrawals | withdraw | Send from the merchant wallet to an address on-chain |
| GET/payouts/withdrawals/:id | live key | One withdrawal: status and txid once broadcast |
Checkout sessions
The quickest integration: no checkout screen of your own. One call, then send the buyer to its url.
curl -X POST https://spotex.trade/api/merchant/v1/checkout-sessions \
-H "Authorization: Bearer $SPOTEX_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1043" \
-d '{ "price": "25.00", "currency": "USD",
"item": "Gift box", "order_id": "1043",
"return_url": "https://yourshop.com/thanks" }'- The buyer chooses a coin and pays from their SpotEx balance or any wallet, then gets a button back to
return_url, which must be on your website. - A session takes one payment and closes once paid, or after
expires_in_minutes(default 60, up to 1440). The webhook's checkout carriessession_idand yourorder_id. - Price it in your own currency:
pricewith anycurrencyunder Currencies.amount_usdalone still works, for a price in dollars. - Payments start at $1 from a SpotEx balance and $5 from a wallet ($10 for USDT and other tokens on an EVM chain, $50 on Ethereum itself, more on a chain whose own deposit minimum is higher), up to $5,000, or their worth in your currency.
Checkouts in your own design
Create a checkout, show its address and amount in your page, and wait for the webhook.
curl -X POST https://spotex.trade/api/merchant/v1/checkouts \
-H "Authorization: Bearer $SPOTEX_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1043" \
-d '{ "price": "25.00", "currency": "USD", "coin": "DOGE",
"item": "Gift box", "order_id": "1043" }'{
"id": "cm...",
"object": "checkout",
"livemode": true,
"status": "pending",
"method": "onchain",
"item": "Gift box",
"order_id": "1043",
"price": "25.00",
"currency": "USD",
"currency_rate_usd": "1",
"amount_usd": "25.00",
"coin": "DOGE",
"amount": "138.88888889",
"rate_usd": "0.18",
"address": "D8x...",
"received": "0",
"confirming": "0",
"remaining": "138.88888889",
"expires_at": "2026-10-27T10:30:00.000Z",
"hosted_url": "https://spotex.trade/checkout/cm...",
...
}- Show
addressandamount(a QR code of the address helps), or send the buyer tohosted_url, SpotEx's own page for it. - The price is held for 30 minutes. Coins that can be sent from any wallet are marked
onchain: trueinGET /coins. - A token on several chains, like USDT, takes
networktoo: one of itsnetworksinGET /coins, each with its ownmin_usd. The address is watched on that chain alone, so show the network beside it. Sent on another, it does not arrive. - Paid in parts? SpotEx holds what arrived until the rest does (
remainingsays how much), or until you accept it as paid in the Merchant Center. Set a shortfall to accept (Settings, up to 5%) and a payment that short or less is paid on arrival. - When paid, the amount less the 0.5% fee is in your merchant wallet:
feeandnetsay what each was. - Chose to receive payments as one coin (Settings)? Each payment in another coin is sold on the spot market as it lands, within 2% of the market price and with no trading fee, for 1% in all on what converts.
The checkout object
What every checkout endpoint returns, and what webhooks carry in data.checkout.
| Field | Type | Meaning |
|---|---|---|
id | string | The checkout's id. |
object | "checkout" | |
livemode | boolean | False for test mode. Never fulfil an order on a false one. |
session_id | string | null | The checkout session (or payment link) it was paid through. |
invoice_id | string | null | The invoice it paid, if any. |
subscription_id, subscription_period | string | null, number | null | The subscription it charged, and which period (1 is the first). |
status | string | pending, partially_paid, paid, released or expired. Released: a part payment SpotEx passed to your wallet without you accepting it (after it waited too long, or by our support). The order is not paid. |
method | string | onchain (sent from a wallet) or balance (paid from a SpotEx balance). |
item, order_id | string | What you named it, and your own order number. |
price, currency | decimal, string | The price as you asked it, and its currency: USD, EUR, JPY… |
amount_usd, currency_rate_usd | decimal | The price in dollars when the checkout was quoted, and the dollars per unit of the currency it used (1 for USD). |
coin, amount, rate_usd | string, decimal | The coin, the exact amount owed in it, and the rate it was quoted at. |
network | string | null | For a token on an EVM chain, the one to send on: BSC, ETH, POLYGON, BASE. Null for a coin on its own chain. |
address | string | null | Where to send it: this checkout's own address. In test mode a test_ stand-in. |
received, confirming, remaining | decimal | What has arrived, what is seen but still confirming, and what is left to send. |
fee, net | decimal | null | Once paid: SpotEx's fee, and what reached your merchant wallet. |
convert_* | convert_to, convert_status (pending, sent, done or failed), convert_fee and convert_note: set when you receive payments as one coin. | |
paid_late | boolean | Completed by money first seen after the quote ran out: check its value. |
duplicate | boolean | A second payment for a checkout session already paid. |
accepted_short | boolean | It went to your wallet short of the amount: see accepted_by. |
accepted_by | string | null | Who let it go short: tolerance (within your shortfall setting) or merchant (you accepted it) pay the order; operator or auto mean status released. Null when paid in full. |
expires_at, paid_at, created_at | ISO 8601 | |
hosted_url | string | SpotEx's own checkout page for it. |
Invoices
Bill a customer line by line. Each invoice has a page of its own you send them, and is paid once, from any wallet or a SpotEx balance.
curl -X POST https://spotex.trade/api/merchant/v1/invoices \
-H "Authorization: Bearer $SPOTEX_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoice-2041" \
-d '{ "currency": "EUR", "customer_name": "Acme Ltd",
"items": [{ "description": "Logo design",
"quantity": "1", "unit_price": "300" }],
"due_date": "2026-11-30" }'- Send the customer
url: the invoice's page, with its lines, total and due date, and the way to pay it. SpotEx doesn't email them; you can make invoices in the Merchant Center too, and email them from your own mail app. statusisopen,overdue(pastdue_at, still payable),paidorvoid. When paid,checkout.paidfires with the checkout'sinvoice_id, and itsorder_idis the invoice number.- Up to 50 lines; each
amountisquantity×unit_price, rounded to the currency's decimals, andtotalis their sum. Text on an invoice can't hold links, emails, phone numbers, handles or wallet addresses. Live keys only. - Voiding stops new payments. A customer who had already started paying from a wallet can still complete it: then the invoice is paid, and you can refund them from the Merchant Center.
Subscriptions
Charge SpotEx users every week, month or year, from their balance. They subscribe once and can cancel any time.
- Make a plan — in the Merchant Center or with
POST /plans— and send subscribers itsurl. They choose a coin, agree to the terms and confirm with their authenticator; the first period is paid then. - Each period is charged at the day's rate from their balance, as a checkout of its own: you get
checkout.paidwith itssubscription_idandsubscription_period. A period is charged once, whatever happens. - A failed charge (not enough in their balance) is tried again daily; after the third, the subscription ends. Monthly and yearly subscribers are reminded three days before each charge. A plan's price and period never change: for a new price, make a new plan.
Currencies
Price in your shop's own currency. The buyer sees your price in it, and pays its worth in their coin.
- Send
pricewithcurrency, a three-letter code. Prices have the currency's own decimals: two for most, none forJPY,KRW,IDR,VND,PKRandHUF. - Your price becomes dollars when the buyer opens a checkout, at the exchange rate then, rounded up to the cent; the coin amount is quoted from that, and both hold for 30 minutes. The checkout keeps your price, the dollars, and the rate it used (
currency_rate_usd). - Rates come from the European Central Bank and CoinGecko, checked against each other and refreshed every hour. If a currency's rate can't be confirmed, new prices in it are refused with
503 currency_unavailableuntil it can: retry, or price in USD.
Webhooks
We POST every event to your webhook address, signed, and retry with backoff for about a day until your server answers 2xx.
| Event | When |
|---|---|
checkout.paid | Paid in full, within your shortfall setting, or accepted by you. Fulfil the order on this one, unless duplicate is true: then it is a second payment for an order already paid, which you accepted, and you may want to refund it. |
checkout.partial | Money arrived and is held for you: part of the amount (remaining says what is left), all of it but late and worth less now (paid_late), or a second payment on a checkout session already paid (duplicate). |
checkout.extra | More arrived after it was paid; it is in your wallet less the fee. |
checkout.released | A part payment that waited too long (or that our support let go) went to your wallet without you accepting it. The order is NOT paid: don't fulfil it; ask the buyer for the rest, or refund. |
checkout.refunded | You refunded some or all of it from the Merchant Center. |
subscription.created | Someone subscribed, and their first period is paid (a checkout.paid comes with it). data.subscription. |
subscription.past_due | A period's charge failed: retried daily, three times in all. |
subscription.canceled | Ended by the subscriber, by you, or by its third failed charge. No more charges. |
payout.withdrawal.* | broadcast (with txid), completed, failed, rejected, cancelled: a withdrawal you sent moving on. data.withdrawal is it as GET /payouts/withdrawals/:id shows it. |
payout.transfer.* | completed, rejected: a transfer you sent, including one held for approval. data.transfer. |
test | From the "Send a test event" button in the Merchant Center. |
POST /your-webhook
SpotEx-Event: checkout.paid
SpotEx-Delivery: evt_8f1c...
SpotEx-Signature: t=1793071234,v1=5b2c...
{ "id": "evt_8f1c...", "type": "checkout.paid", "created": 1793071234,
"livemode": true, "data": { "checkout": { ... } } }Check the signature before trusting anything in the body: v1 is an HMAC-SHA256 of <t>.<raw body> with your webhook signing secret. Refuse events whose t is more than five minutes old, and treat the same id twice as one event.
import { constructEvent } from "spotex-pay";
// rawBody: the exact bytes received, before any JSON parsing
const event = constructEvent(rawBody, req.headers["spotex-signature"], secret);
if (event.type === "checkout.paid" && event.livemode) {
fulfil(event.data.checkout.order_id); // once per event.id
}The webhook address must be HTTPS on a public domain name, on port 443 or 8443. Redirects are not followed.
Test mode
Build and test your integration without moving any money.
- Make a test key in Merchant Center → Developers. With it,
POST /checkouts,POST /checkout-sessionsand their reads work exactly as live, and every object carries"livemode": false. - A test checkout's
addressstarts withtest_: it is not an address, never send coins to it. Pay it withPOST /checkouts/:id/simulate, or open itshosted_url(or a test session'surl) and press a button. - Your webhook gets
checkout.paidandcheckout.partialas it would live, signed the same way, with"livemode": false: check it before fulfilling an order. - Test and live never mix: a test key can't read live checkouts, nor a live key test ones. Payouts and the balance need a live key. Test objects are deleted after 30 days.
Payouts
Pay out from your merchant wallet, never from your Spot balance, with a key that has the permission.
# Pay a SpotEx user (instant)
curl -X POST https://spotex.trade/api/merchant/v1/payouts/transfers \
-H "Authorization: Bearer $SPOTEX_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: refund-1043" \
-d '{ "to": "alice", "coin": "USDT", "amount": "25",
"note": "Refund for order 1043" }'
# Withdraw on-chain
curl -X POST https://spotex.trade/api/merchant/v1/payouts/withdrawals \
-H "Authorization: Bearer $SPOTEX_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: supplier-2026-10-27" \
-d '{ "coin": "USDT", "network": "BSC",
"address": "0x...", "amount": "250" }'- Confirmed by your key alone: no email and no authenticator code.
- Sent automatically up to $1,000 a payout and $5,000 in 24 hours. Larger ones are accepted and wait for SpotEx to approve: a transfer is then
pending_review, a withdrawalsecurity_review. The amount is reserved in your wallet meanwhile. networkis needed only for a coin sent on more than one chain. A withdrawal's network fee comes out of your wallet on top ofamount.- Transfers follow the rules for any transfer between accounts (the minimum amount, and transfers being switched on) and go to the same account up to 20 times a day.
- Payouts stop while SpotEx has withdrawals paused, for a frozen account, and for a while after a security change on your account.
Idempotency
Retrying is always safe if you send the same key.
Send an Idempotency-Key header (8 to 100 letters, digits, - or _): the same request with the same key returns the same checkout or payout, however often it is sent. It is required for payouts. After a timeout, retry with the same key, never a new one, or you may pay twice. The SDKs make one for you when you leave it out; for payouts, always pass your own.
Errors
A non-2xx status, with a code to branch on and a message to log.
{ "error": { "code": "insufficient_funds", "message": "Not enough USDT in the merchant wallet." } }| Status | Code | Means |
|---|---|---|
| 400 | invalid_request | A field is missing or wrong: the message says which. |
| 400 | insufficient_funds | Not enough in the merchant wallet for the payout and its network fee. |
| 401 | unauthorized | Missing, wrong or revoked key. |
| 403 | permission_denied | The key lacks the transfer or withdraw permission. |
| 403 | ip_not_allowed | The request came from outside the key's IP allowlist. |
| 403 | not_whitelisted | A whitelist-only key sending to an address not on your whitelist. |
| 403 | merchant_unavailable | Your merchant account is not taking payments. |
| 403 | test_mode | A live-only call (balance, payouts) made with a test key. |
| 404 | not_found | No such object, or not yours. |
| 409 | conflict | The request clashes with the object's state. |
| 429 | rate_limited | Over 300 requests a minute for this key: wait Retry-After seconds. |
| 503 | paused, unavailable | Payments or payouts are paused for now: retry later with the same Idempotency-Key. |
| 503 | currency_unavailable | The currency's exchange rate isn't current: retry in a few minutes, or price in USD. |
The SDKs raise these as an error with status, code and message, and a network failure or timeout as network_error.