Skip to content

Types

TypeScript type definitions for the FunnelFox Payments Web SDK

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.

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.
Type Describes
CreateCheckoutOptions Options for createCheckout()
CheckoutInstance The checkout object createCheckout() returns
CheckoutState A checkout state
CheckoutStatus The result of getStatus()
PaymentResult Data of the success event
InitMethodOptions Options for Billing.initMethod(), including callbacks
PaymentMethodInterface The object Billing.initMethod() returns
PaymentMethod Enum: PAYMENT_CARD, PAYPAL, GOOGLE_PAY, APPLE_PAY
StripeCardFormOptions Options for Billing.stripe.createCardForm()
StripeCardForm The { submit() } handle the card form returns
StripeWalletOptions Options for Billing.stripe.purchaseWallet()
CreateClientSessionOptions Options for createClientSession()
ClientSessionData The session createClientSession() returns
TaxInfo Data passed to onTaxChange
TaxBehavior 'inclusive' or 'exclusive'
TaxBreakdownEntry One jurisdiction in TaxInfo.taxBreakdown
PaymentFailure An Error with decline code fields
DeclineCodeSource 'primer', 'stripe', 'adyen', or another provider name
ApplePayButtonType An Apple Pay button type
BillingCardOptions The card option: cardholder name and email fields
SDKConfig Options for configure()
APIConfig The apiConfig option: baseUrl and region
  • 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.
import { configure, createCheckout, PaymentMethod } from '@funnelfox/billing';
import type {
CheckoutInstance,
PaymentResult,
TaxInfo,
} from '@funnelfox/billing';
configure({
orgId: 'your-org-id',
});
const checkout: CheckoutInstance = await createCheckout({
orgId: 'your-org-id',
priceId: 'price_123',
customer: {
externalId: 'user_456',
email: 'user@example.com',
countryCode: 'US',
},
container: '#checkout',
clientMetadata: {
source: 'web',
campaign: 'summer-sale',
},
paymentMethodOrder: [
PaymentMethod.PAYPAL,
PaymentMethod.PAYMENT_CARD,
PaymentMethod.GOOGLE_PAY,
PaymentMethod.APPLE_PAY,
],
onTaxChange: (info: TaxInfo) => {
console.log('Total:', info.amountTotal, info.currency);
},
});
checkout.on('success', (result: PaymentResult) => {
console.log('Order:', result.orderId);
console.log('Status:', result.status);
});