Your organization’s ID.
Web SDK quickstart guide
Get started with the FunnelFox Payments Web SDK: install it, choose an integration, and render your first checkout.
The FunnelFox Payments Web SDK connects your paywall page to FunnelFox Payments Subscription Billing. It renders the checkout through Primer’s Headless Checkout or through Stripe directly, and creates the subscription when the payment succeeds.
Key features
Section titled “Key features”- Type-safe: Complete TypeScript definitions ship with the package.
- Dynamic pricing: Switch the price point without reloading the page.
- Event-driven: Handle success, errors, and state changes with events or callbacks.
- Taxes: Get the total with tax as the buyer’s location changes.
- Decline codes: Tell an insufficient-funds decline apart from other failures.
- On-demand loading: The SDK loads Primer and Stripe only when a checkout needs them.
- Browser support: Chrome 60+, Firefox 55+, Safari 12+, Edge 79+. Internet Explorer is not supported.
Choose your integration
Section titled “Choose your integration”The SDK offers three ways to build a checkout:
createCheckout() renders every available payment method in one
container. Runs on Primer.
Billing.initMethod() renders the card form and each payment button into
your own layout. Runs on Primer.
Billing.stripe renders a Stripe card form and opens Apple Pay or Google
Pay. Runs on Stripe directly.
The steps below use the drop-in checkout.
Get started
Section titled “Get started”1. Install
Section titled “1. Install”Install the SDK from a CDN or from npm.
Include the SDK script. It adds a global Billing object to the page:
<script src="https://unpkg.com/@funnelfox/billing@0.11.0/dist/funnelfox-billing.min.js"></script>Install the SDK from npm:
npm install @funnelfox/billingThe package installs Primer’s @primer-io/checkout-web and Stripe’s
@stripe/stripe-js as dependencies.
You don’t need to add Primer’s scripts to the page. The SDK loads Primer
v2.57.3 from sdk.primer.io when a checkout needs it.
2. Create your first checkout
Section titled “2. Create your first checkout”Create a checkout for a price point and a customer, and render it on your page:
import { createCheckout } from '@funnelfox/billing';
await createCheckout({ orgId: 'your-org-id', priceId: 'price_123', customer: { externalId: 'user_456', email: 'user@example.com', }, container: '#checkout-container',});Required parameters:
orgIdstringrequiredpriceIdstringrequiredThe price point identifier.
customerobjectrequiredCustomer information (requires externalId and email).
containerstringrequiredA CSS selector for the DOM element where the checkout form will be mounted.
After you call createCheckout(), the checkout form appears in the
container, ready for the buyer to pay.