Skip to main content

Configure for Sandbox

Point the SDK to the sandbox API by setting the host environment variable:
All other environment variables (NEXT_PUBLIC_CUBEPAY_MERCHANT_ID, CUBEPAY_API_KEY) use your sandbox credentials from the Grain Dashboard.

Run an End-to-End Test

1

Create a payment session

Use your server to create a session against the sandbox API.
2

Open the payment modal

Launch the SDK on the client with the returned session credentials. In sandbox, the SDK connects to test blockchain networks (Sepolia) automatically.
3

Complete the payment

Connect a wallet funded with testnet tokens and approve the transaction. The SDK handles network switching automatically.
4

Verify in the dashboard

Go to the Grain Dashboard and navigate to Transactions. Confirm your test payment appears with the expected status.

Test Webhook Delivery

Sandbox webhooks work identically to production. Configure your webhook URL in the dashboard and use a tunneling tool to receive webhooks locally:
Then update your webhook URL in the Grain Dashboard to point to your ngrok URL:

Simulate Payment Statuses

Each webhook delivery contains a status field. In sandbox, payments progress through the full lifecycle: Verify your webhook handler processes each status correctly by monitoring your server logs as you complete test payments.

Sandbox vs Production

Always test the full payment flow in sandbox before switching to production. Verify that your webhook handler, success screen, and error handling all work as expected.