POST /v1/checkout/sessions, get back a payment URL, redirect your customer, and Flexprice activates the subscription once payment is confirmed.
Session lifecycle
Create a Checkout Session
payment_action.url. Each session has its own link. Do not reuse URLs across sessions.
Request fields
All redirect URLs must be absolute HTTPS URLs. HTTP is accepted only for localhost.
Provider link expiry
Setlink_expiry as a value/unit object:
value must be greater than zero. unit must be second, minute, hour, or day. If omitted, Flexprice uses the provider default. These defaults are also the minimum accepted overrides:
For hosted links, Flexprice sets the session deadline five minutes after the configured link deadline, or five minutes after an earlier expiry returned by the provider. On Stripe, this grace period gives payments already in progress time to settle. When Checkout debits an existing Razorpay mandate, Flexprice can extend the session for settlement: 72 hours for card or UPI and seven days for eNACH. Use the response’s
expires_at as the session deadline.
Stripe Checkout Sessions created through this API save the card for future off-session use, but do not set it as the customer’s default. These sessions do not offer promotion-code entry. The direct /payments option gateway_options.stripe.allow_promotion_codes is separate and does not apply here.
Other Checkout Actions
Four more actions exist, but they are not created through this endpoint. Each is triggered by adding acheckout object to the endpoint that owns the change, so that Flexprice can compute the amount and defer the change itself:
Passing any of these actions here returns a validation error naming the endpoint to use instead (for
add_addon, the error names the deprecated POST /subscriptions/addon). Once created, all of them are read, cancelled, deleted, and monitored through the same endpoints and webhook events described on this page. See Pay-First Checkout.
Get a Checkout Session
checkout_status on your redirect pages before showing the customer a result.
Response (200):
Polling for the result
Reading a session that is stillinitiated or pending checks it against the payment provider and completes it if the customer has already paid, so a late or dropped webhook does not leave a paying customer waiting. Gateway calls are debounced, so reading in a tight loop does not add load. Poll until terminal is true, waiting next_poll_after_ms between reads.
A still-open session cannot complete after expires_at.
Terminal responses omit
payment_action. A cancellation is represented by the expired status and cancelled_at, not by a separate checkout status.
A declined payment does not fail the session. The customer can retry on the same link while the provider link remains live, and the session stays pending until payment, expires_at, or cancellation. For Stripe, the link expires five minutes before the session deadline, so the grace period is for a payment already in progress. On unpaid Stripe session cleanup, Flexprice attempts to close the provider link after the session update commits. This is best-effort cleanup, not part of the session transaction; a provider error can leave the link open. Flexprice expires sessions through its own expires_at cleanup; Stripe’s checkout.session.expired event is unhandled and does not transition a payment status. Chargebee’s provider page can also outlive the Flexprice session because its adapter does not apply the requested provider deadline.
Reconciliation on read applies to Razorpay sessions. Chargebee sessions reconcile through webhooks, and reads return stored state.
Cancel a Checkout Session
Cancel a session the customer has abandoned so that everything it was holding is released immediately instead of waiting forexpires_at.
GET /checkout/sessions/{id}, with terminal set to true. An active session comes back as expired and gets cancelled_at. A session that had already failed or expired is returned unchanged, so checkout_status can also be failed.
Canceling an active session publishes both checkout.session.expired and checkout.session.cancelled. A session with a successful payment cannot be canceled before expires_at; completed sessions cannot be canceled.
Cancelling releases whatever the session was holding:
- Draft subscription: A subscription created behind the session is archived along with its addons, coupons, credit grants, and tax associations. A change deferred behind the session is never applied.
- Pending addon attachments: Addons attached behind the session are archived.
- Pending wallet top-up: The pending wallet transaction is marked failed, along with any pending bonus credit earned from the purchase.
- Payment and invoice: The payment and invoice created for the session are archived. If the invoice already holds customer value, such as applied prepaid credits, it is voided first so that value is returned.
Cancelling frees the session’s
idempotency_key for reuse.
Delete a Checkout Session
204 No Content, not a final session state. Cleanup marks the session expired and publishes checkout.session.expired, but does not set cancelled_at or publish checkout.session.cancelled. Unlike POST /checkout/sessions/{id}/cancel, Delete does not run the paid-before-expiry guard. A session already in a terminal state (completed, failed, expired) is archived as is.
Webhook events
Subscribe to these in Developers > Webhooks to drive fulfillment from your backend.Safe to receive the same event twice. If your payment provider delivers
payment_link.paid more than once, Flexprice ignores the duplicate. Your
webhook handler should also be idempotent for the same reason.Requirements
Customer must exist first. Thecustomer_external_id must refer to a customer already in Flexprice. Create them at sign-up if they don’t exist yet.
Plan must have a non-zero charge. Checkout requires a payable invoice amount to generate a payment link. Plans with only free or zero-amount charges will cause session creation to fail.
Idempotency on retry. An idempotency_key is reserved while its session is active, so retrying with the same key returns 409 rather than creating a duplicate. Read the open session with GET /checkout/sessions/{id} to recover its payment URL. Once the session reaches a terminal state the key can be reused.
Razorpay Setup
Configure the webhook events Razorpay needs to send Flexprice.
Implementation Guide
Full end-to-end integration with code examples.

