SDK Service
The Payment SDK uses a singleton service that handles script loading, initialization, and payment execution. Import and use it directly in your components.- Lazy-loads the SDK bundle on first use (no upfront script loading)
- Initializes once and reuses the same instance across your app
- Creates a Shadow DOM inside the
#cubepay-sdk-rootelement for style isolation
Initialization Flow
When you callexecutePayment() for the first time, the service automatically:
Loads the SDK script
Injects
/vendor/cubist-pay-client-sdk.umd.js into the page and waits for window.CubePaySDK to become available.Initializes the SDK
Calls
CubePaySDK.init() with your merchant ID, the container element, and optional configuration (RPC endpoints, theme variables).Configuration Options
The SDK reads configuration from environment variables automatically. You can customize behavior through these settings:| Option | Environment Variable | Description |
|---|---|---|
| Merchant ID | NEXT_PUBLIC_CUBEPAY_MERCHANT_ID | Required. Identifies your merchant account |
Theme Customization
The SDK applies CSS custom properties to the payment modal. Override these in your#cubepay-sdk-root element to match your brand: