import { configure, createCheckout, CheckoutInstance, PaymentResult } from '@funnelfox/billing';
configure({ orgId: 'your-org-id' });
// Create checkout with full type safety
const checkout: CheckoutInstance = await createCheckout({
priceId: 'price_123',
customer: { externalId: 'user_456', email: 'user@example.com', countryCode: 'US' },
container: '#checkout',
clientMetadata: { source: 'web', campaign: 'summer-sale' },
});
// Using the typed event handler
checkout.on('success', (result: PaymentResult) => {
console.log('Order ID:', result.orderId);
console.log('Status:', result.status);
// `result` is strongly typed, so accessing properties is checked by the compiler
});