Developer docs
checkout_url we return, and we send your server a signed webhook when the payment is confirmed. There is no SDK to install, and no card or wallet code to maintain. Prefer no code at all? Use a payment link or the Pay button.Quickstart
- Get a test key. Create an account. You get a
ts_test_API key straight away and a webhook signing secret (whsec_). Both are shown once, so store them somewhere safe. - Create a payment from your server with
POST /v1/payments(below), or try it in the playground first. - Send the customer to
checkout_url. They pay by card or with the coin they hold. - Listen for the webhook. When the status becomes
paidwe call your webhook URL. Check the signature, then fulfil the order.
curl https://trustsettle-api.trustsettle.workers.dev/v1/payments \
-H "Authorization: Bearer ts_test_..." \
-H "Content-Type: application/json" \
-d '{
"amount": "500.00",
"currency": "USD",
"order_id": "INV-123",
"customer_email": "buyer@example.com",
"description": "Order INV-123",
"success_url": "https://yourshop.com/thanks",
"cancel_url": "https://yourshop.com/cart"
}'const res = await fetch('https://trustsettle-api.trustsettle.workers.dev/v1/payments', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.TS_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: '500.00',
currency: 'USD',
order_id: 'INV-123',
customer_email: 'buyer@example.com',
success_url: 'https://yourshop.com/thanks'
})
});
if (!res.ok) throw new Error((await res.json()).error.message);
const payment = await res.json();
// send the customer to payment.checkout_urlimport os, requests
res = requests.post(
"https://trustsettle-api.trustsettle.workers.dev/v1/payments",
headers={"Authorization": f"Bearer {os.environ['TS_KEY']}"},
json={
"amount": "500.00",
"currency": "USD",
"order_id": "INV-123",
"customer_email": "buyer@example.com",
"success_url": "https://yourshop.com/thanks",
},
timeout=15,
)
res.raise_for_status()
payment = res.json()
# send the customer to payment["checkout_url"]$ch = curl_init("https://trustsettle-api.trustsettle.workers.dev/v1/payments");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("TS_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"amount" => "500.00",
"currency" => "USD",
"order_id" => "INV-123",
"customer_email" => "buyer@example.com",
]),
]);
$payment = json_decode(curl_exec($ch), true);
// send the customer to $payment["checkout_url"]The response contains the checkout_url:
{
"id": "pay_Hq3x...",
"object": "payment",
"order_id": "INV-123",
"amount": 500,
"currency": "USD",
"status": "pending",
"provider": null,
"customer_email": "buyer@example.com",
"customer_name": null,
"description": "Order INV-123",
"metadata": {},
"link_id": null,
"invoice_number": null,
"checkout_url": "https://trustsettle.web.app/checkout?session=pay_Hq3x...",
"created_at": "2026-11-25T10:00:00.000Z",
"expires_at": "2026-11-25T11:00:00.000Z",
"paid_at": null
}Test and live
Every account starts in test mode. Test payments use a sandbox, so no real money moves. The mode is set by your API key:
| Key | Mode | What happens |
|---|---|---|
ts_test_... | Test | Sandbox payments. Never counted against plan limits. Invoice numbers look like TEST-0001. |
ts_live_... | Live | Real payments. Crypto is sent straight to your own settlement wallet. Invoice numbers look like INV-0001. |
Find and roll your keys in the dashboard under API keys. Your test key and live key work side by side: use the test key to test and the live key to go live, without swapping keys, even after the setup fee is paid. Rolling a key stops only that key, and the other keeps working. The dashboard also has a test/live switch for payment links and invoices you create there. Test and live payments are completely separate and one can never change the other.
Base URL: https://trustsettle-api.trustsettle.workers.dev
Authentication
Call the API from your server only, and send your key as a bearer token on every request. The merchant API sends no CORS headers on purpose, so it cannot be called from a browser. Keep the key out of your website code.
Authorization: Bearer ts_test_xxxxxxxxxxxxxxxxxxxxxxxxA missing or wrong key returns 401 unauthorized. If you have not paid the setup fee for the mode you are using, you get 402 setup_fee_required.
Create a payment
| Field | Type | Description |
|---|---|---|
amount * | string or number | Positive, at most 2 decimals, up to 1,000,000. Send it as a string such as "500.00" to avoid float surprises. |
currency * | string | USD, EUR or GBP. |
order_id * | string | Your own reference, 1 to 64 characters: letters, digits, _ . -. Unique per merchant (see below). |
customer_email | string | If you pass it, the customer is not asked for it again, and they get a receipt there. |
description | string | Up to 200 characters. Shown on the checkout page and the invoice. |
metadata | object | Anything you want back in webhooks. Up to 2 KB of JSON. |
success_url | string | Where the customer goes after paying. Must be https on one of your approved domains. |
cancel_url | string | Where the customer goes if the payment is cancelled, fails or expires. Same rule. |
Approved domains are the Redirect domains in the dashboard under Settings. A subdomain of an approved domain is accepted. This stops your key being used to build open redirects.
Try this call in the playground →
Safe to retry (idempotency)
order_id makes the call safe to repeat. Sending the same order_id again returns the same payment with 200 instead of 201, so a timeout or a double click never creates two payments. If you reuse an order_id with a different amount or currency you get 409 order_conflict.
Expiry
A payment that nobody has started paying expires after 60 minutes and moves to expired. Once the customer has picked a coin and been shown an address, the payment stays open so a late transfer can still be matched.
Retrieve a payment
Returns the payment object shown above. Use it to check a status when you do not want to wait for a webhook, for example on your own "thank you" page. Treat the webhook as the source of truth, and never mark an order paid because a customer landed on success_url.
curl https://trustsettle-api.trustsettle.workers.dev/v1/payments/pay_Hq3x... \
-H "Authorization: Bearer ts_test_..."Payment statuses
A status only ever moves forward. A late or replayed event can never turn a paid payment back into a failed one.
| Status | Meaning | Webhook |
|---|---|---|
pending | Created and waiting for the customer. | none |
processing | The customer has paid and the network is confirming it. | none |
paid | Confirmed and checked against your invoice amount. Safe to fulfil the order. | payment.paid |
partially_paid | The customer sent less than the invoice amount. | payment.partially_paid |
failed | The payment did not go through. No funds were confirmed. | payment.failed |
expired | Nobody paid in time. | payment.expired |
cancelled | The payment was cancelled. | payment.cancelled |
refunded | The payment was refunded. | payment.refunded |
review | The amount, currency or payout address did not match your invoice, so a person has to check it. Do not fulfil the order. | none |
The checkout page
You never build a payment form. The hosted checkout shows the amount and your business name, and asks for an email if you did not send one. The customer then picks how to pay, and the page shows Payment successful only after our server says the payment is paid. Nothing in the browser can fake that.
For live payments the customer pays a provider address and the money is converted and sent to your own settlement wallet. We never hold your funds. If the provider ever reports a different payout address than the one on your invoice, the payment goes to review instead of paid.
Webhooks
Set your webhook URL in the dashboard under Webhooks. It must be https and reachable from the public internet (private and internal addresses are refused). We send a POST with a JSON body each time a payment reaches one of these statuses: paid, partially_paid, failed, expired, cancelled or refunded.
{
"id": "k3Jx9...",
"type": "payment.paid",
"created": 1795600000,
"data": {
"id": "pay_Hq3x...",
"order_id": "INV-123",
"amount": 500,
"currency": "USD",
"status": "paid",
"provider": "nowpayments",
"metadata": {},
"link_id": null,
"invoice_number": "INV-0001",
"paid_at": "2026-11-25T10:07:41.000Z"
}
}| Field | Description |
|---|---|
id | Unique id of this event. A retry of the same event keeps the same id. |
type | payment. followed by the status. |
created | Unix time (seconds) the event was created. |
data.id | The payment id (pay_...). |
data.order_id | The order_id you sent. Use it to find your order. |
data.invoice_number | Set on paid events, for example INV-0001. |
data.link_id | The payment link it came from, or null for API payments. |
data.metadata | The metadata you sent. |
Acknowledging and retries
- Reply with any
2xxwithin 8 seconds. Redirects are not followed. - If you do not, we retry after about 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then mark the delivery failed. Retries run on a 5-minute timer, so allow a few minutes of slack.
- Recent deliveries, their status and attempts are shown in the dashboard under Webhooks.
Duplicates
Webhooks are delivered at least once, so the same event can arrive twice. Make your handler safe to run twice, for example by storing the event id (or checking that the order is not already paid) before you fulfil it.
Verify a webhook
Every webhook carries a header, TrustSettle-Signature: t=<unix time>,v1=<hex>, where v1 is the HMAC-SHA256 of t + "." + rawBody using your webhook secret (whsec_...). Always verify it, using the raw request body, and reject anything older than 5 minutes.
import crypto from 'node:crypto';
import express from 'express';
const app = express();
// You need the RAW body to check the signature, so do not JSON-parse before verifying.
app.post('/hooks/trustsettle', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('TrustSettle-Signature') || '';
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const t = parts.t, v1 = parts.v1;
if (!t || !v1) return res.sendStatus(400);
const expected = crypto.createHmac('sha256', process.env.TS_WEBHOOK_SECRET)
.update(`${t}.${req.body.toString('utf8')}`).digest('hex');
const a = Buffer.from(v1), b = Buffer.from(expected);
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) return res.sendStatus(400);
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return res.sendStatus(400); // replay window: 5 min
const event = JSON.parse(req.body.toString('utf8'));
if (event.type === 'payment.paid') {
// mark event.data.order_id as paid. Make this safe to run twice (see "Duplicates").
}
res.sendStatus(200); // any 2xx acknowledges
});import hmac, hashlib, json, os, time
from flask import Flask, request, abort
app = Flask(__name__)
@app.post("/hooks/trustsettle")
def hook():
raw = request.get_data() # raw bytes, before any JSON parsing
parts = dict(p.split("=", 1) for p in request.headers.get("TrustSettle-Signature", "").split(","))
t, v1 = parts.get("t"), parts.get("v1")
if not t or not v1:
abort(400)
expected = hmac.new(os.environ["TS_WEBHOOK_SECRET"].encode(), f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
if not hmac.compare_digest(v1, expected):
abort(400)
if abs(time.time() - int(t)) > 300: # replay window: 5 minutes
abort(400)
event = json.loads(raw)
if event["type"] == "payment.paid":
pass # mark event["data"]["order_id"] as paid; make this safe to run twice
return "", 200$raw = file_get_contents("php://input");
$parts = [];
foreach (explode(",", $_SERVER["HTTP_TRUSTSETTLE_SIGNATURE"] ?? "") as $p) {
[$k, $v] = array_pad(explode("=", $p, 2), 2, "");
$parts[$k] = $v;
}
$expected = hash_hmac("sha256", ($parts["t"] ?? "") . "." . $raw, getenv("TS_WEBHOOK_SECRET"));
if (!hash_equals($expected, $parts["v1"] ?? "") || abs(time() - (int)($parts["t"] ?? 0)) > 300) {
http_response_code(400); exit;
}
$event = json_decode($raw, true);
if ($event["type"] === "payment.paid") {
// mark $event["data"]["order_id"] as paid; make this safe to run twice
}
http_response_code(200);Sign or check a sample webhook in the playground → You can also simulate a payment event and watch your server receive it.
Roll the secret if it leaks. In the dashboard under Webhooks, roll the signing secret. The old one stops working immediately, so update your server straight after.
Playground Test mode
Try the API from this page, with your own ts_test_ key and no code. Requests go to the real API and the responses are real, so you can see exactly what your server will receive: success shapes, every error code, idempotent replays and signed webhooks.
Test keys only. A ts_live_ key is refused here and again by our server. The key is kept in this page's memory (or this tab's session storage if you tick the box), and is only ever sent to the TrustSettle API. Nothing here moves real money. Production calls must still come from your server, never from a browser.
Request body
Edited by hand, so the fields above no longer change it.
The next Send uses a made-up key, so you can see the 401 response.
/v1/paymentsThe same call in your server code
Fetch a payment by id, the way your "thank you" page would. Creating a payment fills the id in for you.
/v1/payments/:idThe same call in your server code
Nobody can pay in test mode without a sandbox wallet, so move a test payment to any status yourself. This runs the real pipeline: the status changes, a TEST- invoice is written for paid, and a signed webhook is sent to your webhook URL. We show you how your server answered. A status only moves forward, so try failing a paid payment to see it refused. This route exists only in the playground and only for test payments.
/v1/playground/payments/:id/simulateThe same call in your server code
Build and check webhook signatures without a public URL. This tab never touches the network: the secret stays in your browser and the signing runs locally.
1. Send a signed sample to your own server
2. Check a signature you received
Calls are limited to 60 a minute. Test payments never count against plan limits. Test receipts are only emailed to your own address.
Payment links No code
You do not need the API to get paid. In the dashboard open Payment links, enter what the payment is for and an amount, and share the link by WhatsApp or email. Your client enters their email, pays at the normal checkout, and the payment appears in your dashboard.
- One payment links close after the first payment. Reusable links can be paid again and again.
- A link can expire after 7, 30 or 90 days, and you can turn it off and on at any time.
- Send a one-payment link straight to a client with a due date, and we email it to them and remind them before and after the due date. Reminders stop the moment they pay.
- Payments from links behave exactly like API payments: the same webhooks, invoices and receipts.
data.link_idtells you which link was paid. - A link belongs to the mode it was created in. A test link cannot be paid once you are live.
Pay button for your website One line
Add a ready-made Pay with TrustSettle button to any page with one script tag. It needs no API key and no backend, because the amount is fixed by the payment link. In the dashboard press Add to website on a link to copy the exact snippet.
<script src="https://trustsettle.web.app/button.js" data-link="lnk_..."></script><div class="trustsettle-button" data-link="lnk_..." data-label="Pay deposit"></div>
<script src="https://trustsettle.web.app/button.js" async></script><button id="pay">Pay now</button>
<script src="https://trustsettle.web.app/button.js" async></script>
<script>
document.getElementById('pay').onclick = () =>
TrustSettle.open('lnk_...', { email: 'client@company.com' });
</script>| Attribute | Default | What it does |
|---|---|---|
data-link * | Your payment link id (lnk_...). | |
data-label | Pay with TrustSettle | Button text. |
data-theme | dark | dark or light. |
data-email | Prefills the client's email on the pay page. | |
data-target | _blank | Use _self to open in the same tab. |
Use a reusable link for a public page. A one-payment link stops working after the first payment, so the button would stop working for everyone else.
The button opens the pay page in a new tab. It does not use an iframe, because the pay page cannot be framed on purpose. If you need a different amount for every order, create the payment from your server with the API instead.
If you load the script after the page has changed, call TrustSettle.mount() to draw any new buttons. You can also skip the script and use a plain link: <a href="https://trustsettle.web.app/pay/lnk_...">Pay now</a>.
Branding your checkout
Your customers see your business, not a generic page, from the moment they open a payment link or press the Pay button, through to the hosted checkout you send them to from the API. Set it once in the dashboard under Settings, then Checkout branding. It applies straight away, including to payments and links you have already created.
| Setting | What it does | Rules |
|---|---|---|
| Business name | Shown as "Pay your business" and in the browser tab title. Without a logo it also replaces the TrustSettle mark at the top of a payment link. | 2 to 80 characters. Set under Business. |
| Logo | Replaces the TrustSettle mark at the top of the payment link page, and appears on a white tile at the top of the amount panel on the hosted checkout. | PNG, JPEG or WebP. Resized in the dashboard to fit 400 by 160 pixels and stored at under 100 KB. SVG is not accepted. |
| Accent colour | The amount panel, the main buttons and the selected payment method. | 6 hex digits such as #0a7c66. White text sits on it, so a colour that is too light is rejected. |
Where it appears
- Payment links (
/pay/lnk_...) and the Pay button, which opens that page. - The hosted checkout (
checkout_url) for payments created with the API, including the success and problem screens.
What stays the same. The footer still reads "Secure checkout by TrustSettle", so customers know who is processing the payment, and the payment page cannot be changed beyond the logo and colour. Invoices and receipt emails are not branded yet. Branding is the same in test and live mode, so you can check it with a test payment link before going live.
The checkout and payment link endpoints return a brand object ({ "color": "#0a7c66", "logo": "data:image/png;base64,..." }, each field null when unset) that the TrustSettle pages use. The merchant API does not change.
Invoices and receipts
Every paid payment, from the API or a payment link, gets its own numbered invoice written at the moment it is marked paid, so numbers never repeat. Live invoices are INV-0001, INV-0002 and so on, and test ones are TEST-0001. The number appears as invoice_number on the payment and in the payment.paid webhook.
- Each invoice has a page your client can print or save as a PDF, at
/invoice/<payment id>. - We email your client a receipt, sent as "Your business via TrustSettle", and email you a payment-received notice. Replies go to the contact email in your Settings.
- See every invoice, resend a receipt and export a CSV from the dashboard under Invoices.
- In test mode, receipts are only emailed to your own address, so a test link cannot send mail to strangers.
Errors
Errors use standard HTTP status codes and one JSON shape. Show error.message to your developers, and branch on error.code in code.
{
"error": {
"code": "invalid_amount",
"message": "amount must be a positive number with at most 2 decimals."
}
}| HTTP | Code | What to do |
|---|---|---|
| 400 | invalid_json | The request body is not valid JSON. |
| 400 | invalid_amount | Fix the amount: positive, at most 2 decimals, within the limit. |
| 400 | invalid_currency | Use USD, EUR or GBP. |
| 400 | invalid_order_id | 1 to 64 characters: letters, digits, _ . -. |
| 400 | invalid_email | customer_email is not a valid address. |
| 400 | invalid_metadata | Must be an object under 2 KB. |
| 400 | invalid_redirect | success_url or cancel_url is not https on an approved domain. |
| 401 | unauthorized | Missing, malformed or rolled API key. |
| 402 | setup_fee_required | Pay the setup fee for this mode in the dashboard (Billing). |
| 402 | subscription_required | Live payments need a paid plan. |
| 402 | plan_limit_reached | Your plan's monthly live volume is used up. Upgrade or wait for next month. |
| 404 | not_found | No such payment on your account. |
| 409 | order_conflict | This order_id already exists with a different amount or currency. |
| 409 | payout_wallet_required | Add a settlement wallet in Settings before taking live payments. |
| 413 | payload_too_large | Request bodies are limited to 32 KB. |
Going live
- Run a full test payment with your
ts_test_key and confirm your server handles the webhook, including a replay of the same event. - Choose a plan in Billing and pay the second half of the setup fee.
- Add your settlement wallet in Settings. Payments are sent straight to it. Double-check the address and network.
- Create your
ts_live_key under API keys (your test key keeps working), store the live key in your server's secrets and deploy. - Make one small real payment end to end and check that the funds arrive and your order is marked paid.
Stuck? Email support@trustsettle.co with the payment id (pay_...). Questions from customers about paying are answered in the FAQ.