Overview
Checkout sessions allow you to launch hosted Flowglad checkout pages to complete customer transactions.Checkout Session Types
Flowglad offers three distinct types of checkout sessions, each tailored to different scenarios:- Product checkout: A “product” checkout session is the most straightforward and you can create it with
createCheckoutSessionin both client and server side. The customer will checkout according to the standard terms defined on your product and price records. Customers can initiate these sessions directly by visiting a product or price purchase page. You specify either thepriceIdor thepriceSlugof the product (bothsingle_paymentandsubscriptionare validpriceType’s), and provide thesuccessUrl,cancelUrl,quantity, and optionallyoutputMetadataandoutputName. See checkoutSession.ts for more information on the parameters. - Add Payment Method: The “Add Payment Method” checkout session provides a flow for customers to securely save a payment method to their Flowglad profile. You can create this type of checkout with
createAddPaymentMethodCheckoutSessionin both client and server side. Upon successful completion, the payment method is stored. Optionally, if atargetSubscriptionIdis provided when creating the session, the newly added payment method will automatically become the default payment method for that specific subscription. See checkoutSession.ts for more information on the parameters. - Activate Subscription: You use this when a subscription already exists, but the customer still needs to provide payment details and formally start billing. It will prompt the customer to add or confirm a payment method, pay any outstanding invoices tied to the subscription, and transition the subscription from a pending/credit state to “active,” establishing the billing cycle anchor. See checkoutSession.ts for more information on the parameters.
Customer Association
When creating checkout sessions from the SDK, the authenticated customer’s ID will be linked automatically to the checkout sesion. Associating a checkout session with an existing customer record ensures that all billing activities are correctly attributed and avoids potential data discrepancies or the creation of duplicate customer profiles. To create anonymous checkout sessions, you can call the create checkout session API directly withanonymous field set to true.
What you can do
- Create product checkout sessions.
- Securely save a payment method to a customer’s Flowglad profile, optionally making it the default payment method for subscriptions.
- …and more!
Example: Launch a product checkout
- Client
- Server
Example: Collect a payment method
- Client
- Server