Payment Flow Guide

Step-by-step guide to processing payments using the Aurion REST API

Overview

This guide walks you through the complete payment processing flow using Aurion's REST API. The process consists of three main steps:

1. Initialize Payment
→
2. Assign Token
→
3. Verify & Process

Prerequisites

💡 Tip: All API requests require authentication using a Bearer token in the Authorization header. Use your secret key (sk_...) for authentication.
Public key: Steps 2 and 3 and 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.

Step 1 Initialize Payment

Create a new payment transaction with specified recipients and USD amount.

Endpoint

POST /v1/payments/initialize

Headers

Content-Type: application/json
Authorization: Bearer sk_your-secret-key

Request Body

FieldTypeRequiredDescription
amountUSDnumberRequiredPayment amount in USD (must be positive)
recipientsarrayRequiredArray of recipient objects with userId and percentage
recipients[].userIdstringRequiredUser ID from Create User response
recipients[].percentagenumberRequiredPercentage allocation (total must equal 100)
metadataobjectOptionalCustom metadata for the transaction
callbackUrlstringOptionalStored in the transaction's metadata but never called. To receive payment events, configure a webhook endpoint (see Webhooks)

Example Request

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 Response (201 Created)

{
  "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"
  }
}
Important: Save the transactionId from the response. You'll need it for the next steps.
Validation Rules:
  • Total recipient percentages must equal exactly 100%
  • Amount must be a positive number
  • All user IDs must exist in your platform
Amounts: platform and Aurion fees are added on top of 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.

Step 2 Assign Token

Select the cryptocurrency token for payment and get payment details including wallet address.

Endpoint

POST /v1/payments/update-token

Headers

Content-Type: application/json
Authorization: Bearer sk_your-secret-key

Request Body

FieldTypeRequiredDescription
transactionIdstringRequiredTransaction ID from Step 1 (Initialize Payment)
tokenIdstringRequiredToken ID from /v1/tokens. Token IDs are mint addresses
💡 Getting Token IDs: Call GET /v1/tokens to get a list of available tokens and their IDs. Common tokens include:
  • So11111111111111111111111111111111111111112 - SOL (Solana)
  • EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v - USDC
  • Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB - USDT

Example Request

curl -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 Response (200 OK)

{
  "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"
    }
  }
}
✅ What happens here:
  • A unique wallet address is assigned for this transaction
  • The USD amount is converted to the selected token based on current exchange rates
  • Transaction expiration is set to 30 minutes from now
  • You receive the walletAddress where the customer should send payment, and the exact amount in tokenDetails.amount
  • A payment.token_updated webhook is sent
⚠️ Important Notes:
  • Transaction must be in PENDING state. While it is, you can call this again to change the token
  • Transaction expires in 30 minutes from token selection
  • Use the walletAddress to provide payment instructions to your customer
  • The amount is converted from the gross amount (your amount plus fees) at current exchange rates. Show every decimal of it
  • With a public key: an expired checkout can't be revived (400 Transaction has expired), changing the token keeps the first expiry, and token changes on one transaction are limited to one every 3 seconds (429)

Step 3 Verify & Process Payment

Verify that payment has been received on-chain and trigger the distribution process.

Endpoint

POST /v1/payments/verify

Headers

Content-Type: application/json
Authorization: Bearer sk_your-secret-key

Request Body

FieldTypeRequiredDescription
transactionIdstringRequiredTransaction ID from Step 1

Example Request

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 Response (200 OK)

{
  "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"
  }
}
✅ What happens here:
  • The system verifies the latest transaction to the assigned wallet
  • Validates that the received amount matches the expected amount: within 1% of it, plus one smallest unit of the token (for example 0.000001 USDC), in either direction. Otherwise it returns 400 Amount mismatch and the transaction stays PENDING
  • Transaction status changes to PLATFORM_RECEIVED
  • Distribution process automatically starts to send funds to recipients, and the response reports the final status (usually COMPLETED)
Expired checkouts: once the transaction's expiry has passed, verify returns 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.
💡 Polling Strategy: If you receive a pending response, wait a few seconds and retry. Blockchain transactions can take a moment to propagate. You can poll this endpoint every 5-10 seconds until you receive a success response.

Webhooks

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.

Events

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.eventOuter typeEnable alert typeSent when
payment.initializedpayment_initializedPAYMENT_INITIALIZEDStep 1 created the payment
payment.token_updatedwallet_assignedWALLET_ASSIGNEDEvery successful Step 2
payment.receivedpayment_receivedPAYMENT_RECEIVEDStep 3 found the payment on-chain
payment.verifiedpayment_verifiedPAYMENT_VERIFIEDStep 3 finished and the payment is COMPLETED
payment.distribution_completedpayment_verifiedPAYMENT_VERIFIEDEvery recipient was paid
payment.failedpayment_failedPAYMENT_FAILEDDistribution failed (metadata.error says why)
payment.expiredtransaction_expiredTRANSACTION_EXPIREDAn unpaid payment expired

Envelope

{
  "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"
}

Delivery and retries

Verifying the signature

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.

Node.js

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);
}

Python

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)

Next Steps