Create Payment
Create payment requests to accept cryptocurrency payments from your customers. Each payment generates a unique checkout URL where customers complete their transactions.
Payment Flow Overview
sequenceDiagram
participant M as Merchant Server
participant API as Payment Gateway API
participant C as Customer
participant B as Blockchain
M->>API: Create Payment Request
API->>M: Return Checkout URL
M->>C: Redirect to Checkout
C->>API: Complete Payment
API->>B: Monitor Transaction
B->>API: Confirm Payment
API->>M: Webhook Notification
Create Payment Endpoint
Request
POST /api/payment/checkout
Authorization: Bearer YOUR_CLIENT_TOKEN
Content-Type: application/json
Authentication: Requires a Client Token with the payments.create scope.
Request Body
{
"amount": 10000,
"currencyCode": "USD",
"reference": "ORDER-123",
"referenceLabel": "Order #123",
"clientId": "your_client_id",
"redirectUrl": "https://yoursite.com/payment/success",
"expiresAt": "2026-03-15T12:00:00Z"
}
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | integer | Yes | Amount in cents (e.g., 10000 = $100.00) |
currencyCode | string | Yes | Fiat currency code (USD, EUR, etc.) |
reference | string | Yes | Your internal reference ID |
referenceLabel | string | Yes | Human-readable reference label |
clientId | string | Yes | Your application's Client ID |
redirectUrl | string | No | URL to redirect after successful payment |
expiresAt | string | No | ISO 8601 expiration datetime (default: 1 year) |
You can also use siteId as an alias for clientId.
Success Response
{
"data": {
"checkoutUrl": "https://yourdomain.com/checkout/550e8400-...?expires=1742044800&signature=abc123..."
}
}
The checkoutUrl is a signed URL that includes:
- The payment ID in the path
- An
expirestimestamp - An HMAC-SHA256
signatureto prevent tampering
Redirect your customer to this URL to complete payment.
Code Examples
const axios = require('axios');
async function createPayment(orderData) {
const response = await axios.post(
'https://api.yourdomain.com/api/payment/checkout',
{
amount: orderData.total * 100, // Convert to cents
currencyCode: 'USD',
reference: orderData.id,
referenceLabel: `Order #${orderData.id}`,
clientId: process.env.PAYMENT_CLIENT_ID,
redirectUrl: `https://mystore.com/orders/${orderData.id}/success`
},
{
headers: {
'Authorization': `Bearer ${process.env.PAYMENT_CLIENT_TOKEN}`,
'Content-Type': 'application/json'
}
}
);
return response.data.data.checkoutUrl;
}
// Redirect customer to checkout
const checkoutUrl = await createPayment({ id: 'ORDER-123', total: 100.00 });
Payment Expiration
Control how long the checkout link remains valid using the expiresAt parameter:
{
"expiresAt": "2026-03-15T12:00:00Z"
}
If not specified, the checkout link defaults to a 1-year expiration.
Best Practices
- Use unique references — each payment should have a unique
referenceto prevent duplicates - Amount in cents — always send amounts in the smallest currency unit to avoid decimal issues
- Store the checkout URL — save the returned URL in case you need to redirect the customer again
- Set up webhooks — always verify payment completion via webhooks rather than relying on redirects
- Keep tokens server-side — never expose your Client Token in client-side code