Skip to main content

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

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 is FUNDED, 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

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

Response:

Fetch Session Details

After funding or capture, retrieve the full session state:
The response includes capturableAmount, capturedAmount, and a captures array tracking all capture operations.

Server-Side: Webhook Confirmation

Never rely solely on client-side results to fulfill orders. Always confirm payments server-side via webhooks.

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

Always return a 200 status from your webhook handler, even if your internal processing fails. This prevents unnecessary retries. Handle errors asynchronously.

Next Steps

Learn how to Handle Errors & Edge Cases for robust payment flows.