Skip to main content
The Billing Web SDK is fully typed and ships with TypeScript type definitions out of the box. The SDK includes type definitions for all functions, options, and objects. This helps you catch errors early and provides autocompletion in your code editor. You can import the types and use them in your code:
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
});
I