Step-by-step guide to processing payments using the Aurion REST API
This guide walks you through the complete payment processing flow using Aurion's REST API. The process consists of three main steps:
sk_...) for your backendhttps://api.aurion.finance (or your environment URL)POST /v1/user/create)/v1/tokens endpoint)sk_...) for authentication.GET /v1/payments/{transactionId} also accept your public key (pk_...), so a checkout in the shopper's browser can call them. The key needs the READ scope (otherwise 403). Step 1 always needs the secret key, which must never reach a browser.Create a new payment transaction with specified recipients and USD amount.
POST /v1/payments/initializeContent-Type: application/json
Authorization: Bearer sk_your-secret-key| Field | Type | Required | Description |
|---|---|---|---|
amountUSD | number | Required | Payment amount in USD (must be positive) |
recipients | array | Required | Array of recipient objects with userId and percentage |
recipients[].userId | string | Required | User ID from Create User response |
recipients[].percentage | number | Required | Percentage allocation (total must equal 100) |
metadata | object | Optional | Custom metadata for the transaction |
callbackUrl | string | Optional | Stored in the transaction's metadata but never called. To receive payment events, configure a webhook endpoint (see Webhooks) |
curl -X POST https://api.aurion.finance/v1/payments/initialize \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_your-secret-key" \
-d '{
"amountUSD": 100,
"recipients": [
{
"userId": "user-uuid-1",
"percentage": 60
},
{
"userId": "user-uuid-2",
"percentage": 40
}
],
"metadata": {
"orderId": "order-123",
"description": "Payment for services"
}
}'{
"success": true,
"message": "Payment initialized successfully",
"data": {
"transactionId": "5b0cb826-0bcc-483f-984f-268a0e0a757c",
"paymentLink": "https://pay.aurion.com/5b0cb826-0bcc-483f-984f-268a0e0a757c",
"status": "PENDING"
}
}transactionId from the response. You'll need it for the next steps.amountUSD. The shopper pays the gross amount, which is what the transaction's baseAmountUSD and the webhooks' amountUSD show. The amount you asked for is kept in metadata.netAmountUSD.Select the cryptocurrency token for payment and get payment details including wallet address.
POST /v1/payments/update-tokenContent-Type: application/json
Authorization: Bearer sk_your-secret-key| Field | Type | Required | Description |
|---|---|---|---|
transactionId | string | Required | Transaction ID from Step 1 (Initialize Payment) |
tokenId | string | Required | Token ID from /v1/tokens. Token IDs are mint addresses |
GET /v1/tokens to get a list of available tokens and their IDs. Common tokens include:So11111111111111111111111111111111111111112 - SOL (Solana)EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v - USDCEs9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB - USDTcurl -X POST https://api.aurion.finance/v1/payments/update-token \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_your-secret-key" \
-d '{
"transactionId": "5b0cb826-0bcc-483f-984f-268a0e0a757c",
"tokenId": "So11111111111111111111111111111111111111112"
}'{
"success": true,
"data": {
"transactionId": "5b0cb826-0bcc-483f-984f-268a0e0a757c",
"expiryTime": "2024-01-15T11:30:00.000Z",
"walletAddress": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"tokenDetails": {
"amount": 0.5,
"symbol": "SOL",
"contractAddress": "So11111111111111111111111111111111111111112"
}
}
}walletAddress where the customer should send payment, and the exact amount in tokenDetails.amountpayment.token_updated webhook is sentPENDING state. While it is, you can call this again to change the tokenwalletAddress to provide payment instructions to your customer400 Transaction has expired), changing the token keeps the first expiry, and token changes on one transaction are limited to one every 3 seconds (429)Verify that payment has been received on-chain and trigger the distribution process.
POST /v1/payments/verifyContent-Type: application/json
Authorization: Bearer sk_your-secret-key| Field | Type | Required | Description |
|---|---|---|---|
transactionId | string | Required | Transaction ID from Step 1 |
curl -X POST https://api.aurion.finance/v1/payments/verify \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk_your-secret-key" \
-d '{
"transactionId": "5b0cb826-0bcc-483f-984f-268a0e0a757c"
}'{
"success": true,
"message": "Transaction verified and distribution completed successfully",
"data": {
"transactionId": "5b0cb826-0bcc-483f-984f-268a0e0a757c",
"transactionHash": "5KKsW8Y9n8rTBrDHvdxJ6YQZfJ2rxxvChaZZoGKk8RKFc3xs4TSK1kSv7NgZy6jm478",
"status": "COMPLETED",
"amountReceived": 0.5,
"expectedAmount": 0.5,
"tokenSymbol": "SOL",
"walletAddress": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM"
}
}400 Amount mismatch and the transaction stays PENDINGPLATFORM_RECEIVEDCOMPLETED)400 Transaction has expired. It does not change the transaction itself: the expiry job marks it EXPIRED, releases the wallet and sends the payment.expired webhook.Instead of polling, let Aurion notify your backend. Create a webhook endpoint in the dashboard (Webhooks) and enable the alert types you want. The callbackUrl field of Step 1 is not used for this.
Switch on data.object.event. The outer type is the alert type the event is filed under, and two events share payment_verified.
data.object.event | Outer type | Enable alert type | Sent when |
|---|---|---|---|
payment.initialized | payment_initialized | PAYMENT_INITIALIZED | Step 1 created the payment |
payment.token_updated | wallet_assigned | WALLET_ASSIGNED | Every successful Step 2 |
payment.received | payment_received | PAYMENT_RECEIVED | Step 3 found the payment on-chain |
payment.verified | payment_verified | PAYMENT_VERIFIED | Step 3 finished and the payment is COMPLETED |
payment.distribution_completed | payment_verified | PAYMENT_VERIFIED | Every recipient was paid |
payment.failed | payment_failed | PAYMENT_FAILED | Distribution failed (metadata.error says why) |
payment.expired | transaction_expired | TRANSACTION_EXPIRED | An unpaid payment expired |
{
"id": "evt_5f0c8a2e9b1d4c7a8e3f6b2d1a9c0e4f",
"object": "event",
"created": 1767225600,
"data": {
"object": {
"event": "payment.received",
"data": {
"transactionId": "5b0cb826-0bcc-483f-984f-268a0e0a757c",
"platformId": "0f3a6c1e-2b7d-4e8f-9a1c-5d2e7b8f4a60",
"amountUSD": 102.5,
"tokenAmount": 0.5125,
"tokenSymbol": "SOL",
"walletAddress": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"status": "PLATFORM_RECEIVED",
"transactionHash": "5KKsW8Y9...",
"recipients": [
{ "userId": "user-uuid-1", "percentage": 60, "amount": 0 }
],
"metadata": {
"orderId": "order-123",
"netAmountUSD": 100,
"grossAmountUSD": 102.5,
"walletAssignment": {
"walletAddress": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"isEncrypted": true,
"assignedAt": "2026-01-01T00:00:00.000Z"
}
},
"timestamp": "2026-01-01T00:05:00.000Z"
}
}
},
"livemode": true,
"type": "payment_received",
"api_version": "2024-01-01"
}amountUSD is the gross amount the shopper pays (your amount plus fees). Your own amount is metadata.netAmountUSD; match orders on it or on your own metadata keys.recipients lists only your users. The network-fee share is not in it; in GET /v1/payments/{transactionId} it is a receiver with receiverType: "NETWORK_FEE" and user: null.metadata.walletAssignment.encryptedPrivateKey) is removed. Everything else in metadata, including all of your own keys, is sent unchanged.2xx within 5 seconds.5xx, a timeout or a network error is retried up to 3 times (after 5, 10 and 20 seconds). A 4xx is not retried.id. Deduplicate on transactionId plus event.Every delivery has two signature headers with the same timestamp. Aurion-Signature is unchanged, so existing verification keeps working:
Aurion-Signature: t=<unix seconds>,v1=<base64, deprecated>
Aurion-Signature-V2: t=<unix seconds>,v2=<64 lowercase hex characters>v2 is the hex HMAC-SHA256 of <t>.<raw request body>, keyed with your endpoint's secret (wh_...). Compute it over the exact bytes you received, compare in constant time, and reject events whose t is more than 5 minutes old.
v1 is deprecated and insecure. It is a reversible encoding of the body and your secret, not a signature: one captured delivery reveals the secret. Move to Aurion-Signature-V2, and rotate your webhook secret if you ever logged v1. A body with characters outside Latin-1 (such as €) has no v1 and is sent with Aurion-Signature-V2 only.const crypto = require("node:crypto");
// rawBody = the exact request bytes (e.g. express.raw()), not re-serialised JSON
// header = the Aurion-Signature-V2 request header
function verifyAurionSignature(rawBody, header, secret, toleranceSec = 300) {
const parts = Object.fromEntries(header.split(",").map(p => { const i = p.indexOf("="); return [p.slice(0, i), p.slice(i + 1)]; }));
if (!parts.t || !parts.v2) return false;
if (Math.abs(Date.now() / 1000 - Number(parts.t)) > toleranceSec) return false;
const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.`).update(rawBody).digest("hex");
const a = Buffer.from(expected, "hex"), b = Buffer.from(parts.v2, "hex");
return a.length === b.length && crypto.timingSafeEqual(a, b);
}import hmac, hashlib, time
# header = the Aurion-Signature-V2 request header
def verify_aurion_signature(raw_body: bytes, header: str, secret: str, tolerance=300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
t, v2 = parts.get("t"), parts.get("v2")
if not t or not v2 or abs(time.time() - int(t)) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v2)