Skip to content

createClientSession(params)

Creates a client session without rendering a UI for advanced payment flows

Creates a client session without rendering a UI. This function is used in advanced scenarios where you want to obtain a payment client token and order ID first, then handle the UI or payment flow manually.

The session is a Primer session. For Stripe checkouts, use the Billing.stripe methods.

priceIdstringrequired

The price point identifier.

externalIdstringrequired

The customer’s external ID (your user ID).

emailstring

Customer’s email address.

orgIdstring

Organization ID, if not configured globally. Not needed if you already called configure().

countryCodestring

ISO country code of the customer.

clientMetadataobject

Custom metadata attached to the order.

apiConfigobject

Per-call API settings: baseUrl and region. These override the values from configure().

A Promise resolving to { clientToken, orderId, type }:

  • clientToken: The token to use with Primer’s Headless Checkout.
  • orderId: The order identifier in FunnelFox Payments.
  • type: Always 'session_created'.
import { createClientSession } from '@funnelfox/billing';
const session = await createClientSession({
priceId: 'price_123',
externalId: 'user_456',
email: 'user@example.com',
orgId: 'your-org-id', // Optional if configured
});
console.log(session.clientToken); // Use with Primer Headless Checkout
console.log(session.orderId);