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

ParameterTypeRequiredDescription
amountintegerYesAmount in cents (e.g., 10000 = $100.00)
currencyCodestringYesFiat currency code (USD, EUR, etc.)
referencestringYesYour internal reference ID
referenceLabelstringYesHuman-readable reference label
clientIdstringYesYour application's Client ID
redirectUrlstringNoURL to redirect after successful payment
expiresAtstringNoISO 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 expires timestamp
  • An HMAC-SHA256 signature to 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

  1. Use unique references — each payment should have a unique reference to prevent duplicates
  2. Amount in cents — always send amounts in the smallest currency unit to avoid decimal issues
  3. Store the checkout URL — save the returned URL in case you need to redirect the customer again
  4. Set up webhooks — always verify payment completion via webhooks rather than relying on redirects
  5. Keep tokens server-side — never expose your Client Token in client-side code

Next Steps