Base URL
| Environment | Base URL |
|---|---|
| Production | https://api.pay.grain.inc |
| Sandbox | https://api.sandbox.pay.grain.inc |
Payment Sessions
Create Payment Session
| Header | Value |
|---|---|
Authorization | Bearer {CUBEPAY_API_KEY} |
Content-Type | application/json |
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | Payment amount as a decimal string (e.g., "50.00") |
currency | string | Yes | Currency code (e.g., "USD") |
requestId | string | No | Idempotency key — your own UUID to prevent duplicate sessions |
200 OK:
Get Payment Session
| Header | Value |
|---|---|
Authorization | Bearer {paymentSessionToken} |
200 OK:
Captures
Create Capture
FUNDED.
Headers:
| Header | Value |
|---|---|
Authorization | Bearer {CUBEPAY_API_KEY} |
Content-Type | application/json |
| Parameter | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | Idempotency key to prevent duplicate captures |
captureAmount | string | Yes | Amount to capture (e.g., "50.00") |
isFinalCapture | boolean | No | Default false. When true, remaining balance is refunded to the customer and session moves to SUCCEEDED |
202 Accepted:
Get Capture
| Header | Value |
|---|---|
Authorization | Bearer {CUBEPAY_API_KEY} |
200 OK:
Capture Object
| Field | Type | Description |
|---|---|---|
captureId | string | Unique capture identifier |
status | string | CAPTURING (in progress) or CAPTURED (complete) |
captureAmount | string | Amount captured |
refundAmount | string | Amount refunded to customer (on final capture) |
captureTransferTransactionHash | string | null | On-chain hash of the capture transfer |
refundTransferTransactionHash | string | null | On-chain hash of the refund transfer (if applicable) |
Webhooks
Payment Status Update
| Status | Description |
|---|---|
CREATED | Session created, customer has not connected a wallet yet |
PENDING | Wallet connected, awaiting funding transaction |
FUNDED | Funds received at the one-time wallet — ready to capture |
CAPTURING | Capture in progress (funds being transferred) |
SUCCEEDED | Final capture complete — funds settled to your treasury |
CANCELED | Session expired or was cancelled (not funded within 24 hours) |
ERROR | An error occurred during processing |
200 with a JSON-RPC acknowledgment:
Response Fields Reference
Payment Session Object
| Field | Type | Description |
|---|---|---|
paymentSessionId | string | Unique session identifier |
paymentSessionToken | string | Short-lived token for client-side operations |
amount | string | Payment amount |
currency | string | Currency code |
network | string | Blockchain network (e.g., ETHEREUM, SEPOLIA) |
tokenSymbol | string | Token used for payment (e.g., USDC) |
oneTimeWalletAddress | string | Unique receiving address for this session |
userAddress | string | null | Customer’s wallet address (populated after connection) |
fundingTransactionHash | string | null | Transaction hash of the funding transfer |
userSubmittedTransactionHash | string | null | Transaction hash as submitted by the user’s wallet |
capturableAmount | string | Remaining balance available for capture |
capturedAmount | string | Total amount captured so far |
captures | array | Array of capture operations with their statuses and transaction hashes |
status | string | Current session status |
createdAt | string | ISO 8601 creation timestamp |
All endpoints require authentication. See Error Codes for error response formats.