The integration in four steps
- Your backend sends the USD order value and optional reference.
- Save the returned checkout ID with your order.
- Redirect the customer to
checkout_url. PaySig handles payment-method selection and quotes. - Confirm the order using a verified
invoice.paidwebhook or signed server-side status lookup. A browser redirect is not proof of payment.
| Field | Rule |
|---|---|
| amount_usd | Required positive decimal string, with at most two decimal places. |
| order_reference | Optional order reference up to 100 characters. |
| assetId / network / amount | Do not send these for USD checkout. The customer chooses the method. |
Project customer fees are added to the base order value. Responses separate order_amount_usd, customer_fee_usd and total amount_usd, and include id and checkout_url.
import { createHash, createHmac, randomBytes } from 'node:crypto';
const key = process.env.PAYSIG_API_KEY;
const secret = process.env.PAYSIG_API_SECRET;
if (!key || !secret) throw new Error('Set your project credentials on your server.');
const path = '/api/v2/checkouts';
const method = 'POST';
const body = JSON.stringify({ amount_usd: '25.00', order_reference: 'ORDER-1001' });
// Reuse this key only when retrying this same order.
const idempotencyKey = 'checkout-order-1001';
const timestamp = String(Math.floor(Date.now() / 1000));
const nonce = randomBytes(16).toString('hex');
const bodyHash = createHash('sha256').update(body).digest('hex');
const message = [timestamp, nonce, method, path, bodyHash, idempotencyKey].join('\n');
const signature = createHmac('sha256', secret).update(message).digest('hex');
const response = await fetch('https://paysig.io' + path, {
method, body,
headers: {
'Content-Type': 'application/json',
'PaySig-Key': key,
'PaySig-Timestamp': timestamp,
'PaySig-Nonce': nonce,
'PaySig-Signature': signature,
'Idempotency-Key': idempotencyKey
}
});
const checkout = await response.json();
if (!response.ok) throw new Error(checkout.error || 'Could not create checkout');
// Redirect your customer to this URL, or share it with them.
console.log(checkout.checkout_url);Request signing
Sign the exact request bytes with HMAC-SHA256, using your project secret as a UTF-8 key. Join these six fields with newlines. Do not add a newline after the final field.
timestamp
nonce
METHOD
/api/v2/path?exact=query
sha256(exact raw body, or empty bytes)
Idempotency-Key value, or empty- Use Unix seconds within five minutes of server time.
- Use a fresh 16-64 character nonce for every request, including retries.
- Retry one checkout with its original
Idempotency-Key; do not reuse it for another order. - For GET, hash empty bytes and use an empty final signing field. Preserve the exact path and query.
| Endpoint | Purpose |
|---|---|
| POST /api/v2/checkouts | Create a USD checkout. |
| GET /api/v2/checkouts/:id | Read selected method, invoice ID and payment status. |
| GET /api/v2/invoices/:id | Read the project invoice after issuance. |
A new checkout can be awaiting_selection. Invoice states include pending, partially_paid, paid, paid_late and expired.
Handle errors safely
| HTTP status | Meaning |
|---|---|
| 400 | Invalid input. |
| 401 | Invalid credentials, timestamp or signature. |
| 402 | Invoice allowance reached or platform balance insufficient. |
| 403 | Access or origin denied. |
| 409 | Conflicting request, idempotency key or repeated nonce. |
| 429 | Rate limited; wait before retrying. |
| 503 | A required service or verified rate is unavailable. |
When the outcome is uncertain, check the existing checkout before creating another. Retry with the original idempotency key and a new nonce/signature.