Documentation Index
Fetch the complete documentation index at: https://docs.grain.inc/llms.txt
Use this file to discover all available pages before exploring further.
Client-Side: Transaction Hash
When a customer completes the payment modal,executePayment resolves with the funding transaction details. At this point the session status is FUNDED — funds are sitting in the one-time wallet (OTW), ready for you to capture.
Result Object
| Field | Type | Description |
|---|---|---|
transactionHash | string | On-chain funding transaction hash |
session | object | Full session details (ID, status, network, token, addresses) |
details | object | Additional session metadata |
FUNDED does not mean the payment is complete. You must capture the funds to transfer them from the OTW to your treasury wallet.Capture the Payment
Once a session isFUNDED, your server calls the capture endpoint to move funds from the one-time wallet to your treasury wallet. Capture supports both full and partial amounts.
Capture Request
Capture Parameters
| 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, any remaining balance is refunded to the customer and the session moves to SUCCEEDED |
Capture Response
Capture is an async operation. The response returns immediately with status
CAPTURING. You receive a webhook when the capture completes.Partial vs Final Capture
Partial Capture
Capture a portion of the funded amount. The session returns to
FUNDED and remains open for additional captures.Final Capture
Capture the remaining amount (or a specific amount) and close the session. Any uncaptured balance is refunded to the customer.
Check Capture Status
| Field | Type | Description |
|---|---|---|
captureId | string | Unique capture identifier |
status | string | CAPTURING or CAPTURED |
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 |
Fetch Session Details
After funding or capture, retrieve the full session state:capturableAmount, capturedAmount, and a captures array tracking all capture operations.
Server-Side: Webhook Confirmation
Register Your Webhook Endpoint
Configure your webhook URL in the Grain Dashboard under Settings > Webhooks.Handle the Webhook
Grain sends payment status updates as JSON-RPC 2.0 requests:Webhook Payload
Payment Status Lifecycle
| Status | Meaning |
|---|---|
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 |