REST API: Create an Invoice
Authentication
Every request carries three headers:
x-api-key: your store's public key (it starts withpk_).x-timestamp: the current Unix time in seconds. It must be within 5 minutes of our clock.x-signature: the hex HMAC-SHA256 oftimestamp.body, signed with your store's API secret.
Send Content-Type: application/json too. Each signed request is accepted once, so wait at least a second before you send the same request again, and sign it again. Showing the API secret in the dashboard needs two-factor login with an authenticator app.
Create an invoice
Send POST /api/v1/invoices with an amount and currency. Optional fields include orderId, allowedAssets, expiresMin (5 to 1440), successUrl, cancelUrl and metadata. The response contains invoice_url: send your customer there.
Set test: true to create a test invoice that can't be paid with real money. The full reference is in the API docs.
// Node.js 18+
const crypto = require('crypto');
async function createInvoice() {
const body = JSON.stringify({
amount: '49.00',
currency: 'USD',
orderId: 'ORD-1042',
allowedAssets: ['USDT_TRC20', 'BTC'],
successUrl: 'https://northwind-coffee.example/thanks',
});
const ts = Math.floor(Date.now() / 1000);
const signature = crypto
.createHmac('sha256', process.env.ARIONPAY_API_SECRET)
.update(`${ts}.${body}`)
.digest('hex');
// ARIONPAY_BASE_URL: the API address from the docs
const res = await fetch(`${process.env.ARIONPAY_BASE_URL}/api/v1/invoices`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.ARIONPAY_API_KEY, // pk_...
'x-timestamp': String(ts),
'x-signature': signature,
},
body,
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status}: ${data.error}`);
return data.invoice_url; // save data.id with the order, then send your customer here
}