Skip to main content
The FunnelFox Payments Web SDK ships with TypeScript type definitions for all methods, options, and objects. They catch errors early and give you autocompletion in your code editor. Import types from @funnelfox/billing, or from @funnelfox/billing/types if you only need the types.

Imports

These names are available as named imports:
  • Methods: configure, createCheckout, createClientSession, getAvailablePaymentMethods.
  • Namespace: Billing (also the default export).
  • Enum: PaymentMethod.
  • Constants: EVENTS, CHECKOUT_STATES, ERROR_CODES, DEFAULTS, SDK_VERSION.
  • Error classes: FunnefoxSDKError, APIError, NetworkError, PrimerError, CheckoutError, ValidationError, ConfigurationError.
Call initMethod(), silentPurchase(), and the Stripe methods through the Billing object: Billing.initMethod(), Billing.silentPurchase(), and Billing.stripe.*. The type definitions also declare them as named exports, but those named imports are undefined at runtime.

Main types

TypeScript notes

  • orgId in createCheckout(): The options type requires orgId, even after you call configure().
  • Error classes: The type definitions declare them as interfaces, so instanceof doesn’t compile. Narrow errors by error.name instead. Learn more in Error handling.
  • Events beyond the core four: on() accepts 'success', 'error', 'status-change', and 'destroy' as strings. For other events, such as purchase-failure, pass the EVENTS constant and cast the handler argument. Learn more about purchase-failure.
  • Tax callbacks: onTaxChange receives a typed TaxInfo. Use the callbacks rather than events for tax updates.

Example