Prerequisites
- A Grain merchant account with a Merchant ID
- A server-side API key for creating payment sessions
- Node.js 18+ (for Next.js applications)
Get Your Credentials
1
Get your Merchant ID
Log in to the Grain Dashboard and navigate to Settings > API Keys. Copy your Merchant ID — this is used to initialize the client-side SDK.
2
Get your API key
From the same page, copy your API Key. This is your server-side secret used to create payment sessions.
Configure Environment Variables
Add the following to your.env file:
Add the SDK Mount Point
The Payment SDK renders its payment modal inside a dedicated DOM element. Add this to your root layout:The SDK creates a Shadow DOM inside this element, so its styles are fully isolated from your application. No CSS conflicts.