npm install @cometh/checkout-sdk
- Initialize SDK
import {CheckoutSDK} from '@cometh/checkout'
const sdk = new CheckoutSDK(apiKey)
- Start checkout flow
const request = {
productId: 1,
user: {
walletAddress: '0x1234567890',
email: 'test@email.com'
}
}
await sdk.checkout(request)
- Handle flow events
import {CheckoutSDK, CheckoutError, CheckoutSuccess, CheckoutEvents} from '@cometh/checkout'
const sdk = new CheckoutSDK(apiKey)
sdk.on(CheckoutEvents.START, () => {
console.log('display is ON and flow has started');
});
sdk.on(CheckoutEvents.SUCCESS, (result: CheckoutSuccess) => {
});
sdk.on(CheckoutEvents.FAILURE, (error: CheckoutError) => {
});