What is the Payment SDK?
The Payment SDK is a drop-in SDK that lets you accept cryptocurrency payments directly in your application. It handles wallet connections, network selection, transaction signing, and payment confirmation — so you can focus on your product. The SDK renders inside a Shadow DOM modal for complete style isolation, supports multiple wallet providers, and works with any JavaScript framework.How It Works
Your server creates a payment session
Call the Grain API from your backend with the payment amount and currency. You receive a
paymentSessionId and paymentSessionToken.The SDK opens a payment modal
Pass the session credentials to the client-side SDK. It opens a modal where the customer selects a wallet, connects, and approves the transaction.
Customer funds a one-time wallet
Each session gets a unique one-time wallet (OTW) address. The customer’s funds are sent to this address. The session status moves to
FUNDED.Your server captures the payment
Once funded, your server calls the capture endpoint to transfer funds from the OTW to your treasury wallet. You can capture the full amount or do partial captures.
Key Features
- Drop-in modal — Shadow DOM-based payment UI with full style isolation. No CSS conflicts with your application.
- Multi-wallet support — WalletConnect, injected wallets (MetaMask, Coinbase Wallet), and more out of the box.
- Payment methods — Crypto (stablecoins) with additional methods coming soon.
- One-time wallets — Every payment session gets a unique receiving address for clean reconciliation.
- Flexible capture — Capture the full amount or do partial captures. Final capture automatically refunds any remaining balance to the customer.
- Webhook confirmations — Receive server-side status updates via JSON-RPC 2.0 webhooks.
- Customizable theme — Match the payment modal to your brand with CSS custom properties.
Payment Methods
| Method | Description | Settlement |
|---|---|---|
| Crypto | Customer pays with stablecoins (USDC) from any supported wallet | On-chain |