Skip to main content

Accept Stablecoin Payments

Before you start: Create your API credentials and configure your webhook URL in the Cray Merchant Dashboard.

1. Create a Payment

Method: POST
Headers
Request Body
Example Response
The response contains the payment URL and the order ID. Use the order ID for subsequent API requests.

2. Generate a QR Code

Method: POST
Headers
Example Response
The response contains a Base64-encoded JPEG data URL. Display it as a QR code in your POS interface.
Important: The QR code expires in 2 minutes. Generate a new QR code if it expires before the payment is completed.

3. Test the Integration

Use the Cray Testing Wallet to test the payment flow without using a regular customer wallet.

Testing flow

  1. Create a payment using the Create Payment API.
  2. Generate the payment QR code.
  3. Open the Cray Testing Wallet.
  4. Use the testing wallet to scan or process the payment QR code, following the wallet’s interface.
  5. Complete the test payment.
  6. Monitor the order status through the Status API or your configured webhook.
You can also follow the Payer Flow Testing Guide to test the customer payment experience with a compatible crypto wallet and testnet funds.

Order Status API

Retrieve the latest payment status for an order or subscribe to real-time status updates.

Endpoint

Method: GET
Example
By default, this endpoint uses Server-Sent Events (SSE) to stream live status updates.

Server-Sent Events (Default)

Example event:
When the order status changes, another event is sent automatically. Example:
Keep the connection open to receive subsequent status updates. Handle incoming events until the payment reaches a terminal state or the connection closes.

Standard HTTP Response (Polling)

If you prefer polling instead of SSE, append ?sse=false.
Example response:
With polling, periodically request the order status until the payment reaches a terminal state or requires further action.

Possible Status Values

The Status API can return the following statuses.

Complete POS Integration Flow

The QR_Scanned, QR_Expired, QR_Rejected, and Low_Balance events are POS-specific. Handle them in your POS interface to guide the customer through the payment process.

Recommended Architecture

The SSE connection is primarily for real-time status updates to the client, while the webhook should be treated as the authoritative server-to-server notification. The recommended architecture is:

Important Integration Guidelines

  1. Use SSE for live updates. Display the latest payment status and provide customer feedback in real time.
  2. Use webhooks for backend processing. Treat verified webhook events as the authoritative server-to-server notification.
  3. Verify webhook signatures. Validate the HMAC signature before processing webhook events.
  4. Handle QR expiration. If the status becomes QR_Expired, guide the customer through generating a fresh QR code.
  5. Support retries where appropriate. When Low_Balance is received, guide the customer to resolve the balance issue and retry using the supported payment flow.
  6. Test before going live. Use the Cray Testing Wallet to validate the POS integration.