Checkout sessions
A checkout session collects payment for one order from one buyer. Your backend creates it when the buyer is ready to pay. A hosted session gives you a URL on Flint's checkout page to send the buyer to. A headless session gives your backend a scoped credential so your own storefront can run the checkout. Both kinds share the same order, expiration, replacement, and webhook behavior.
A session is single-use. For one URL that many buyers can open, such as a pricing page, a QR code, or an ad, use a payment link. For a bill with a due date, reminders, and a PDF, use an invoice. Payment links vs checkout sessions vs invoices compares the three.
How a hosted checkout works#
- Browser sends 1. the buyer clicks Pay to Your backend
- Your backend sends 2. create a checkout session to Flint
- Flint returns session and its url to Your backend
- Your backend returns 3. redirect to url to Browser
- Browser sends 4. the buyer pays on Flint's checkout page to Flint
- Flint returns 5. redirect to your success URL to Browser
- Flint sends 6. order.paid webhook to Your backend
The redirect in step 5 is for the buyer. Your backend learns about payment from the webhook in step 6, or by reading the session, as described in Confirm the payment.
A session's status records where it is:
status on checkout sessionOnly an open session takes payment. A buyer who opens the URL of a session that has ended sees a message that the checkout is no longer available, never a payment form, so an old link can't collect an old price. An open session always collects the order's current total, and the buyer approves that total before paying.
When a subscription plan ends automatically, subscription_terms.end_after gives the end condition frozen with the order. Use it to limit the billing schedule you show the buyer. For example, a cycles condition with cycle_count: 1 means the subscription ends after one paid billing cycle, with no renewal charge.
For a subscription signup, subscription_terms.recurring_price_phases quotes the recurring merchandise price after signup promotions, in order from the first paid billing period after any trial. Each phase has recurring_total_money and a positive billing_period_count, or null for the ongoing price. For example, a 14-day trial with 25% off a $60 monthly plan for three paid periods has phases of $45 for three periods, then $60 with no period limit. trial_period_days describes the trial. Tax and shipping are additional where they apply, as with recurring_total_money. Every subscription quote includes at least one phase. starts_at is a nullable RFC 3339 timestamp; it is null when the billing start depends on when the buyer pays. Use the trial duration in that case. Reading a quote does not reserve or consume a promotion use.
For gift subscriptions and gift card purchases, set sender_name inside gift_recipient or gift_card_recipient to show the giver's name in the recipient's email. The field is optional and accepts up to 255 characters on one line.
Create a session#
Every create request sends a type that says what the checkout collects payment for. Each type takes its own fields:
type | Send | Use it when |
|---|---|---|
order | order_id | Your backend already created an order with line items, pricing, and the customer. Most integrations use this. replace_checkout_session_id is optional. |
quick_pay | quick_pay_item | You want to charge a name and an amount without building an order first. customer_id and tax are optional. |
subscription_plan | subscription_plan_id | You want a hosted signup page for a subscription plan. subscription_terms, customer_id, and tax are optional. |
A request without type returns 400 INVALID_REQUEST with detail REQUIRED and param: type, and an unknown value returns INVALID_VALUE. A field that belongs to another type returns 400 INVALID_REQUEST with detail UNKNOWN_FIELD and the field in param, so type: "order" with quick_pay_item is refused. The same request without order_id also returns REQUIRED on order_id. Flint creates nothing for a rejected request.
Every session collects an order: with quick_pay or subscription_plan, Flint creates the order for you. A standalone PaymentIntent can't back a session, and sending payment_intent_id returns 400 INVALID_REQUEST with detail UNKNOWN_FIELD. Collect a standalone PaymentIntent on your own page as Server-confirmed payments describes.
Payment links and invoices create their own sessions. Every session has a read-only type that is fixed when the session is created:
Session type | The session |
|---|---|
order | Pays an order that existed before the session, including the replacement order of a return resolution. |
quick_pay | Pays the order Flint created from quick_pay_item. |
subscription_plan | Signs the buyer up for subscription_plan_id. |
invoice | Pays the invoice in invoice_id. |
payment_link | Started from the payment link in payment_link_id. |
Flint can add type values, so handle an unknown one gracefully. Lists filter by type, as Retrieve and list sessions describes.
Pay an existing order#
Create the order first, then create a session for it. Amounts are integers in the currency's minor unit.
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-order-tote-001" \
-d '{
"type": "order",
"order_id": "ord_1kmn0aExample",
"redirects": {
"success_url": "https://example.com/thanks",
"cancel_url": "https://example.com/cart"
}
}'
Flint responds with 201 Created:
{
"data": {
"checkout_session_id": "cs_1kmn0aExample",
"status": "open",
"surface": "hosted",
"order_id": "ord_1kmn0aExample",
"type": "order",
"expires_at": "2026-07-04T17:04:05Z",
"url": "https://checkout.withflintpay.com/checkout/cs_1kmn0aExample#checkout_token=cklt_v1..."
}
}
Store checkout_session_id with your order. Send the buyer to url, as described in Send the buyer to checkout. Hosted responses omit checkout_auth_token; headless checkout returns it instead of url.
Send an Idempotency-Key on every create. If the response is lost, retry with the same key and Flint returns the same session instead of creating a second one. Testing walks through this flow from creating the order to a test payment.
Hosted checkout pays an order with one payment method. If you staged payment legs with POST /v1/payment-intents and two or more are unpaid, creating or replacing a hosted session returns 409 RESOURCE_IN_USE with the legs in details[0].blocking_resources. Cancel them so checkout collects the balance in one payment, or collect a split payment in your own UI as Pay in more than one leg describes. Headless sessions have no such limit.
Charge a quick amount#
When there is no cart to model, type: "quick_pay" with quick_pay_item charges a name and an amount in one call:
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-consult-001" \
-d '{
"type": "quick_pay",
"quick_pay_item": {
"name": "Design consultation",
"amount_money": {"amount": 9900, "currency": "USD"}
},
"redirects": {
"success_url": "https://example.com/thanks"
}
}'
Flint creates an order with that one line item and returns its order_id on the session. Keep it: refunds, receipts, and reporting all work from the order. To tax the amount, add quick_pay_item.tax with taxable and line_item_tax_category. To link the order to an existing customer, send customer_id.
Start a subscription signup#
Subscription checkout requires the buyer's email before payment, entered on the page or shared by their wallet.
type: "subscription_plan" with subscription_plan_id creates a signup page for a plan. The buyer enters their email and pays with a card, Apple Pay, or Google Pay. When they finish, Flint creates the subscription and its first order, and saves the card with usage: "off_session" so the subscription can charge renewals. The plan must be active: an inactive or archived plan returns 409 ACTION_NOT_ALLOWED with reason archived or unsupported_state. If the plan becomes inactive while the session is open, paying the session returns 409 ACTION_NOT_ALLOWED with reason archived or unsupported_state. While the session is open, the plan can't be archived.
The subscription belongs to the session's customer_id when you set one. Without it, a buyer who types the email of an existing customer confirms that email first: paying returns 409 ACTION_NOT_ALLOWED with reason verification_required, and the buyer enters a six-digit code Flint emails them. Hosted checkout shows this step. The buyer enters the code, then presses Pay again; their payment details are kept. In your own page, request the code with POST /v1/checkout-sessions/{checkout_session_id}/customer-verifications and purpose save_payment_method, confirm it, and pay again with the credential the confirmation returns, as Who the subscription belongs to shows. A buyer with a new email needs no code, and Flint creates their customer.
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-pro-signup-001" \
-d '{
"type": "subscription_plan",
"subscription_plan_id": "plan_1kmn0aExample",
"redirects": {
"success_url": "https://example.com/welcome"
}
}'
The hosted signup response includes url and omits checkout_auth_token. Send the buyer to that URL. Signup sends subscription.created. Manage the subscription afterward through the subscriptions API. For a public signup URL that every buyer can share, use a subscription signup link. To run signup in your own storefront, see Start a subscription.
A partner app can price the signup and every later payment with platform_fee_rule on this request. The rule prices the first payment, and Flint copies it onto each subscription the order starts. It is fixed for the session's life, and it takes the place of platform_fee, which a signup doesn't accept. A session created with both returns 400 INVALID_REQUEST with NOT_ALLOWED on platform_fee_rule. See Charge a fee on every subscription payment.
Apply an offer before checkout opens#
For quick_pay or subscription_plan, add "discounts": [{"promotion": {"promotion_id": "promo_1kmn0aExample"}}] to the create request. You can also select by promotion_code. Flint applies the offer to the order it creates; if redemption fails, it creates neither the order nor the session.
Use promotion_config.codes_enabled: false alongside the offer when buyers shouldn't add codes. Account promotion settings still apply, including account codes being enabled for code-type promotions selected by ID. Buyers can't remove by-ID offers, and eligible offers stay when buyers change subscription terms, address, or codes. Read savings on order.discounts, or order.deferred_promotions for a trial. See Apply a promotion when you create a checkout session for ranking warnings and errors.
Send the buyer to checkout#
Send the buyer to url exactly as returned:
- From a server-rendered page, respond with an HTTP redirect to the URL.
- From a single-page app, navigate the browser with
window.location.assign(url).
The #checkout_token fragment is what lets the buyer's browser open the session. Don't strip it, and don't rebuild the URL from the session ID. Treat the URL as belonging to that buyer: deliver it to them, and keep it out of logs, analytics, and shared links.
Handle the return#
On a hosted session, redirects sets where the buyer goes when they leave checkout:
redirects.success_url: where the buyer lands after paying. Flint addscheckout_session_idandorder_idquery parameters with the session and order IDs, replacing any parameters with those names.redirects.cancel_url: where the buyer goes if they leave without paying. The session staysopen, so they can come back to the same URL and pay until it expires.redirects.expired_url: where Flint sends a buyer who opens the session after it expires. Without it, they see Flint's expired-checkout page.
Each URL is an absolute HTTPS URL of up to 2,048 characters. Test mode also accepts HTTP loopback URLs. A headless session takes no redirects; see Embed checkout in your storefront.
A buyer can close the tab before the success redirect, or open the success URL directly, so the redirect proves nothing about payment. Confirm payment from your backend.
Confirm the payment#
Subscribe to webhooks for the result:
The webhook events catalog lists each payload. You can also read the session at any time:
curl "https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample?expand=order" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": {
"checkout_session_id": "cs_1kmn0aExample",
"status": "paid",
"terminal_reason": "payment_succeeded",
"order_id": "ord_1kmn0aExample",
"payment_intent_ids": ["pi_1kmn0aExample"],
"order": {
"order_id": "ord_1kmn0aExample",
"status": "closed",
"payment_status": "paid"
}
}
}
Embed checkout in your storefront#
Set surface: "headless" when your storefront renders the checkout. The response includes checkout_auth_token instead of url, because there is no Flint page to send the buyer to.
Note: Coming from Stripe Embedded Checkout?
Stripe's ui_mode: embedded mounts a prebuilt iframe. Flint has no iframe checkout: surface: "headless" means you build the checkout screens yourself and collect the card with Stripe Elements. For a prebuilt page, send the buyer to a hosted session's url. Migrating from Stripe maps the rest.
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-cart-123" \
-d '{
"type": "order",
"order_id": "ord_1kmn0aExample",
"surface": "headless"
}'
An invoice session (type: invoice, with invoice_id set) collects delivery and an address fixed when the invoice was issued. The buyer can't change them. Delivery quotes, selection writes, and releases return 409 ACTION_NOT_ALLOWED with reason configuration_required and the invoice in details[0]. Reads stay available. The merchant changes delivery or the address by voiding the invoice and issuing a new one. Set delivery through the delivery field on PATCH /v1/orders/{order_id} before issue, or on POST /v1/orders when creating the order. Use an ordinary checkout session or a payment link when the buyer should choose shipping.
Keep the checkout credential on your backend, tied to your own signed browser session. When your backend calls Flint on the buyer's behalf, it sends the credential as a bearer token in place of your API key. The token names its session, so you send no session ID beside it:
GET /v1/checkout-sessions/cs_1kmn0aExample
Authorization: Bearer ckat_1kmn0aExample
Each request carries one credential in Authorization: Bearer, and the prefix tells an API key from a checkout credential, which starts with ckat_. In a backend that holds both, choose the credential in one place rather than in each handler.
A checkout credential reaches only its own session. Using one on another session's /v1/checkout-sessions/{checkout_session_id} path, or to read, cancel, or pay with a payment intent that belongs to another order or session, returns 404 RESOURCE_NOT_FOUND, the same as an unknown ID. The cklt_ token in a hosted session's url fragment is a launch token for the hosted page, not an API credential: sending it as a bearer token returns 403 FORBIDDEN with details[0].reason checkout_launch_token_restricted.
Flint doesn't accept these calls from a browser on your domain. Relay them through your backend, with CSRF protection, origin checks, and rate limits on your own routes. Build your own checkout covers the full integration, and Securing a headless checkout covers the security boundary.
Send page_origin with the origin of your checkout page if buyers can enter gift card codes there. It names the one origin that can show the gift card challenge Flint requires after repeated failed codes. Build your own checkout covers the challenge.
Send payment_return_url for a headless session. It's where Flint returns the buyer after a redirect-based payment step such as Affirm, whatever the outcome, and your page there reads the session to show the result. It must be an absolute HTTPS URL on your site with no credentials, query string, or fragment, and it's required when the session offers Affirm. Test mode also accepts HTTP loopback URLs. Flint adds no query parameters to it. Flint deliberately excludes query strings from payment return URLs so credentials and provider state cannot cross its payment relay. Put your own identifiers in the path, for example https://shop.example/return/sub_123 instead of https://shop.example/return?subscription=sub_123. redirects isn't allowed on a headless session, and payment_return_url and page_origin aren't allowed on a hosted one; each returns 400 INVALID_REQUEST with detail NOT_ALLOWED.
What the checkout credential can do#
The credential works only for its own session and that session's order. It acts for the customer the session was created with, from the session's customer_id, and that doesn't change if the order gets a customer later. A session created without a customer acts for one only after the buyer confirms a verification code, and then only with the credential that confirmation issues. See Confirm the buyer's email.
The checkout credential can
- Read the session, its order, and the order's PaymentIntents
- Create and cancel payment legs (PaymentIntents) on the order
- Start, resume, read, list, and cancel the order's payment attempts
- Confirm and cancel its own session's payment intents
- Quote, select, read, and clear delivery, and check pickup availability
- Change line-item modifiers and gift card recipients
- Apply and remove gift cards
- Preview and apply promotion codes, and reprice and remove discounts
- Set the requested tip, or turn on automatic tax with a tax location
- Save
buyer_contact - List the checkout customer's active saved payment methods
- Request and confirm a verification code for the buyer, including the code a subscription signup needs when the typed email belongs to an existing customer
- Save the card the buyer typed, when they ask and
can_save_payment_methodistrue - Send the order's receipt, once the session is
paidorpartially_paid
Needs your API key
- Read or change any other order or session
- Make any other change to line items or order fields
- Apply a discount by ID, or create a manual discount
- Change the session's
metadataorexternal_reference_id - Add, edit, or remove payment methods
- Manage customers, subscriptions, or merchant settings
- Refund, or handle disputes
A session read with the checkout credential leaves out metadata, external_reference_id, closed_reason_message, and url. It adds what the buyer's page needs: payment_collection and setup_collection for mounting the payment form, the save-card offer described in Saved payment details, customer_prefill, and merchant_support. Its payments lists the payment options the buyer can use now, where your API key sees the options configured for the session. The API reference marks the credentials each field is withheld from.
Configure the checkout#
Each of these fields is optional, and most default to the merchant's checkout settings from the dashboard. Within an object, each field you leave out falls back to the merchant setting on its own: sending "tip": {"enabled": true} turns tipping on and keeps the merchant's tip percentages.
| Field | What it sets |
|---|---|
surface | hosted (default) or headless. |
page_origin | Headless only. The origin of the page that renders your checkout, such as https://shop.example.com. Only that origin can show the session's gift card challenge. |
customer_id | An existing customer to link to the order Flint creates. Not allowed with type: "order". |
buyer_fields | Which buyer details checkout requires, and whether it suggests addresses. |
prefill | Contact details and addresses to fill in for the buyer. |
redirects | Hosted only. Where the buyer goes after paying, after canceling, and after the session expires. |
payment_return_url | Headless only. Where Flint returns the buyer after a redirect payment such as Affirm. |
expires_in_seconds | How long the session stays open, from 60 to 86,400. |
payments | Which payment methods appear, plus a payment note. |
tip | Whether tips are offered, and the presets. |
promotion_config | Automatic promotions and promotion-code entry. |
tax | Automatic tax for the order Flint creates from quick_pay_item or subscription_plan_id. Not allowed with type: "order". |
delivery_method_ids | The delivery methods checkout offers for shipping, pickup, and local delivery, 1 to 25. Leave it out to use settings.checkout.default_delivery_method_ids. |
legal | Links to terms of service, refund and shipping policies, and a contract, and whether the buyer must accept the terms. |
custom_text | An order summary message and the shipping address label. |
theme | Overrides for title, primary_color, and accent_color. Other theme fields come from branding settings. |
external_reference_id | Your own ID for the session, which you can filter the list by. |
metadata | String key-value pairs for your own use, returned on every read. |
surface, page_origin, customer_id, prefill, redirects, payment_return_url, custom_text, external_reference_id, and metadata have no merchant default.
external_reference_id is your merchant-owned ID for this session and can be updated. client_reference comes only from a payment link's URL or resolve request and is immutable, nullable, and readable only by merchant credentials. It names the buyer or cart according to a buyer-controlled claim, not a verified identity. You cannot send it on session create or PATCH.
Read a session with GET /v1/checkout-sessions/{checkout_session_id} to get its storefront branding. merchant_name and show_flint_mark are always present; merchant_logo, merchant_icon, and payment_link_image appear when set. These fields are omitted from create and launch results, lists, and webhooks. The returned theme combines the session's three overrides with branding settings, including background_color, text_color, font_family, and corner_radius; it is omitted when none is set. See Brand your checkout.
Session responses also include tax when the session has tax settings: enabled as set at creation, and location_fixed_by_merchant when the order already had a tax location. Hosted checkout shows that fixed location without asking for another. This records session settings; use the order's tax for the current tax calculation.
Customer details#
customer_id sets which customer the checkout is for. buyer_fields sets what the checkout asks the buyer, and prefill fills in what you already know:
{
"type": "quick_pay",
"quick_pay_item": {
"name": "Design consultation",
"amount_money": {"amount": 9900, "currency": "USD"}
},
"customer_id": "cus_1kmn0aExample",
"buyer_fields": {
"require_email": true,
"require_phone": false,
"require_billing_address": false,
"address_autocomplete_enabled": true
},
"prefill": {
"shipping_recipient_name": "Alex Morgan",
"shipping_address": {"line1": "123 Market Street", "city": "San Francisco", "state": "CA", "postal_code": "94103", "country": "US"},
"email": "ada@example.com",
"phone": "+15555550100"
}
}
With
type: "order", the customer comes from the order, socustomer_idisn't allowed: sending it returns400 INVALID_REQUESTwith detailNOT_ALLOWEDandparam: customer_id. Set the order'scustomer_idbefore you create the session. While a session is open, setting the order's customer returns409 RESOURCE_IN_USE; close the session first.With
quick_payorsubscription_plan,customer_idlinks the new order to an existing customer. An unknown ID returns404 RESOURCE_NOT_FOUNDwithparam: customer_id.A session read returns
customer_idas the customer of the session's order, and leaves it out when the order has none. It's the valueexpand=customerand thecustomer_idlist filter use.buyer_fields.require_email,require_phone, andrequire_billing_addressmake a field mandatory before payment. A field you leave out uses the merchant's checkout settings. Subscription signups always require email, so asubscription_planrequest can sendbuyer_fields.require_email: trueor leave it out;falsereturns400 INVALID_REQUESTwith detailNOT_ALLOWEDandparam: buyer_fields.require_email. When Checkout collects a required billing name and address, merchant reads of the paid order include them incheckout_billing_contact.buyer_fields.address_autocomplete_enabledsuggests addresses as the buyer types.prefillfills inemail,phone,billing_address,shipping_address, andshipping_recipient_name, and the buyer can edit them. For a customer with saved addresses, Flint fills in any address you leave out, and reads include it.shipping_recipient_name: who receives the delivery. Send it withshipping_addressso the buyer has nothing to type. It is optional, accepted without an address, and trimmed. It must contain 1 to 200 characters. Empty or longer names return400 INVALID_REQUESTwith detailINVALID_VALUEandparam: prefill.shipping_recipient_name. Reads with your API key or the checkout credential return it. It never changes the customer record.
Tax is calculated from the order's tax location. With type: "order", creating the session doesn't change it. Set tax.location on the order before you create its first session, and hosted checkout shows it without letting the buyer change it. If you don't, hosted checkout asks the buyer, starting from the ZIP code in a prefilled address, and the buyer can change the location they give until they pay. A location already on an order that had an earlier session may be one a buyer gave, so hosted checkout lets the buyer change it. With quick_pay or subscription_plan and automatic tax on, an address you send in prefill sets the tax location: the shipping address when the order ships, otherwise the billing address, or the shipping address when you sent no billing address. Addresses Flint fills in from the customer don't set it, and a delivery destination on the order takes precedence.
Require only what fulfillment needs; each extra field is one more thing the buyer has to fill in before paying.
Buyer contact#
A checkout can save the email and phone the buyer types before they pay, so a reload can prefill them. Send them as buyer_contact with the session's checkout credential, for example when a field loses focus:
PATCH /v1/checkout-sessions/cs_1kmn0aExample
Authorization: Bearer ckat_1kmn0aExample
Content-Type: application/json
{
"buyer_contact": {
"email": "ada@example.com",
"phone": "+15555550100"
}
}
- Only the session's own checkout credential can set
buyer_contact, and only while the session isopen. With the checkout credential, this route also acceptstimezoneand, on a subscription plan session,subscription_terms. Any other field returns400 INVALID_REQUESTwith detail codeNOT_ALLOWEDandparamnaming the field. Your API key can readbuyer_contactbut not set it: sending it returns the same error. The update request in the API reference marks which credentials may not send each field. - An omitted field keeps its saved value, and
nullclears it.emailmust be a valid address andphonemust be in E.164 format. Flint stores both exactly as sent, so a value with surrounding spaces is rejected. - Saving the values the session already holds changes nothing.
- Reads return
buyer_contactwithemail,phone,is_email_cleared,is_phone_cleared, andupdated_at. A value the buyer hasn't entered, or cleared, isnull. The correspondingis_*_clearedflag istrueonly after an explicit clear, including when the buyer clears a merchant prefill before saving any contact. Saving a value resets its flag tofalse. The contact is omitted until the buyer saves or clears a field. - When a payment made with the checkout credential omits
buyer_contact.emailorbuyer_contact.phone, Flint uses the saved value. The order records the contact the payment used asbuyer_contact.emailandbuyer_contact.phone. - If the merchant turned on checkout reminder emails, saving an email on a hosted session schedules at most one reminder, sent if the buyer leaves without paying. Invoice, subscription signup, and return checkouts don't send reminders.
- Flint clears the saved contact 30 days after the session ends. Deleting the customer the session was created for, or the customer its order belongs to, clears it too.
Every session has a version that increases with each saved change to it, such as a contact save, a metadata update, a close, expiry, or payment completing. To keep a save from overwriting a change the buyer's page hasn't seen, such as a save from another tab, send the version the page loaded as expected_version:
PATCH /v1/checkout-sessions/cs_1kmn0aExample
Authorization: Bearer ckat_1kmn0aExample
Content-Type: application/json
{
"expected_version": 4,
"buyer_contact": { "email": "ada@example.com" }
}
The response is the session with version 5. Send that value with the page's next save, and keep the version you started from if a background refresh returns a newer one, so a change you haven't shown the buyer isn't overwritten. If the session changed first, the save returns 409 VERSION_CONFLICT with the current version in details[0].current_version and changes nothing. Keep what the buyer typed, read the session again, and save the contact again with the new version and a new Idempotency-Key. expected_version is optional on every PATCH and on close.
Buyer data on a session#
Three fields hold buyer details, and each comes from a different place. None of them changes another.
| Field | Who fills it | What it holds |
|---|---|---|
prefill | You on session create, or the buyer's payment-link URL or resolve request | The contact details and addresses you sent, plus addresses Flint filled in from the customer. |
customer_prefill | Flint, from the customer record | The contact and default addresses of the customer the checkout acts for. Only the session's checkout credential reads it, while the session is open. |
buyer_contact | The buyer, in checkout | The email and phone the buyer typed or cleared. |
buyer_contact never changes prefill. Payment-link prefill.email is editable and unverified, sets no customer_id or customer_prefill, and never links an existing customer. Receipts use the email the buyer submits.
When a clear flag is true, keep that field empty instead of restoring a prefill. Omit the corresponding buyer_contact.email or buyer_contact.phone when paying; Flint sends no saved value for a cleared field. If a delivery selection already carries that phone, create a new selection through POST /v1/delivery-selections with the same choices and a recipient containing the values to keep without phone. The new selection replaces the recipient. A delivery option that requires a phone reports it in input_requirements until the buyer supplies one.
Saved payment details#
Hosted checkout offers buyers an unchecked "Save my details for faster checkout at {business name}" option under the card fields. When the buyer checks it and the payment succeeds, Flint saves the card for the customer the checkout acts for, with usage: "on_session". That card pays only in later checkouts the buyer completes, never a subscription or an automatic invoice. A guest proves their email with a six-digit code before a card can be saved, or gives a US or Canadian mobile phone number to confirm by text after paying. A returning buyer gets a code when they type their email, and the code opens the cards they saved.
The option is on by default; turn it off with checkout.saved_payment_details. It saves only a card the buyer types, so it never appears for Apple Pay, Google Pay, ACH debit, or Affirm, for partial payments, on invoice, subscription, and return checkouts, or when customer accounts are merchant hosted. When Flint wallet support is on, checkout instead offers to save the card with Flint for faster checkout at other stores that use Flint, and the option to save it with your business doesn't appear.
Cards buyers save in checkout covers the codes, phone numbers, and what each card can pay. To offer the option in a headless checkout, see Offer to save the card.
Tips#
{
"tip": {
"enabled": true,
"tip_percent_options": [10, 15, 20],
"default_tip_percent": 15,
"custom_tip_enabled": true
}
}
tip_percent_options takes exactly three percentages, each from 1 to 100 with up to four decimal places: 15 means 15%. default_tip_percent must be one of the options the session offers, whether you send them or they come from the merchant's tipping settings; otherwise the request returns 400 INVALID_REQUEST on default_tip_percent. Fixed tip amounts must use the session's currency. Offer tips at hosted checkout covers fixed-amount presets for small orders and how the tip lands on the order.
Promotions and tax#
For API address pickers, read the order's tax.supported_countries and the tax connection's coverage. Outside the US, automatic tax covers digital goods, software, and SaaS in Canada, the EU, the UK, Australia, and New Zealand; physical goods, services, and taxable charges remain unsupported. See EU, UK, Australia, and New Zealand coverage.
promotion_config.automatic_enabled turns automatic promotions on or off for the session. promotion_config.codes_enabled controls whether the buyer can apply codes. It inherits from the payment link, then checkout.promotion_codes_enabled. When all are unset, promotion_config.codes_enabled stays null and hosted checkout offers code entry only when the merchant has an active code promotion in this environment whose schedule includes now. Read can_apply_promotion_code to decide whether to show a field in your own checkout. This required boolean is recomputed on every session response, including lists and webhook snapshots; it is false after the session ends or while it is in recovery. An explicit true offers entry even without a promotion, and false refuses code application. A null config still accepts a valid code, including one activated since the last read. If the merchant turned promotion codes off with promotions.codes_enabled: false, creating a session with codes_enabled: true returns 409 ACTION_NOT_ALLOWED with reason configuration_required. Codes apply to the order before payment.
tax.enabled turns on tax for the order Flint creates from quick_pay_item or subscription_plan_id. Leave it out to follow the merchant's tax.default_enabled setting. tax.calculation sets how that order calculates tax: {"mode": "automatic"}, or {"mode": "external", "components_source": "callback"} to ask your tax calculation callback whenever the buyer gives an address or changes delivery. External tax needs components_source: callback, because nobody can send components for an order Flint creates: without it the request returns 400 INVALID_REQUEST with detail code REQUIRED, and provided returns INVALID_VALUE. Leave tax.calculation out to follow tax.default_calculation in settings, where a provided default means automatic. With callback tax and no callback selected in tax.calculation_callback_id, creating the session returns 409 ACTION_NOT_ALLOWED with reason configuration_required and resource_type tax_calculation_callback. A subscription plan session's subscription copies the tax you send; see Tax on subscriptions. With type: "order", the order's own tax applies, and sending tax returns 400 INVALID_REQUEST with detail NOT_ALLOWED and param: tax; change tax on the order instead. A session has no tax setting of its own: read tax on its order. Hosted checkout asks the buyer for a tax location whenever the order's automatic tax needs one and the order doesn't ship; a delivery address or pickup store sets it otherwise. When the order's tax isn't calculated and no location from the buyer can calculate it, for example external tax with no calculation, hosted checkout takes no payment and tells the buyer to contact you. When the order uses automatic tax and the merchant has no active tax connection, creating the session returns 409 ACTION_NOT_ALLOWED with reason configuration_required. Sales tax covers how tax is calculated.
With external tax you provide, an order that can offer a paid delivery method needs tax.delivery_charge_calculation, including for methods inherited from settings. An order whose tax.components_source is callback doesn't: its tax calculation callback taxes each delivery charge. Without it, a method that can charge in the order currency returns 400 INVALID_REQUEST with detail code REQUIRED, with param: delivery_method_ids when it was set on the session or payment link, or param: settings.checkout.default_delivery_method_ids when it was inherited from the default. Set the template on the order, or remove the paid methods. See Tax delivery charges.
Platform fees#
A partner app token can price the payments a session creates, within the cap the merchant approved. Send platform_fee with an amount on an order or quick_pay session, or platform_fee_rule with a percent and an optional fixed part and maximum on an order, quick_pay, or subscription_plan session. A session takes one or the other, never both.
- A rule is fixed at create. Flint checks it once, prices each payment the session creates from it, and copies it onto each subscription the order starts. The session shows it as
platform_fee_rule, and it doesn't advanceversion. A rule isn't accepted on an invoice or return resolution session. - A replacement inherits it. A session created with
replace_checkout_session_idtakes the rule of the session it replaces, and the app that created it. Sendingplatform_fee_ruleon a replacement returns400 INVALID_REQUESTwithNOT_ALLOWED, and so does sendingplatform_feewhen the session it replaces has a rule. A replacement doesn't copy aplatform_feeamount. - Buyers never see it. The checkout credential's session leaves out
platform_feeandplatform_fee_rule.checkout_session.createdcarries the rule, including one inherited by a replacement.
Platform fees has the checks, the errors, and how each payment is priced.
Session rules#
One open session per order#
An order has at most one open session. Creating another for the same order returns 409 ALREADY_EXISTS with param: order_id, and the open session in details[0].current_resource. The existing session and its URL keep working. Retained error responses also use current_resource and guidance to reuse or explicitly replace that session. If two requests create a session for the same order at the same moment, one can return 409 VERSION_CONFLICT. Read the order and its current session, then rebuild the request with a new Idempotency-Key.
To replace the session on purpose, for example to send the buyer a fresh URL, pass its ID as replace_checkout_session_id:
{
"type": "order",
"order_id": "ord_1kmn0aExample",
"replace_checkout_session_id": "cs_1kmn0aCurrent"
}
Flint checks the order's current session:
- If the named session is still the order's open session, Flint replaces it in one step.
- If another session is now the order's open session, Flint returns
409 VERSION_CONFLICTwithparam: replace_checkout_session_idand that session indetails[0].current_resource. - If the named session is
closedorexpiredand the order has no open session, there is nothing to replace. Flint creates the new session normally. A buyer restarting after expiry can send the old ID or omitreplace_checkout_session_id. The named session must still belong to the same merchant, environment, and order. If the order is no longer payable, create a new order. - If the buyer is in the middle of paying, Flint returns
409 OPERATION_IN_PROGRESS. Retry once the payment finishes. - If the response is lost, retry with the same
Idempotency-Keyto get the same new session.
When Flint replaces an open session, the old session becomes invalidated with terminal_reason: "superseded", and its superseding_checkout_session_id points to the new one, on reads and on the checkout_session.invalidated event. Replacement works only with type: "order". An invoice's session is managed through POST /v1/checkout-sessions with type: invoice.
A session's inventory_reservation_ids binding becomes inert when it ends, including invalidated with terminal_reason: superseded or order_mutated. Replacements never inherit the binding. This also applies when a buyer restarts after expiry, with or without the old session ID, and when hosted checkout recovers a session. To authorize the new session to use the cart's holds, your merchant server must send the IDs again when creating it. Otherwise, delivery selection uses the order's existing hold or acquires available stock. Unused cart holds keep their own release and expiration lifecycle.
Changing the order during checkout#
You can change the order with your API key while its session is open: line items, discounts, charges, tax, and the tip. The session stays open with the same ID, URL, and checkout credential. It keeps the buyer's saved contact and time zone, and a buyer who confirmed their email with a code keeps the credential that confirmation returned. Flint re-prices the order in place and sends order.updated, not checkout_session.invalidated. Changes the buyer makes through the session's checkout credential, such as adding a tip or applying a code, work the same way.
The buyer approves the new total before paying. A payment with the checkout credential must send expected_outstanding_money, and if it no longer matches the order, Flint returns 409 VERSION_CONFLICT without charging. Flint's hosted page then tells the buyer the checkout changed and shows the updated total. In a headless checkout, re-read the order and show the buyer the new total. Send the order's version as expected_version with the payment as well, to also catch an edit that leaves the total unchanged; see Start the payment.
An edit that leaves the line items, their quantities and prices, the discounts, and the customer unchanged, such as a charge, a tip, or tax, keeps the buyer's delivery selection while it is still usable, and the tax on the delivery charge follows the order. Any other edit, including a new inventory_routing_source, releases the selection in the same request. The order the edit returns has no delivery charge and governing_delivery_selection_id: null, its totals and tax no longer include delivery, and any stock the selection held is released. The session stays open and reads delivery_selection_required: true. Edits to an open, unpaid order also release an expired or otherwise unusable provisional selection, including tip, metadata, and note changes. A revoked backing quote makes the selection unusable. Closing the order releases its provisional selection too. Quotes from before a change to the delivery basis return DELIVERY_REQUOTE_REQUIRED with reason quote_stale, and paying returns ACTION_NOT_ALLOWED with reason configuration_required until the buyer selects from a new quote.
Some changes still end the session or are refused:
- Closing the order, or an edit that leaves nothing to pay, such as a discount that covers the rest of a partly paid order, ends the session as
invalidatedwithterminal_reason: "order_mutated". - Sessions for an invoice, a return, or a subscription plan aren't kept open: an edit to their order can end them with
order_mutated. - A session already past
expires_atbecomesexpired, and then the edit applies. - Changing
customer_idreturns409 RESOURCE_IN_USE. Close the session first. - After part of the order is paid, a new quantity on a tracked line, a new or removed tracked line, or a new
inventory_routing_sourcereturns409 RESOURCE_IN_USE.details[0].blocking_resourcesnames the reservation that keeps the stock for the rest of the order. Only a delivery selection's own stock hold is released by an edit.
To send the buyer a new URL anyway, replace the session or close it.
While the buyer is paying, Flint rejects these changes and leaves both the order and the session as they were. You get 409 OPERATION_IN_PROGRESS, and details[0].blocking_resources names the blocking resource when Flint knows it: the checkout session, invoice, payment attempt, or payment intent that holds the order. Retry after the payment finishes.
While a hosted session is open, the order keeps at most one unpaid payment leg (PaymentIntent). Creating another with POST /v1/payment-intents returns 409 RESOURCE_IN_USE, with unpaid legs as payment_intent references in details[0].blocking_resources and the session in details[0].current_resource. Cancel that leg first, or close the session and collect a split payment in your own UI.
Paying the order with your API key#
You can pay the order with your API key while its session is open, for example when the buyer calls to finish the order by phone. The payment uses the buyer's current delivery selection, so the delivery charge on the order is the one charged; an order that needs a selection and has none returns ACTION_NOT_ALLOWED with reason configuration_required. On the session, delivery_selection_required says whether the order needs a delivery selection before payment, and delivery.delivery_selection_id is the current selection's ID, or null when there is none. Send expected_outstanding_money, the order's outstanding_money you read, so Flint refuses to charge a total the buyer didn't approve. It's required while the session is open: without it the payment returns 400 INVALID_REQUEST with detail code REQUIRED and param expected_outstanding_money, and when the order's balance has changed, 409 VERSION_CONFLICT with the current balance in details[0].current_money. Neither starts a payment. Send the buyer's IP address as buyer_ip_address when you have it, so IP address risk rules and block lists apply to the payment.
Only one payment for the order runs at a time. While the buyer is paying, your request returns 409 PAYMENT_ATTEMPT_ACTIVE with the buyer's attempt in details. While yours runs, a payment or an order change with the checkout credential returns 409 OPERATION_IN_PROGRESS, and reading the session returns payment_in_progress in problems[], without naming your payment or its amount. Flint's hosted page tells the buyer a payment for the order is already being processed. With a manual capture, that lasts until you capture or cancel. When it ends:
- A payment that clears the balance ends the session as
invalidatedwithterminal_reason: "order_paid_elsewhere"and sendscheckout_session.invalidated. The hosted page tells the buyer the order was paid another way. - A deposit or other payment that leaves a balance ends the session as
partially_paidwithterminal_reason: "payment_partially_succeeded"and sendscheckout_session.partially_paid. The hosted page shows the partial payment. Create a new session to collect the rest. - A declined payment leaves the session
open, and the buyer keeps their delivery selection.
The checkout credential can still read the session after it ends.
Expiration#
A session expires 24 hours after creation unless the merchant set a different default. Shorten it when the price or stock won't hold that long:
{
"type": "order",
"order_id": "ord_1kmn0aExample",
"expires_in_seconds": 1800,
"redirects": {
"expired_url": "https://example.com/quote-expired"
}
}
expires_in_seconds takes 60 to 86,400. Omit it to use the merchant's settings.checkout.default_expires_in_seconds. redirects.expired_url sends a buyer who opens the expired session to your page, and only hosted checkout uses it. Every read returns the deadline as expires_at and the lifetime the session got as expires_in_seconds.
An invoice's session has no expires_in_seconds. It takes its deadline from the invoice's public link instead, so the buyer's link keeps working for the invoice's whole collection window.
When an unpaid payment link or shop session expires, Flint also closes its order with closed_reason: "checkout_expired" and emits order.closed, provided nothing was paid or authorized, no invoice or other active collection owns the order, and the order is not linked to a return. Pending discounts and inventory reservations are released, and the unpaid delivery destination is cleared. Orders behind existing-order, quick pay, subscription-plan, and invoice sessions stay open after session expiry. Resolve the payment link or shop again to start a new checkout and order.
Close a session#
Close a session when it should no longer take payment: the quote was withdrawn, the buyer abandoned it, or you need to set the order's customer. The request body is optional.
curl -X POST https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/close \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"reason_message": "Quote withdrawn"}'
To close the session only if it hasn't changed since you read it, add "expected_version" with the session's version to the body; a stale value returns 409 VERSION_CONFLICT and leaves the session as it is. The session becomes closed, and reason_message is stored as closed_reason_message for your records. The buyer never sees it. Closing while the buyer is paying returns 409 OPERATION_IN_PROGRESS, and closing a session that has already ended returns 409 ACTION_NOT_ALLOWED with reason unsupported_state and the session's status in details[0].current_status. A session that is past expires_at has already ended: closing it marks it expired and returns that 409 with current_status: expired in details[0].
After a session ends#
The checkout credential keeps limited access after the session leaves open, so the buyer's page can show the result:
| Session status | What the checkout credential can do |
|---|---|
paid, partially_paid, invalidated | Read the session, its order and PaymentIntents, its payment attempts (as a list or one at a time), and the delivery selection. A paid or partially_paid session can also send the receipt. After a paid session, the buyer can also confirm a card they saved with a mobile phone number, or replay a completed orders.pay request with the original checkout credential, Idempotency-Key, and body. Reusing the key with a different request returns 409 IDEMPOTENCY_KEY_REUSED. A new payment or a resume of a different attempt on a paid order returns 409 ACTION_NOT_ALLOWED with reason payment_collected. A resume of the attempt that paid the order can recover its outcome with a new key. Other writes return reason terminal_status. |
closed, expired | Read the session, including terminal_reason and merchant_support. Anything else returns 409 ACTION_NOT_ALLOWED with reason terminal_status with details[0].current_status set to closed or expired. |
An ended session's read leaves out payment_collection and setup_collection, and the credential acts for no customer. A credential past its own lifetime returns 401 INVALID_CREDENTIAL with details[0].reason expired, whatever the session's status. Support and back-office tools should use your API key, which works for every session regardless of status.
Finish a payment after expiry#
A session can reach expires_at while the buyer is in the middle of a payment, for example on a 3D Secure screen. Rather than strand that payment, the session stays usable for it alone. The session read shows is_in_recovery: true, the attempt in recovery_payment_attempt_id, and the deadline in recovery_expires_at, which is at most an hour after the attempt itself expires.
In recovery, the checkout credential can call only:
Any other call returns 403 FORBIDDEN with details[0].reason checkout_recovery_restricted, and reading a different attempt returns 403 FORBIDDEN with details[0].reason checkout_recovery_attempt_mismatch. If the attempt succeeds, the session becomes paid, or partially_paid if it collected only part of the balance. If it fails, the session expires. For an existing-order or quick pay checkout, create a new session to collect any balance left. For a payment-link checkout, resolve the link again; its unpaid order closes when the conditions above are met.
Continue an embedded payment#
After completing a payment intent's 3D Secure client action, send POST /v1/payment-intents/{payment_intent_id}/confirm with the same checkout credential and no payment_source. Use the ID in the action's subject.payment_intent.payment_intent_id. This continues the holding order payment attempt and returns the payment intent with current_payment_action. Read the order to check the whole collection's outcome.
The checkout credential can also start confirmation of a single leg that covers its order's balance. Another session's intent or a standalone intent returns 404 RESOURCE_NOT_FOUND. Invoice checkout legs run the invoice's collection steps. supported_actions is the merchant list filtered to confirm and cancel on the session's own intents; it never includes capture. Save cards through order pay: sending save_payment_method to confirm with a checkout credential returns 400 INVALID_REQUEST with detail code NOT_ALLOWED.
Retrieve and list sessions#
Read one session with GET /v1/checkout-sessions/{checkout_session_id}. Add expand to include related records in the same response: customer, invoice, order, payment_intents, or payment_link, comma-separated. Each expansion needs your key to have read access to that resource; otherwise the request returns 403 INSUFFICIENT_SCOPE.
List sessions for reconciliation and support tools:
curl "https://api.withflintpay.com/v1/checkout-sessions?status=open&order_id=ord_1kmn0aExample" \
-H "Authorization: Bearer YOUR_API_KEY"
status, type, and surface take several values, as repeated keys or a comma-separated list: ?type=quick_pay,payment_link lists sessions of either type.
The list filters by status, type, surface, order_id, customer_id (the order's customer), payment_link_id, subscription_plan_id, invoice_id, and external_reference_id, and by time with created_after, created_before, updated_after, updated_before, expires_after, and expires_before. query searches session IDs, external_reference_id, metadata, and payment notes. Results use cursor pagination and can be ordered with sort_by and sort_direction. The status filter matches the status each session has when you read it: a session past expires_at lists as expired even if Flint hasn't marked it yet, and one whose payment is still settling stays open until it settles. A page can hold fewer sessions than page_size, so keep paging until next_page_token is empty. Each _after bound is inclusive and each _before bound is exclusive.
To find the sessions behind an invoice or a subscription plan, filter by its ID. subscription_plan_id and invoice_id each take one complete Flint ID and match the session's field of the same name. surface is hosted or headless, and sessions created before surfaces existed count as hosted. This lists the headless sessions started for one plan:
curl "https://api.withflintpay.com/v1/checkout-sessions?subscription_plan_id=plan_01J00000000000000000000000&surface=headless" \
-H "Authorization: Bearer YOUR_API_KEY"
An empty or repeated ID, an ID with the wrong prefix, or an unknown surface value returns 400 INVALID_REQUEST with detail code INVALID_VALUE. A valid ID with no sessions returns an empty page.
With your API key, PATCH /v1/checkout-sessions/{checkout_session_id} updates metadata and external_reference_id in any status. New metadata keys merge into the existing ones, a key set to null is removed, and "metadata": null clears them all. Add expected_version to apply the change only to the session version you read.
Errors#
Errors lists every code with its remediation.
Next steps#
- Testing: create an order and a session, and pay with a test card.
- Build your own checkout: run a headless session from your own storefront.
- Webhooks: receive and verify the events that drive fulfillment.
- Checkout sessions API reference: every field on every endpoint.