API Reference@flopay/js
createCheckoutSession
Functions for creating checkout sessions via the billing API and redirecting users.
createCheckoutSession
Creates a checkout session via the billing API and redirects the user to the hosted checkout page.
Behavior
- 201: Redirects to
{checkoutBaseUrl}/secure?id={uuid}&...redirectParams}. Returns{ status: 201, redirectUrl: string }. - 204: Redirects directly to
successUrl(payment method already on file). Returns{ status: 204 }. - Other: Returns
{ status: number }without redirecting.
When setCookie is true (default), a checkout_data cookie is set with the cancelUrl for navigation purposes.
Parameters
See CreateSessionParams for the full parameter table.
Example
createCheckoutSessionWithRetries
Creates a checkout session with automatic retry on timeout/abort errors. Uses exponential backoff: 100ms, 200ms, 400ms, etc.
Parameters
Accepts all CreateSessionParams plus:
| Parameter | Type | Required | Description |
|---|---|---|---|
maxRetries | number | No | Maximum number of retry attempts. Defaults to 3. Must be a positive integer. |
Retry Behavior
- Only retries on
AbortError(i.e. timeout). - Non-abort errors are thrown immediately.
- Backoff delay:
100ms * 2^attempt(100ms, 200ms, 400ms).