Server-Side Session Creation
Create checkout sessions from your server using the billing API or the @flopay/js helper.
Before rendering a checkout form, you need a session UUID from the billing API. There are two approaches: a raw API route, or the createCheckoutSession helper from @flopay/js.
Next.js API Route
This is the recommended pattern for server-side session creation. It calls POST /v1/checkouts/sessions on the billing API and returns the session UUID.
Client-Side Alternative
The createCheckoutSession helper from @flopay/js handles the API call and browser redirect in one step. This is useful when you want to create sessions directly from the client.
On a 201 response, createCheckoutSession automatically redirects the browser to the checkout page with the session UUID. On 204 (payment method already on file), it redirects to the successUrl.
For automatic retry on timeout errors, use createCheckoutSessionWithRetries: