5-minute integration

Create a crypto payment session.

Use the payment session API to create a hosted checkout URL. The same object can carry order IDs, customer IDs, product codes, coupon context, and webhook callback details.

1. Send the create-session request

Required fields are amount, currency, and network. Use test keys first, then switch to live keys after mainnet activation.

cURL

curl -X POST https://xpayr.com/api/v1/payments \
  -H "Authorization: Bearer sk_test_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 49.90,
    "currency": "USDT",
    "network": "tron-mainnet",
    "metadata": {
      "order_id": "ORDER-1001",
      "customer_id": "cus_123"
    },
    "success_url": "https://example.com/paid",
    "cancel_url": "https://example.com/cancel",
    "ipn_callback_url": "https://example.com/webhooks/xpayr"
  }'

Node.js

const response = await fetch("https://xpayr.com/api/v1/payments", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.XPAYR_SECRET_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    amount: 49.90,
    currency: "USDT",
    network: "tron-mainnet",
    metadata: { order_id: "ORDER-1001", customer_id: "cus_123" },
    success_url: "https://example.com/paid",
    cancel_url: "https://example.com/cancel",
    ipn_callback_url: "https://example.com/webhooks/xpayr"
  })
});

const session = await response.json();
console.log(session.payment_url);

PHP

$payload = [
    'amount' => 49.90,
    'currency' => 'USDT',
    'network' => 'tron-mainnet',
    'metadata' => ['order_id' => 'ORDER-1001', 'customer_id' => 'cus_123'],
    'success_url' => 'https://example.com/paid',
    'cancel_url' => 'https://example.com/cancel',
    'ipn_callback_url' => 'https://example.com/webhooks/xpayr',
];

$ch = curl_init('https://xpayr.com/api/v1/payments');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('XPAYR_SECRET_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
]);

$session = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $session['payment_url'] ?? 'No payment URL returned';

2. Redirect to the returned payment URL

{
  "id": "ps_abc123",
  "object": "payment_session",
  "amount": "49.90",
  "currency": "USDT",
  "network": "tron-mainnet",
  "status": "pending",
  "payment_url": "https://xpayr.com/test/ps_abc123",
  "livemode": false
}

3. Confirm status

Use the public status endpoint for lightweight confirmation and signed webhooks for production order updates.

curl https://xpayr.com/api/v1/payments/ps_abc123/status

4. Download the quickstart files