Build your own checkout
Your storefront renders every checkout screen: cart, delivery, payment, and receipt. Stripe Elements collects card details on Stripe's domain. Flint computes what the buyer owes, runs the payment, and tells you when to fulfill. This guide builds an order checkout end to end, then covers saved cards, gift cards, Affirm and ACH debit, invoice and return balances, and subscription signups.
Hosted checkout already quotes delivery, collects the tax location, applies codes and gift cards, and takes every payment method, with one call from your backend; Checkout sessions covers it. Hosted or headless lists what each surface owns. For the payment step alone, without delivery or saved cards, Embedded payments with Stripe Elements is shorter.
Warning: Your backend calls Flint for headless checkout
Flint has no publishable key. The only calls a merchant page can make directly from the browser are the keyless GET /v1/payment-links/{payment_link_id}/public and POST /v1/payment-links/{payment_link_id}/resolve calls to start a payment-link checkout. Resolve returns a hosted session, so to run the checkout on your own page, replace it with a headless session from your backend: Sell event tickets on your own page shows the calls. The browser talks to Stripe.js and to your backend, and your backend calls Flint. The one Flint page your checkout loads is the gift card challenge, in an iframe, and only after repeated failed gift card codes.
How the pieces fit#
- Browser sends cart contents to Your backend
- Your backend sends POST /v1/orders, then POST /v1/checkout-sessions to Flint
- Flint returns session and checkout_auth_token to Your backend
- Browser sends shipping address to Your backend
- Your backend sends quote and select delivery to Flint
- Flint returns updated order total to Your backend
- Browser sends stripe.createConfirmationToken to Stripe.js
- Stripe.js returns ctoken_... to Browser
- Browser sends pay to Your backend
- Your backend sends POST /v1/orders/{order_id}/pay to Flint
- Flint returns order_payment_attempt to Your backend
- Flint sends order.paid webhook to Your backend
| Concern | Owner |
|---|---|
| Page, layout, fields, navigation, receipt UI | You |
| Buyer authentication, browser session, CSRF, CSP, origin checks | You |
| Card and wallet data collection | Stripe Elements, on Stripe's domain |
| Order total, tax, discounts, outstanding balance | Flint |
| Payment confirmation, authentication state, attempt state machine | Flint |
| Settlement and the fulfillment signal | Flint |
Card details never pass through your servers or Flint's.
Before you start#
- Check that the merchant can take payments:
readiness.payments.statusonGET /v1/merchantisready. Otherwise tell the buyer checkout is unavailable instead of rendering an empty payment form. A payment for a merchant that isn't ready fails withMERCHANT_NOT_READY, anddetails[0].reasonsays why, such asrequirements_due,capability_pending, ormerchant_payments_disabled. None of these clears by resending the same request:remediation.retryisnone. - Serve checkout over HTTPS, and register every checkout hostname with
POST /v1/payment-method-domainsbefore you expect Apple Pay or Google Pay. Registration is a wallet requirement and gives your origin no access to Flint. See Apple Pay and Google Pay setup. - Register a webhook endpoint, verify signatures against the raw body, and deduplicate on
webhook-id. - Give your backend a key with only the scopes it needs. These are the calls your API key makes, with the scope each requires. Provision wallet domains with a separate administrative key.
Buyer-side calls, such as quoting delivery, applying a gift card code, and paying, go out with the session's checkout credential instead, as step 5 describes.
1. Build the cart on your backend#
The browser sends product IDs, variants, and quantities. Your backend looks them up in your catalog and creates the order with POST /v1/orders, as in Create an order.
Never take a unit price, tax amount, delivery charge, discount, or total from the browser. Flint computes what the buyer owes, and your page renders it.
2. Apply price-changing choices first#
Promotion codes, tips, tax location, modifiers, gift cards, and delivery all change the total. After each change, render the amounts from the order Flint returns, never a total you calculated.
- Promotion codes. Show a field when the session's
can_apply_promotion_codeistrue. When the session, payment link, andcheckout.promotion_codes_enabledleave code entry unset, Flint offers it only while an active code promotion exists in this environment. An explicittrueoffers entry even without one. The hint is recomputed on each read. It does not change code admission: checkout lifecycle, recovery,promotion_config, and merchant policy still apply. With an inherited config, a valid code can apply even if it became active after the last read. - Order of steps. Settle the cart and promotion codes before the buyer chooses delivery. Applying or removing a promotion code requotes the selected delivery and keeps it when it is still valid. If the response includes
delivery_requote_requiredinmeta.warnings, quote and select delivery again. Cart changes can also release the selection.
3. Associate the customer before collection#
How the order gets its customer depends on whether the buyer signed in:
- Signed-in buyer. Set
customer_idon the order before you create the session. The checkout then acts for that customer, so it can list the cards they saved. Settingcustomer_idwhile a session is open returns409 RESOURCE_IN_USE. When a paid checkout session's order has a customer with no email, Flint sets the customer's email to thebuyer_emailthe checkout collected once the payment settles, before it sends the buyer's notices or provisions a subscription. It never replaces an email the customer already has, and it fills no other customer field. When another customer in the environment has that address, the customer stays without an email, and the order keeps the buyer's contact. Carry a signed-in buyer into checkout shows the calls. - Guest. Send
buyer_contact.emailonPOST /v1/orders/{order_id}/pay, or save it on the session first. A typed email never joins the order to an existing customer. When no customer has the email, Flint creates a minimal customer and links the order to it once the payment settles the order, and sendscustomer.created. When a customer already has the email, the order stays unlinked withbuyer_emailkept, and it doesn't appear in that customer's/v1/meor hosted account. If two checkouts race to create the customer, the one that loses stays unlinked. The account holder can claim the order later withlink-guest-purchases. - Guest who confirms a code. When the buyer confirms their email with a code, the checkout acts for that email's customer, and Flint links the order to that customer.
4. Decide whether you need a checkout session#
You can pay an order without a session: read its payment_collection, collect a credential with Stripe Elements, and call POST /v1/orders/{order_id}/pay with your API key. That covers cards, Apple Pay, and Google Pay. To send part of an order payment to a seller, set up Elements for splits and pay without a checkout session.
Create a headless session when your checkout needs any of these:
| Need | Why it takes a session |
|---|---|
| A buyer-scoped credential | The checkout credential reaches only this checkout, so your relay can't be used to act on other orders. |
| Flint delivery | Quotes and selections belong to a session. Your API key can also quote, select, and pay while the session is open. |
| Saved cards | Recognizing a returning buyer and saving a card both run on the session. See Saved cards in checkout. |
| Gift card codes the buyer types | Codes are counted and challenged per session. See Apply gift cards. |
| Affirm | The session's payment_return_url brings the buyer back. See Affirm and ACH debit. |
| An expiration | The session ends at expires_at. |
Create the session from your backend:
<!-- docs-test {"scenario":"main","status":201,"fixtures":{"order":6400},"expect":{"data.status":"open","data.surface":"headless"}} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: create-headless-checkout-cart-123" \
-H "Content-Type: application/json" \
-d '{
"type": "order",
"surface": "headless",
"page_origin": "https://shop.example.com",
"payment_return_url": "https://shop.example.com/checkout/cart_123/return",
"order_id": "ord_1kmn0aExample",
"payments": {
"enabled_payment_options": ["card", "apple_pay", "google_pay"]
},
"promotion_config": {"codes_enabled": true},
"buyer_fields": {
"require_email": true
},
"expires_in_seconds": 1800
}'
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.
payment_return_url is where Flint sends the buyer after 3D Secure or another redirect step. It is optional unless the session offers Affirm, and the session keeps it for every payment made with the checkout credential. The response is the checkout session with checkout_auth_token among its fields. It has no url, because there is no Flint-hosted page to send the buyer to. expires_in_seconds takes 60 to 86,400; Expiration covers the default.
POST /v1/checkout-sessions with type: order, quick_pay, or subscription_plan is for what you sell. A return or exchange balance uses type: return_resolution, and an invoice has its own launch route, both described in Collect an invoice or a return balance.
Set the page origin#
page_origin is the origin of the page that renders your checkout, such as https://shop.example.com. It's optional, but without it the session can't show a gift card challenge: only that origin can frame the challenge and receive its result. It grants no API access, and the browser still never calls Flint.
- Send the origin exactly as a browser serializes it: scheme,
://, host, and a port only when it isn't the default. No path (not even a trailing/), query, fragment, or credentials. Flint rejects other forms instead of correcting them, so an uppercase host or:443fails. The limit is 255 characters. - In live mode, use
httpsand a lowercase DNS name. IP addresses,localhost, and names ending in.localhostorwithflintpay.comare refused. - In test mode,
localhost, names ending in.localhost, and127.0.0.1also work, overhttporhttps. - It's accepted only when
surfaceisheadless. - You set it when you create the session, and reads return it. Neither the checkout credential nor
PATCH /v1/checkout-sessions/{checkout_session_id}can change it. Invoice and return launches can.
One open session per order#
An order has at most one open session. After a lost create response, retry with the same Idempotency-Key. Creating a second session for the order returns 409 ALREADY_EXISTS with param: order_id and the open session in details[0].current_resource: keep using that one. It stays open when you change the order. To replace it on purpose, send its ID as replace_checkout_session_id. One open session per order covers replacement in full.
5. Store the credential, relay the calls#
Buyer-side requests authenticate with the checkout credential, the checkout_auth_token from the create response, sent as a bearer token:
Authorization: Bearer ckat_1kmn0aExample
- The token names its session, so you send no session ID with it. Used on another session's
/v1/checkout-sessions/{checkout_session_id}path, it returns404 RESOURCE_NOT_FOUND. - Keep it on your backend, tied to your own signed browser session. The browser calls your endpoints, such as
/checkout/{cart_id}/quote-deliveryand/checkout/{cart_id}/pay, and your backend takes Flint IDs from its own checkout record, never from the browser. - Each request carries one credential in
Authorization: Bearer: the checkout credential, which starts withckat_, or your API key. Choose it in one place in your relay, not in each handler. - Rate limit your own bootstrap, pricing, delivery, and payment routes, and add CSRF protection and origin checks to cookie-authenticated endpoints. Flint applies its own limits, but your backend mustn't become an open relay.
- Give each buyer their own checkout session and reuse it across payment retries. Card payments made with a headless checkout credential use the session's failed-attempt budget, along with the card fingerprint and billing email budgets. Buyers on different sessions can pay independently through the same relay. See card testing.
- Keep keys, checkout credentials, client secrets, and ConfirmationTokens out of logs, analytics, URLs, error messages, and persistent browser storage.
What the checkout credential can do lists the calls it allows. Securing a headless checkout covers the full boundary, including what changes for PCI once your payment page runs your own JavaScript.
Save the buyer's contact as they type#
Relay the email and phone the buyer enters to the session as buyer_contact, with the checkout credential. Save a field once it's valid, for example when it loses focus, so a reload can prefill it:
PATCH /v1/checkout-sessions/cs_1kmn0aExample
Authorization: Bearer ckat_1kmn0aExample
Content-Type: application/json
{"buyer_contact": {"email": "buyer@example.com"}, "expected_version": 4}
- An omitted field keeps its saved value, and
nullclears one. The phone must be in E.164 format. A failed save should never block the buyer. expected_versionis optional. Send the session'sversionfrom the read your page started from, then theversioneach successful save returns. A stale value returns409 VERSION_CONFLICTand saves nothing: keep the buyer's input, read the session again, and save with the newversion. Don't take the version from a background refresh, which could hide a change the buyer hasn't seen.- When the pay request omits
buyer_contact.emailorbuyer_contact.phone, Flint uses the saved value. - A headless session never sends a checkout reminder email, because those link to hosted checkout.
Buyer contact covers clearing, the is_*_cleared flags, and how long Flint keeps the contact.
Send the buyer's time zone#
So that receipts Flint sends show the buyer's local time, read the time zone in the browser with Intl.DateTimeFormat().resolvedOptions().timeZone and relay it to the open session with the checkout credential:
PATCH /v1/checkout-sessions/cs_1kmn0aExample
Authorization: Bearer ckat_1kmn0aExample
Content-Type: application/json
{"timezone": "America/Chicago"}
timezone must be an IANA time zone name, or the request returns 400 INVALID_REQUEST on timezone. Only the checkout credential can set it: with your API key, the request returns 400 INVALID_REQUEST with detail code NOT_ALLOWED. null isn't accepted; leave the field out to keep the value you sent before.
6. Collect delivery#
For a headless order checkout with one available delivery option, pay quotes and selects it automatically when the saved order destination or checkout prefill supplies every required address and recipient field. The returned order reports the choice in governing_delivery_selection_id and delivery. The usual stock, tax, and payment checks still apply.
Automatic selection keeps your expected_outstanding_money check. If delivery changes the total, payment returns 409 VERSION_CONFLICT without charging. Read the order, show the updated total, then pay with its current version, the reviewed outstanding amount, and a new idempotency key.
When there are multiple options, a required window or instructions, missing buyer details, or a delivery method that needs an explicit quote, quote the buyer's address and select an option yourself. Both calls use the checkout credential and need no read first. An existing selection always stays in place.
The selection writes the order's delivery_destination, and while a selection is active you can't set the destination directly. A payment request doesn't save a shipping address. When the session's delivery_selection_required is true and automatic selection can't apply an option, paying returns 409 ACTION_NOT_ALLOWED with reason configuration_required until you select delivery. A return's replacement order is the exception, as Collect an invoice or a return balance describes.
If your cart holds stock with an inventory reservation, bind the hold when your merchant server creates the order's checkout session:
{
"type": "order",
"order_id": "ord_1kmn0aExample",
"inventory_reservation_ids": ["invr_1kmn0aExample"]
}
The binding accepts at most 100 unique IDs. Exceeding the cap returns 400 INVALID_REQUEST with param: inventory_reservation_ids. The binding is immutable and applies only to type: order with an existing order. The reservations must be active, unexpired, and merchant-created in the same merchant and environment. Unknown or ineligible IDs return 404 RESOURCE_NOT_FOUND.
The buyer's quote and selection use the session's eligible holds automatically. The buyer never sends reservation IDs and cannot read the binding. Sending inventory_reservation_ids on either delivery request, even as an empty array, returns 400 INVALID_REQUEST before lookup. Merchant delivery requests that omit the field also use the binding. With a merchant credential and delivery write access, your server can send explicit IDs on either request to replace the binding for that request, including an empty array to use no cart holds. The two sets are never merged.
Quoting credits matching held stock without changing it. Selection transfers matching units into the order's hold atomically, leaves unused cart units held, and acquires any remainder from available stock. Payment commits the order's hold. Expired, released, or fully adopted cart holds no longer provide credit; checkout uses current stock or the order's existing hold. A quote's credit cannot authorize adoption from an unbound hold. If stock changes before selection, the existing stock checks can return 409 INVENTORY_INSUFFICIENT.
First adopter wins when two sessions bind the same hold. The other session silently skips the adopted hold and acquires normally, or returns the existing stock conflict if stock is short. Order changes keep an open session's binding, but invalidate stale quotes; a fresh quote rechecks the current cart. Ending the session, including invalidation with superseded or order_mutated, prevents further adoption and does not release unused cart units; their own release and expiration rules apply. Replacement sessions never inherit the binding, including expiry restarts and hosted recovery. Your merchant server must send the IDs again to bind them to the new session. Without a binding or merchant-server adoption, release the cart hold before buyer quoting. Orders without delivery also require release before payment.
If another cart takes the remaining stock, quote and pay return one shortage detail per short demand. Use order_line_item_id and, when present, bundle_component_id to identify what sold out, and available_quantity to offer a smaller quantity. Treat demand_key as opaque. Buyer credentials receive the quantities and line identities without inventory_item_id; quote and pay omit param. Shortage details lists the facts.
Quote the buyer's address#
expected_delivery_selection_id is optional. Send null to assert that no selection exists yet, or the session's delivery.delivery_selection_id once one does, so a second tab of the same checkout can't replace a newer choice. Leave it out to quote against whichever selection is current.
POST /v1/delivery-quotes
Authorization: Bearer ckat_1kmn0aExample
Idempotency-Key: quote-cart-123-address-1
Content-Type: application/json
{
"checkout_session_id": "cs_1kmn0aExample",
"expected_delivery_selection_id": null,
"destination_address": {
"line1": "120 Kent Avenue",
"city": "Brooklyn",
"state": "NY",
"postal_code": "11249",
"country": "US"
}
}
{
"data": {
"delivery_quote_id": "dqt_1kmn0aExample",
"status": "active",
"evaluation_status": "complete",
"selection_required": true,
"choice_groups": [{
"delivery_choice_group_id": "dcgrp_1kmn0aExample",
"availability_status": "ready",
"method_types": ["shipment"],
"input_requirements": [],
"options": [{
"delivery_option_id": "dopt_1kmn0aExample",
"delivery_method_id": "dmet_1kmn0aExample",
"type": "shipment",
"name": "Standard shipping",
"amount_money": {"amount": 900, "currency": "USD"},
"recommended": true,
"taxable": true
}]
}],
"input_requirements": [],
"buyer_reasons": [],
"evaluated_at": "2026-08-03T15:30:00Z",
"expires_at": "2026-08-03T16:00:00Z",
"created_at": "2026-08-03T15:30:00Z"
},
"request_id": "req_1kmn0aExample"
}
Render one picker per choice group. Its availability_status says what the buyer can do:
availability_status | Meaning | What to show |
|---|---|---|
ready | The group has options to choose from. | The options in options. |
needs_input | The buyer must first supply what the group's input_requirements list, such as an address field. | Ask for that input, then quote again. |
unavailable | No option can serve the group at this address. | Say the items can't be delivered there. |
method_types lists how the group can be delivered (shipment, pickup, or local_delivery) in the order the merchant displays the methods. It's present before any option is priced, so a checkout that offers only local delivery can say "Delivery" while it asks for the address. A type stays listed while its methods need more input or can't serve the current address; options is what the buyer can choose now.
Quotes and selections each have an expires_at. An explicit selection holds stock for up to two minutes. If the hold expires while the selection is still valid, payment tries to reserve the stock again and returns 409 INVENTORY_INSUFFICIENT if it has sold out. If a selection response is lost, retry with the same Idempotency-Key and unchanged body to recover a committed selection.
When the selection or its quote is out of date, problems[] on the session reports delivery_selection_stale until Flint clears the selection. It then reports delivery_selection_invalid if delivery is still required. Create a new quote and select an option to continue.
If Flint can't read the session's delivery, reading the session still succeeds: delivery is omitted, and problems[] reports delivery_unreadable, with the error's code in remediation.next_actions[0].reason_code. When remediation.retry is same_request, read the session again after a short delay. Otherwise, create a new quote.
Show a total before the address#
When the address form opens on a country the buyer can see, send that country to POST /v1/delivery-quotes, for example "destination_address": {"country": "US"}. If no country is selected, omit the destination. A method that needs no further input to price already offers an option.
Select one offered option per group with POST /v1/delivery-selections, omitting destination_address to keep the quote's partial address. Render the returned order's amounts: they include the selected delivery charge. Automatic tax that still needs the address stays pending. The selection's input_requirements names each missing address member with purpose selection, and paying returns 409 ACTION_NOT_ALLOWED with reason configuration_required until they are supplied.
To complete the address in the same country, select the same options from the same quote with the complete destination_address and the current selection as expected_delivery_selection_id. A changed country returns 409 DELIVERY_REQUOTE_REQUIRED with reason destination_changed. Create a new quote; if no method serves it, show the existing outside_delivery_area state and render the order after its old selection and charge are released.
Pickup still needs a store before selection. Your server can read a waiting pickup candidate's expected_amount_money to display "Pickup: Free" when every pickup method that could serve the group charges zero. This field does not add money to the order, and an omitted field does not mean free.
Select the option#
Use the IDs from the quote. Don't reconstruct them from method data.
The chosen option decides which recipient details are required, and it lists them in recipient_requirements: a shipment normally needs a recipient name and may need an email or phone for carrier notifications, and local delivery often needs a phone. Read them instead of assuming.
You can select before you have every required field. Apple Pay and Google Pay reveal the buyer's street, name, and phone only after the buyer approves the payment sheet, so a wallet flow quotes and selects from the partial address first. A sheet can ask for a phone only when it opens, so decide from the quote you have then: its input_requirements names recipient.phone, with purpose selection, for each option or waiting method that requires one, even before the buyer gives an address.
A shipment or local delivery selected from a partial address lists each missing address member, such as destination_address.line1, in the selection's input_requirements, and payment is refused with 409 ACTION_NOT_ALLOWED reason configuration_required until a selection sends the complete address. When the buyer approves the sheet, select again from the same quote with the full destination_address and recipient the sheet returned, and assert the selection you're replacing. Flint stores that address, and the order's delivery_destination reads it back. A street that changes the price, such as one outside a local delivery radius, needs a new quote instead: quote the full address, then select from that quote.
POST /v1/delivery-selections
Authorization: Bearer ckat_1kmn0aExample
Idempotency-Key: select-cart-123-shipping-1
Content-Type: application/json
{
"delivery_quote_id": "dqt_1kmn0aExample",
"expected_delivery_selection_id": null,
"recipient": {"name": "Morgan Lee", "email": "morgan@example.com", "phone": "+12125550123"},
"choices": [{
"delivery_choice_group_id": "dcgrp_1kmn0aExample",
"delivery_option_id": "dopt_1kmn0aExample"
}]
}
The response carries the selection, the session, and the order, repriced with the delivery charge:
{
"data": {
"delivery_selection": {
"delivery_selection_id": "dsel_1kmn0aExample",
"delivery_quote_id": "dqt_1kmn0aExample",
"status": "selected",
"amount_money": {"amount": 900, "currency": "USD"},
"choices": [{
"delivery_choice_group_id": "dcgrp_1kmn0aExample",
"delivery_option_id": "dopt_1kmn0aExample",
"delivery_method_id": "dmet_1kmn0aExample",
"type": "shipment",
"name": "Standard shipping",
"amount_money": {"amount": 900, "currency": "USD"},
"total_money": {"amount": 900, "currency": "USD"}
}],
"recipient": {"name": "Morgan Lee", "email": "morgan@example.com", "phone": "+12125550123"},
"input_requirements": [],
"expires_at": "2026-08-03T16:00:00Z"
},
"checkout_session": {
"checkout_session_id": "cs_1kmn0aExample",
"status": "open",
"surface": "headless"
},
"order": {
"order_id": "ord_1kmn0aExample",
"version": 1790760300,
"pricing_amounts": {
"subtotal_money": {"amount": 5000, "currency": "USD"},
"discount_money": {"amount": 0, "currency": "USD"},
"charge_money": {"amount": 900, "currency": "USD"},
"additive_tax_money": {"amount": 500, "currency": "USD"},
"total_money": {"amount": 6400, "currency": "USD"}
},
"settlement_amounts": {
"outstanding_money": {"amount": 6400, "currency": "USD"}
}
}
},
"request_id": "req_1kmn0aExample"
}
Render the totals from the returned order. Don't add the shipping price to a total you already had: shipping is taxable in many places, so the tax can move too. On an order with external tax you provide, the charge takes its tax from the order's tax.delivery_charge_calculation, and the selection request carries no tax; on a callback order, Flint asks your tax calculation callback for it. Without the template, the order's tax is incomplete and paying returns 409 ACTION_NOT_ALLOWED with reason configuration_required. See Tax delivery charges. The order's outstanding balance and version are what you send with the payment in step 10.
With input_requirements empty, the checkout can collect payment. Otherwise it lists each required recipient field the selection is missing, and paying returns 409 ACTION_NOT_ALLOWED with reason configuration_required and resource_type: delivery_selection until a new selection supplies them. Select the same choices from the same quote with the full recipient, sending the selection you're replacing as expected_delivery_selection_id. Flint commits the selection to the order together with a successful payment.
Keep the selection through later changes#
Edits to an open, unpaid order check the provisional delivery selection. If it has expired, no longer matches the order, has a revoked backing quote, or depends on revoked delivery configuration, the edit releases it and returns the order without its delivery charge. Closing the order also releases its provisional selection. This also applies to metadata and note changes. A selection held by a payment is kept.
A delivery price depends on the cart, not on the tip or the tax location. These keep the buyer's selection while it is still usable:
- A tip or a tax location sent with the checkout credential, and saving the buyer's contact. The delivery charge stays on the order, and when the order's tax changes, the tax on the delivery charge changes with it.
- A declined payment, so the buyer can try another card without choosing delivery again.
- A charge, tip, or tax change made with your API key.
- Applying or removing a promotion code, when requoting confirms that the chosen delivery is still valid. Its shipping discount and tax follow the updated order. Older quote alternatives become stale; create a new quote to change the delivery choice.
If a code change invalidates the selection, the response includes delivery_requote_required in meta.warnings. Quote and select again before payment.
These also release it: changing a line item's modifiers, and, with your API key, a new quantity, line item, discount, or inventory_routing_source. The change releases the selection in the same request. The order it returns has no delivery charge, governing_delivery_selection_id is null, and its totals and tax no longer include delivery, so render that order as it is. Any stock the selection held is released with it. The session stays open and reads delivery_selection_required: true, and paying returns 409 ACTION_NOT_ALLOWED with reason configuration_required until the buyer selects from a new quote. See Handle order changes.
Only the selection's own stock hold goes with it. After part of an order is paid, its inventory_reservation_id keeps the stock for the rest of the order instead, and a new quantity on a tracked line, a new or removed tracked line, or a new inventory_routing_source returns 409 RESOURCE_IN_USE with that reservation in details[0].blocking_resources. The order doesn't change.
The checkout credential can change some line item details with PATCH /v1/orders/{order_id}/line-items/{order_line_item_id} and the order's version as expected_version. Each request sends one of modifiers, subscription, or the gift card details (gift_card_recipient, gift_card_face_value_money, or both):
<!-- docs-test {"skip":"Gift-card line-item editing is outside payment-request coverage."} -->
curl -X PATCH https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/line-items/li_1kmn0aExample \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Content-Type: application/json" \
-d '{"gift_card_face_value_money": {"amount": 5000, "currency": "USD"}, "expected_version": 1790760000}'
- Every successful request returns the updated order. A stale
expected_versionreturns409 VERSION_CONFLICT; read the order again before rebuilding the change. - A new gift card face value reprices the line, so render the amounts from the returned order and its
payment_collectionbefore the buyer pays. The value must be USD and within the offer's custom amount range. Orders covers the rules. - When the recipient can no longer change, Flint returns
409 ACTION_NOT_ALLOWEDwith reasonfield_lockedandparam: gift_card_recipient. Other fixed gift card purchase terms, such as the original buyer, use reasonnot_offered.
7. Mount Elements from fresh collection guidance#
Read the order right before you mount or update Elements. Its payment_collection is the authoritative description of what to collect and under which Stripe account, and it changes when the total changes. Under the checkout credential, payment_collection.stripe.elements.next_step is create_confirmation_token. Branch on the returned value rather than assuming it.
Read the collection guidance and Mount Stripe Elements have the Elements setup. When the total changes after mounting, for example after a delivery selection, call elements.update() with the new amount and show the buyer the new total.
8. Decide whether to offer saved cards#
Saved cards are optional. If you offer them, two more things happen before the buyer pays:
- When the buyer types their email, you can ask for a code that opens the cards they saved at your business.
- When the buyer checks a save option, the ConfirmationToken has to carry that choice, as Offer to save the card describes.
Saved cards in checkout covers both. Without them, go on to step 9.
9. Create the ConfirmationToken#
When the buyer submits, call elements.submit(), then stripe.createConfirmationToken({elements}), and post the token's ID to your backend. Create the credential has the code.
The ctoken_... is single-use and pays one payment leg. Never store it as retry authority, and never resend it to continue an existing attempt.
Send it straight to POST /v1/orders/{order_id}/pay in payment_source: Flint creates the payment leg for the full balance and starts the attempt in one request. Create legs yourself only for split tender, partial payment, manual capture, a staged amount, or choosing among existing legs. Legs freeze their amounts and add stale-state handling, so they aren't the default storefront path. See Pay in more than one leg.
10. Start the payment#
Read the order, then send that read's outstanding balance as expected_outstanding_money and its version as expected_version. Pay with the checkout credential:
<!-- docs-test {"scenario":"main","status":200,"card":"pm_card_visa","expect":{"data.order.payment_status":"paid","data.order_payment_attempt.status":"succeeded"}} -->
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/pay \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: pay-cart-123-attempt-1" \
-H "Content-Type: application/json" \
-d '{
"action": "pay",
"payment_source": {
"credential_type": "stripe_confirmation_token",
"stripe": {"confirmation_token": "ctoken_1kmn0aExample"}
},
"expected_outstanding_money": {"amount": 6400, "currency": "USD"},
"expected_version": 1790760300,
"buyer_contact": {"email": "buyer@example.com"}
}'
expected_outstanding_moneystops Flint from charging when the order no longer matches what the buyer approved. The checkout credential must send it, and so must your API key while the order has an open session.expected_versionis optional. It catches an edit that changes the order but not the total, such as one item swapped for another at the same price.- Starting a payment advances the order's
version. After a declined or failed attempt, take the version from the order in the pay response, or read the order again, before the buyer tries again. A resume doesn't takeexpected_version. - If you also send
accepted_gift_card_allocation, itsorder_versionmust matchexpected_version, or the request returns400 INVALID_REQUESTonaccepted_gift_card_allocation. - The browser must never call
stripe.confirmPaymentfor an order's payment.POST /v1/orders/{order_id}/payconfirms it, so there is one authoritative attempt. - Payment needs the buyer's email, from
buyer_contact.email, the contact saved on the session, or the buyer's wallet, and Flint saves it on the customer.
Your backend can also pay the order with your API key while its session is open, for example when the buyer finishes over the phone. Flint pays with the session's current delivery selection, so the delivery charge on the order is the one charged. Only one payment for the order runs at a time. A payment with your API key commits the delivery selection when it collects money. It ends the session as partially_paid if the order still has a balance, or as invalidated with terminal_reason: "order_paid_elsewhere" if it clears the balance. The checkout credential can still read the session, so your page can tell the buyer what happened. A declined payment leaves the session open and the selection in place. Paying the order with your API key has the details.
11. Drive the attempt, not the HTTP status#
Every pay action accepts client_action_type: "url" for a Flint URL, or "stripe" for the existing Stripe.js handoff; omission keeps the existing type on a continuation and defaults to url on a new confirmation. With your API key and url, you can also send payment_return_url to choose where the buyer returns. With the checkout credential, leave it out: the buyer returns to the payment_return_url you set when you created the session, and a pay request that includes the field returns 400 INVALID_REQUEST with detail code INVALID_VALUE. A session without one sends the buyer to Flint's completion page. Embedded payments describes the API key flow and shows both completion message forms and the origin check.
Read every payment response through order_payment_attempt, not through the 200. Run each returned pending_actions[].client_action, such as 3D Secure, then call POST /v1/payment-intents/{payment_intent_id}/confirm for its subject.payment_intent.payment_intent_id with the same checkout credential and no payment_source. The response is the payment intent with current_payment_action; continue that action if one remains. Read the order to check whether the whole collection finished. For setup actions, continue through order pay with action: "resume" and the order_payment_attempt_id. Declines and payment attempts has the status table, the decline set, and how to recover a lost response with active_payment_attempt.
After a decline, collect a new credential and send action: "pay" again with a new Idempotency-Key, the current outstanding balance, and the current order version if you use expected_version. Flint reuses the single declined leg when its amount and currency match the outstanding balance. An active attempt, a processing payment, or multiple open legs cannot be replaced this way.
If the server returns INVALID_REQUEST with param: payment_intents and lists details[0].selectable_resources, select the declined leg explicitly. This also works on versions that require explicit selection after every decline. Send the credential fields inside payment_source in the selection:
<!-- docs-test {"scenario":"staged","status":200,"card":"pm_card_visa","fixtures":{"order":6400,"payment":{"order":true},"checkout":true},"expect":{"data.order.payment_status":"paid","data.order_payment_attempt.status":"succeeded"}} -->
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/pay \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: pay-cart-123-attempt-2" \
-H "Content-Type: application/json" \
-d '{
"action": "confirm_payment_intents",
"payment_intents": [{
"payment_intent_id": "pi_1kmn0aExample",
"payment_source": {
"credential_type": "stripe_confirmation_token",
"stripe": {"confirmation_token": "ctoken_1kmn0bExample"}
}
}],
"expected_outstanding_money": {"amount": 6400, "currency": "USD"},
"expected_version": 1790760301,
"buyer_contact": {"email": "buyer@example.com"}
}'
Use the leg ID from the declined attempt or selectable_resources, and the balance and version from the pay response or a fresh order read. If its frozen amount no longer matches the balance, refresh the checkout and ask the buyer to approve the new total before paying. For processing, requires_action, or an unknown outcome, continue the existing attempt instead of starting another payment.
Two cases matter most in your own checkout:
- Partial success. A
partially_succeededattempt means some legs settled. Keep them, show the errors for the others, and start a new attempt for the remaining balance only. Never retry the original amount. - The session expires mid-payment. If the session passes
expires_atwhile an attempt can still finish, for example on a 3D Secure screen, the checkout credential keeps working for that attempt alone: reading the session and the order, reading that attempt, and resuming it. Finish a payment after expiry lists the routes and the recovery fields.
12. Handle order changes#
When you change the order with your API key while its session is open, for example by adding a line item, changing a quantity, applying a discount, or adding a charge, the session stays open. Its ID and checkout credential keep working, as do the buyer's saved contact and time zone and the credential from a confirmed email, so the browser needs no new bootstrap. Flint reprices the order in place, and the buyer approves the new total:
- Read the order again with the checkout credential and render the new amounts.
- If the change released the delivery selection, quote and select again. A change to line items, quantities, prices, or discounts releases it; a charge, tip, or tax change keeps it while it is still usable. The order the change returns already shows the release: no delivery charge and
governing_delivery_selection_id: null. The session readsdelivery_selection_required: trueuntil the buyer selects again. - Pay with the new outstanding balance and
version. A browser still holding the old ones gets409 VERSION_CONFLICT, and nothing is charged.
Your backend can tell the browser to refresh after a change, or let that error prompt it. A change ends the session only when it closes the order or leaves nothing to pay, with terminal_reason: "order_mutated", or when the session had already passed expires_at, which makes it expired. Changing the order during checkout lists every case.
To give the buyer a new credential on purpose, create a session with replace_checkout_session_id and pass the new credential to the browser. The old session's superseding_checkout_session_id and its checkout_session.invalidated event name the replacement. Never make the browser depend on an ended credential to find its replacement.
When the session ends#
When a session closes or expires, its checkout credential can still read its own session. Call GET /v1/checkout-sessions/{checkout_session_id} with it to get status, terminal_reason, and merchant_support, and tell the buyer what happened and how to reach the merchant. The read returns 200 with status closed or expired. It leaves out payment_collection and setup_collection, because an ended session can't take a payment, and the credential acts for no customer.
Every other call with the credential returns 409 ACTION_NOT_ALLOWED with reason terminal_status and details[0].current_status set to closed or expired. That includes changing the session, quoting delivery, reading or paying the order, and confirming the buyer's email. Treat it as the signal to stop calling and show the ended state. A paid, partially_paid, or invalidated session keeps more read access; After a session ends has the table.
To let the buyer try again, create a new session with the same order_id while the order is still payable; otherwise create a new order first. You can omit replace_checkout_session_id or send the ended session's ID. If another session is now open, naming the old one returns 409 VERSION_CONFLICT with param: replace_checkout_session_id and the open session in details[0].current_resource.
A credential past its own lifetime fails differently: 401 INVALID_CREDENTIAL with details[0].reason expired. Create a new session to get a new credential.
13. Fulfill and send receipts#
Fulfill from a verified, deduplicated webhook or an authoritative backend read, never from the browser reporting success.
You render your own receipt. To send another copy of Flint's receipt, call POST /v1/orders/{order_id}/send-receipt with the checkout credential while the session is paid or partially_paid. The response is the order as the checkout credential reads it.
- Omit
emailto send to the address on file. With the checkout credential, a different address returns409 ACTION_NOT_ALLOWEDwith reasonfield_locked. - If the order has no email on file, send
emailto choose one. The checkout credential can send to at most three distinct addresses over the order's lifetime. Every receipt sent for the order through this route counts, including failed deliveries and receipts sent with your API key. A fourth address returns409 LIMIT_REACHEDwith reasonreceipt_recipients: send to an address already used, or send with your API key. - Addresses are trimmed and lowercased, keeping plus-addressing. You can send to the same address once every five minutes.
Refunds, disputes, and support use your API key. The checkout credential reaches only its own session and order.
Show the merchant's branding and support#
A session read with the checkout credential carries what your page needs to look like the merchant's checkout and to tell the buyer where to get help.
Brand your checkout#
Read GET /v1/checkout-sessions/{checkout_session_id} with the checkout credential:
| Field | How to use it |
|---|---|
merchant_name | Show the business name when theme.title is unset. It reads Merchant when no business name is set. |
merchant_logo, merchant_icon | Show the logo in your header and the square icon in browser tabs or compact headers. Each is an Image with url, width, and height, and is omitted when unset. |
payment_link_image | The current image of the payment link that opened the session. Omitted when the link has none or the session has no payment link. |
show_flint_mark | Whether Flint's hosted pages show the Powered by Flint mark. false when the merchant's agreement with Flint removes it. |
theme | The theme checkout renders with. Omitted when no theme field is set. |
theme.titlecomes from the session and replacesmerchant_namein the header.theme.primary_colorandtheme.accent_colortake the session's values, then fall back to the merchant's branding settings.- The other theme fields come only from branding settings:
background_colorandtext_colorare six-digit hex colors,font_familyisinstrument_sans,system_sans,system_serif, ormonospace(more values can be added), andcorner_radiusis an integer from 0 to 32 pixels, where 0 is square. Every theme field is optional. - The create request's
themeaccepts onlytitle,primary_color, andaccent_color. Set the rest in branding settings. Branding images use theImageshape, not bare URLs or file objects: upload them withPOST /v1/filesandpurpose: "merchant_logo"orpurpose: "merchant_icon". - Only the single-session
GETreturns the merchant name, images, andshow_flint_mark. Create and launch results, lists, and webhooks omit them, so read the session again when you need current branding.themeis in every session response and webhook.
Show how to reach the merchant#
A session read with the checkout credential includes merchant_support, the support email, phone, and help page the merchant set:
"merchant_support": {
"email": "help@example.com",
"phone": "+15125550142",
"url": "https://example.com/support"
}
Show it on your receipt and wherever your checkout tells the buyer to contact the merchant: an expired or closed session (the credential still reads it), or a checkout with no payment method the buyer can use. Link the email with mailto: and the phone with tel:. url is an absolute http or https URL.
Each field is omitted when the merchant hasn't set it, and merchant_support is omitted when none is set. A read with your API key omits it. The merchant sets these under Settings > Business profile in the dashboard, or with support_email, support_phone, and support_url on PATCH /v1/merchant.
Saved cards in checkout#
Flint's hosted checkout may text a returning buyer at the number they added to their Flint wallet; a headless checkout keeps using the store's saved-details number or the buyer's email.
A returning buyer can pay with a card they saved at your business, and any buyer can save the card they type for next time. Hosted checkout does both for you; in your own checkout, your backend drives it through the session. Cards buyers save in checkout explains what each saved card can pay for.
The checkout uses saved cards only for the customer it acts for: the customer you created the session for, or the customer whose email the buyer confirms with a code. A typed email is never enough. Read the session with the checkout credential, and let three fields drive your page:
| Field | When it's true |
|---|---|
can_save_payment_method | Checkout offers to save the card the buyer types. Show an unchecked option under the card fields, such as "Save my details for faster checkout at Cedar & Stone Coffee". |
save_payment_method_requires_verification | The checkout acts for no customer yet. Using saved cards needs a code before paying. A new card can wait pending for an emailed code on the receipt, or be saved with a phone number. |
can_save_payment_method_with_phone | The buyer can save with a mobile phone number, confirmed by a texted code after paying. |
can_save_payment_method is false when checkout.saved_payment_details is off, customer accounts are merchant hosted, card isn't an available payment option, the checkout collects an invoice, a subscription, or a return, or the checkout acts for no customer and Flint can't email the buyer a code. save_payment_method_requires_verification is false whenever can_save_payment_method is. A read with your API key omits all three.
Confirm the buyer's email#
A checkout that acts for no customer needs the buyer's identity confirmed before listing saved cards. A list request with no customer_id returns 409 ACTION_NOT_ALLOWED with details[0].reason: verification_required and no param. Its remediation.next_actions includes create_checkout_session_customer_verification, with the session's customer-verifications URL. Request a code with purpose: use_saved_payment_methods, confirm it, then retry listing with the checkout credential returned by confirmation. The supported email and phone flows are described below; a code might not be offered. The buyer can continue with a fresh card. An explicit customer_id the credential cannot access still returns 404 RESOURCE_NOT_FOUND. Only the checkout credential can call these verification routes.
Request a code with the purpose that matches what the buyer asked for:
purpose | When | email | channel |
|---|---|---|---|
gift_card_purchase | The buyer confirms their email before buying a gift card. Saves no payment method. | Required | email (default) |
save_payment_method | The buyer checked the option to save their card, or a subscription signup returned verification_required, as in Who the subscription belongs to. Flint sends a code to any valid address. | Required | email (default) |
use_saved_payment_methods | The buyer typed their email, to open details they saved. See Recognize a returning buyer. | Required | auto (default), email, or sms |
confirm_saved_payment_method | After a payment that sent save_payment_method_phone. See Save with a mobile phone number. | Not allowed | Required: email or sms |
email is the address the buyer typed, with no surrounding spaces and up to 255 characters. Flint matches customers by email without regard to case. gift_card_purchase works while the session is open, its order has a gift card purchase line and no payment yet, and the checkout acts for no customer.
<!-- docs-test {"skip":"Customer verification email/code flow requires browser and inbox QA; outside payment-request coverage."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/customer-verifications \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: verify-cart-123-1" \
-H "Content-Type: application/json" \
-d '{"email": "buyer@example.com", "purpose": "save_payment_method"}'
The request returns 200. A retry with the same Idempotency-Key returns the same code request and sends no second email or text. For an emailed code, the response is the same whether or not Flint sent one, so it never reveals whether an email belongs to one of your customers:
{
"data": {
"checkout_session_customer_verification_id": "cscv_1kmn0aExample",
"checkout_session_id": "cs_1kmn0aExample",
"email": "buyer@example.com",
"purpose": "save_payment_method",
"channel": "email",
"expires_at": "2026-09-26T15:19:05Z",
"created_at": "2026-09-26T15:04:05Z"
},
"request_id": "req_1kmn0aExample"
}
Ask the buyer for the code, then confirm it:
<!-- docs-test {"skip":"Customer verification email/code flow requires browser and inbox QA; outside payment-request coverage."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/customer-verifications/cscv_1kmn0aExample/confirm \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: verify-cart-123-1-confirm" \
-H "Content-Type: application/json" \
-d '{"code": "482913"}'
{
"data": {
"checkout_session_id": "cs_1kmn0aExample",
"status": "open",
"can_save_payment_method": true,
"save_payment_method_requires_verification": false,
"customer_prefill": {
"email": "buyer@example.com",
"shipping_address": {"line1": "400 Congress Ave", "city": "Austin", "state": "TX", "postal_code": "78701", "country": "US"},
"shipping_recipient_name": "Jordan Lee"
},
"checkout_auth_token": "ckat_2kmn0aExample"
},
"request_id": "req_1kmn0aExample"
}
What a confirmed email changes:
- The new credential.
checkout_auth_tokenis the only credential that acts for the customer. Send it as theAuthorization: Bearertoken from now on. - The customer. The checkout now acts for your customer with that email. Flint creates one when the email has none, and sends
customer.created. - Prefill.
customer_prefillholds the customer's email and default addresses for your form, withshipping_recipient_name, the recipient saved with the default shipping address. An address the customer doesn't have is omitted, andshipping_recipient_namecomes only with ashipping_addressthat has a saved recipient. - Saved cards. List the buyer's cards with
GET /v1/payment-methodsand the new credential, which lists onlyactivecards, and pay with one by sending itspayment_method_idinpayment_source. An emailed code opens only the cards saved by email. When all of the customer's cards were saved with a phone number, the list is empty: tell the buyer their email is confirmed and let them pay with a new card. Whencan_save_payment_method_with_phoneistrue, they can save it with their current number, which replaces the saved one. This is how a buyer who lost their phone gets their saved details back. - Saving. To save the card being typed, send
save_payment_method: truewith the payment, as Offer to save the card describes. - Pricing. Flint links the order to the customer only when the payment succeeds, so confirming changes no item price, tax, or promotion. Delivery conditions on the customer, such as a rate for a customer segment, apply from now on. When that changes what the checkout qualifies for, confirming releases the delivery selection and earlier quotes go stale, so quote and select again. An order that already had a customer keeps being evaluated for that customer.
Every earlier credential for the session, including the one you created the session with and its hosted checkout link, keeps working for the checkout but acts for no customer. With one, listing cards without customer_id returns 409 ACTION_NOT_ALLOWED with details[0].reason: verification_required and no param; request and confirm a code, then list with the credential returned by confirmation. With the earlier credential, paying with a saved card returns 400 INVALID_REQUEST with detail code NOT_ALLOWED, and a read returns save_payment_method_requires_verification: true. It also can't read the buyer's delivery details: delivery selections, quotes, and the order leave out the recipient, destination address, buyer location, and delivery instructions. If that credential later confirms an email for a different customer, Flint releases the delivery selection and removes the earlier buyer's delivery details from the checkout's quotes and selections, so quote and select again. A buyer who opens the link on another device confirms an email there, and from then on only that device's new credential acts for a customer.
The checkout acts for the customer only while the customer keeps that email. If the email changes or the customer is deleted, the new credential also acts for no customer, and a read returns save_payment_method_requires_verification: true again. The buyer can then confirm the new email, or another one.
If the confirm response is lost, the credential you sent still works. Send the same code with it again while the code is valid: the retry counts as a try and returns a new credential for the same customer. You can also request a new code with it. A retry with the same Idempotency-Key returns the stored response.
One error covers every rejected code. 400 INVALID_REQUEST with detail code INVALID_VALUE and param: code means the code is wrong, expired, replaced by a newer code, or out of tries; the checkout was confirmed again after the code was used; the email is past its limit on wrong tries; or the customer's email changed, or the customer was deleted, after the code was sent. Flint never tells a guesser that a code was right. Ask for the code from the latest email, or request a new one.
Restore the code form after a reload#
A page that reloads between sending a code and confirming it has lost the checkout_session_customer_verification_id. Don't request another code to get it back: a new request replaces the earlier code and counts against the checkout's limits. Read the checkout's code requests with the checkout credential instead:
<!-- docs-test {"skip":"Customer verification email/code flow requires browser and inbox QA; outside payment-request coverage."} -->
curl "https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/customer-verifications?page_size=1" \
-H "Authorization: Bearer ckat_1kmn0aExample"
{
"data": [
{
"checkout_session_customer_verification_id": "cscv_1kmn0aExample",
"checkout_session_id": "cs_1kmn0aExample",
"email": "b•••@example.com",
"purpose": "save_payment_method",
"channel": "email",
"expires_at": "2026-09-26T15:19:05Z",
"created_at": "2026-09-26T15:04:05Z",
"supported_actions": ["confirm"]
}
],
"request_id": "req_2kmn0aExample"
}
The list is ordered by created_at descending, then by checkout_session_customer_verification_id descending, and pages with page_size and page_token as Pagination describes. After a reload, restore the form from data[0], the request the buyer is most likely entering a code for:
- Check that
data[0]has thepurposeandchannelyour form expects. If the list is empty, no code is waiting: show the step that asks for the buyer's email, and request a code when they submit it. - Say where the code went. For an email, show the masked address as returned, such as "Enter the code we emailed to b•••@example.com". For a text, use
phone_last_digits, as Recognize a returning buyer shows. - Confirm with
data[0].checkout_session_customer_verification_idand the code the buyer types, as Confirm the buyer's email describes.
What a read returns:
- Live requests only. A code request is readable until its
expires_at. After that the list leaves it out, and reading it by ID returns404 RESOURCE_NOT_FOUND, the same answer as for an ID that doesn't exist, is malformed, or belongs to another checkout. Request a new code when the buyer needs one. - A masked email. Every read returns
emailmasked, even where the request response returned the address as typed. A request with noemail, such as a textedconfirm_saved_payment_methodcode, has none on a read either. Keep the address the buyer typed in your own page state if you need it. - The same shape whether or not Flint sent a code. A request with
"channel": "email"reads the same whether or not Flint sent a code, so a read doesn't reveal whether an email has details saved at your business. - No code and no outcome. A read never returns the code, how many tries are left, or whether the request was confirmed or replaced. A wrong code is still rejected only by the confirm route.
- No side effects. A read sends nothing, uses no try, and doesn't count as a code request toward the limits on codes.
A paid session lists and reads its confirm_saved_payment_method requests, so a confirmation page can restore its form the same way. Only the checkout's own credential can read: your API key gets the same 401 INVALID_CREDENTIAL as the other verification routes, and another checkout's credential gets 404 RESOURCE_NOT_FOUND.
Recognize a returning buyer#
As soon as the buyer types their email, ask for the code that opens the details they saved at your business. auto is the default channel for use_saved_payment_methods, so a request without a channel is an auto request too:
<!-- docs-test {"skip":"Customer verification email/code flow requires browser and inbox QA; outside payment-request coverage."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/customer-verifications \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: verify-cart-123-2" \
-H "Content-Type: application/json" \
-d '{"email": "buyer@example.com", "purpose": "use_saved_payment_methods", "channel": "auto"}'
With auto, Flint sends the code the way the buyer saved their details:
| Saved details | What Flint does | Response |
|---|---|---|
| Saved with a mobile phone number | Texts a code to that number. The text comes from Flint Pay, not your business, and reads "Your Flint Pay verification code is: " followed by the six digits. | "channel": "sms" and phone_last_digits |
| Saved only by email | Emails a code to the address. | "channel": "email" |
| None, or a limit reached | Sends nothing. | 409 ACTION_NOT_ALLOWED with details[0].reason: not_offered |
A texted code's response:
{
"data": {
"checkout_session_customer_verification_id": "cscv_2kmn0aExample",
"checkout_session_id": "cs_1kmn0aExample",
"email": "buyer@example.com",
"purpose": "use_saved_payment_methods",
"channel": "sms",
"code_route": "store",
"phone_last_digits": "71",
"can_use_email_code": false,
"expires_at": "2026-09-26T15:14:05Z",
"created_at": "2026-09-26T15:04:05Z"
},
"request_id": "req_1kmn0aExample"
}
- A texted code includes
code_routeon create, read, and list responses.storemeans it used a number saved at your business. In Flint's hosted checkout,flint_walletmeans it used the buyer's enrolled Flint wallet number, including when your business has the same number. It describes the original request and grants no access itself. The field is omitted for email. Its vocabulary is extensible: use generic code instructions for an unrecognized value. - Say who sent the code and where it went, such as "Enter the code Flint Pay texted to ••• 71" or "Enter the code we emailed to b•••@example.com". Flint never returns the full number.
- On
not_offered, show nothing about saved details and let the buyer pay as usual. - Request once per email. While an emailed code Flint sent this way still works, another
autorequest for the same email answers with that code and sends nothing. To send another code, name the channel:"channel": "email", or"channel": "sms"for a text. - Beside a texted code, offer to email the code instead with
"channel": "email"only whencan_use_email_codeistrue. This read-only field appears only forchannel: "sms"with purposeuse_saved_payment_methods. It means an emailed code would open cards saved by email at your business, or a Flint wallet where the checkout offers one. An emailed code never opens cards saved with a number. An explicit email request still works when the flag isfalse, with the same neutral response as before. - A new text to a number ends the code texted to it for any other checkout, at any business, so only the latest code works.
- Never hold the payment for a code. The buyer can ignore it and pay with a new card.
- Anyone who types an email learns whether it has details saved at your business and, for a text, that number's last two digits. Only a request that names
"channel": "email"answers the same whether or not the email has saved details.
Give the code field autocomplete="one-time-code" and inputmode="numeric", so iOS, and Android keyboards that support it, offer the code from the text. The text has no @your.domain #123456 line, which the WebOTP API needs, so browsers don't fill the code through WebOTP.
Confirm the code with the confirm route. A texted code's credential differs from an emailed code's:
GET /v1/payment-methodslists only the cards saved with that number, and paying with a card saved by email returns400 INVALID_REQUESTwith detail codeNOT_ALLOWED. Cards saved by email open only with an emailed code, whose credential in turn opens no card saved with a number.- The checkout reads no customer details, so
customer_prefillis omitted. - A card the buyer saves with
save_payment_method: trueis saved with the confirmed number. - A texted code checks once. If the confirm response is lost, request a new code.
Pay with a saved card to a new address#
A checkout credential whose customer came from an email or texted code needs a code confirmed within the last 15 minutes before a saved card can pay an order that ships or delivers to a new address. This applies whether the buyer typed their email or used a remembered buyer token. Merchant-named customers, newly entered cards, Apple Pay, and Google Pay do not need this step. Pickup and orders that ship nothing never need it.
An address is known when it matches a saved address or the delivery address of an earlier paid order for this customer at your business. Address comparison trims surrounding whitespace, ignores letter case, and treats an empty second line as absent. Recipient names and phone numbers do not change the destination. A Flint wallet card can also pay to an address in that wallet.
Read pay_to_new_address_requires_verification on the checkout session with the paying credential. It is true when at least one saved card the checkout lists would be refused for the current destination. A wallet card can therefore pay to an address in that wallet while the flag is true for a store saved card. You can ask for a code whenever the flag is true.
{"purpose": "pay_to_new_address"}
Send this body to POST /v1/checkout-sessions/{checkout_session_id}/customer-verifications. Send no email, channel, or remembered_buyer_token. The code follows the credential's proof: email to the confirmed email, or text to the confirmed number. A wallet opened by text uses email for this step instead. The response's channel tells your form which was used. Existing code limits apply. When no listed saved card needs this step, the request returns 409 ACTION_NOT_ALLOWED with reason not_offered.
Confirm the code on the verification's /confirm route with the same credential. The response omits checkout_auth_token: keep your current credential. Its proof still opens the same cards, with a fresh code confirmation for 15 minutes. A code confirmed earlier in that window already counts, so there is no second code immediately after recognition.
The server checks at payment too. A saved-card payment to a new address with an older code returns 409 ACTION_NOT_ALLOWED, reason verification_required, and a next action naming pay_to_new_address. Request and confirm the code, then retry payment with the same credential. A remembered buyer token never satisfies this check.
Remember a returning buyer#
After a buyer confirms a checkout code, you can ask Flint to remember their email on that device. A remembered identity lets your checkout offer to send a code without asking for the email again. It never opens a saved card: the buyer still confirms a code before listing or paying with saved cards.
On the confirmation request, send remember_buyer: true and the remembered_buyer_token your backend already holds, if any:
{
"code": "123456",
"remember_buyer": true,
"remembered_buyer_token": "rbt_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
Omit remembered_buyer_token the first time. If the confirmation remembers the buyer, data.remembered_buyer_token contains a one-time secret. Keep it on your backend or in your own HttpOnly, Secure, SameSite=Lax cookie. Keep it out of page data, HTML, URLs, logs, and analytics. Save a returned replacement before discarding the earlier token. A successful confirmation can omit it, including while Flint's required notice email is unavailable; the code and checkout credential still work.
At the next checkout, call POST /v1/remembered-buyers/lookup with the checkout credential and the token in the body:
{"remembered_buyer_token": "rbt_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}
The response contains the remembered identity's ID, masked email, created_at, last_used_at, expires_at, supported_actions, and code_channel. No route returns the whole remembered email. A non-null code_channel tells you whether recognition would text or email a code at this checkout; null means there is nothing to offer now. Lookup sends nothing and does not check code caps. Show a masked greeting only when code_channel is set, the buyer has not typed or prefilled an email, and no code form is already open.
Wait for the buyer to press a button before requesting a code. On the existing customer-verification create route, replace email with the token:
{
"purpose": "use_saved_payment_methods",
"remembered_buyer_token": "rbt_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
}
Send exactly one of email and remembered_buyer_token. Only use_saved_payment_methods accepts the token. channel is auto by default; you can also name email or sms. With email, the token uses the same send eligibility as a typed email and requests a new code on every press, under the existing explicit-email caps and recognition's network caps. With auto, it keeps recognition's routing and reuse of an open emailed code. These requests use recognition's existing caps. Their create response masks the email too. If nothing is sent, the response is 409 ACTION_NOT_ALLOWED with reason not_offered; let the buyer type an email or pay with a new card. A right code fills buyer_contact.email on the checkout, then opens only the cards that code's channel authorizes.
A token works only at the business and in the live or sandbox environment that received it. It expires 90 days after the last right code. Lookup and requesting a code do not extend that date. A right code with remember_buyer: true replaces the token and renews its expiry. A right code for a different email ends the earlier identity even without remember_buyer. Two code steps without a right code, or one code that runs out of its five tries, end the identity.
For "Not you?" or "Forget this device," call POST /v1/remembered-buyers/revoke with the same body token and checkout credential, then clear your cookie. Lookup and revoke work after the checkout ends, so a receipt can offer to forget. Revoke returns the final masked resource with supported_actions: []; a repeat returns 404 RESOURCE_NOT_FOUND. See lifecycle actions for how to read supported_actions. Lookup uses the same 404 for an unknown, expired, replaced, forgotten, or out-of-scope token. Discard it. A code request with such a token instead returns 400 INVALID_REQUEST with an INVALID_VALUE detail on remembered_buyer_token.
Offer to save the card#
Show the save option when the session's can_save_payment_method is true, under the card fields only: save_payment_method_types lists card, a card the buyer types into checkout.
When save_payment_method_requires_verification is true, send buyer_contact.email with the payment. Flint keeps the new card pending for your customer with that email, creating one if needed. The buyer confirms the save on the receipt, so the payment can finish before the code. Using a previously saved card still requires a code before paying. You can also confirm the buyer's email before paying or save with a mobile phone number. Subscription signup and setup keep their existing verification requirements.
Stripe saves the card from the ConfirmationToken, so the token carries the buyer's choice:
- Create the Elements group for the card fields without
setupFutureUsage. Whenpayment_optionslistsach_debitoraffirm, addsetup_future_usage: "none"to theirpaymentMethodOptionsentries,us_bank_accountandaffirm; without it, the Payment Element fails to load once saving is turned on. - When the buyer checks the option, call
elements.update({setupFutureUsage: "on_session"}), andelements.update({setupFutureUsage: null})when they uncheck it. Wait for theupdate-endevent before callingstripe.createConfirmationToken. - Keep Apple Pay and Google Pay in a separate Elements group that never sets
setupFutureUsage. - With
on_sessionset, the Payment Element adds a line saying the buyer allows future charges, which a card saved this way never gets. Create it withterms: {card: "never"}and show your own wording.
Then send the choice with the payment:
{
"action": "pay",
"payment_source": {"credential_type": "stripe_confirmation_token", "stripe": {"confirmation_token": "ctoken_1kmn0aExample"}},
"expected_outstanding_money": {"amount": 6400, "currency": "USD"},
"buyer_contact": {"email": "buyer@example.com"},
"save_payment_method": true
}
In checkout,
save_payment_method: trueworks only with the checkout credential, whencan_save_payment_methodistrue, for one card the buyer typed, sent as astripe.confirmation_tokencreated withon_session. The token and the flag must agree: a token created withon_sessionand sent withoutsave_payment_methodreturns400 INVALID_REQUESTwith detail codeNOT_ALLOWED, and so doessave_payment_methodwith a card token created without it.Flint records the card once the payment succeeds, including after 3D Secure, for the customer the checkout acts for, or pending for the customer with the payment's email when it acts for none. It has
usage: "on_session", so it pays only in later checkouts, andpayment_method.activatedfollows once it can be charged. A declined payment saves nothing.You can send the buyer's choice with every payment button. Apple Pay, Google Pay, a bank account, or Affirm, in a token created without
setupFutureUsage, pays without the save, and the checkout needn't act for a customer. The payment attempt reports it, so tell the buyer their details weren't saved if you showed the option:JSON"payment_method_save": {"status": "not_saved", "reason": "payment_method_not_saveable"}A resume keeps the choice the attempt started with. Don't send
save_payment_methodwithaction: "resume".
Finish an emailed-code save on the receipt#
A new card saved without a number while save_payment_method_requires_verification is true waits for an emailed code after payment. Read the session with its checkout credential until it reports:
{"payment_method_save": {"status": "pending", "email_confirmation_required": true, "expires_at": "2026-11-13T15:04:05Z"}}
There is no phone_last_digits. Request the code with POST /v1/checkout-sessions/{checkout_session_id}/customer-verifications and {"purpose": "confirm_saved_payment_method", "channel": "email"}. Send no email: Flint sends only to the customer's current email while it matches the email given with the payment. The response masks that address. If it changed, the request is refused with 409 ACTION_NOT_ALLOWED, reason not_offered.
Confirm through the confirm route. The session keeps its credential, status becomes saved, and saved_with is email. Until then, the card works for nothing, even for a buyer who proves the same customer's email in another checkout. The save expires after 24 hours; a wrong code saves nothing. With no number, channel: "sms" is refused. The existing code request limits still apply.
Save with a mobile phone number#
A buyer can save their card by giving a mobile phone number with the payment and confirming it with a texted code after paying. Offer it when can_save_payment_method_with_phone is true. That's while Flint can send texts and either:
save_payment_method_requires_verificationistrue: the buyer hasn't confirmed an email, and the number replaces the code before paying.- The buyer confirmed their email in this checkout. The number is optional: without it, the card is saved by email. With it, the number becomes the customer's saved number once the buyer confirms it, replacing any other, so a buyer who changed phones can move their saved details to the new one.
Only US and Canadian mobile phone numbers work, so keep saving optional for everyone else. Send the number in E.164 format with save_payment_method: true:
{
"action": "pay",
"payment_source": {"credential_type": "stripe_confirmation_token", "stripe": {"confirmation_token": "ctoken_1kmn0aExample"}},
"expected_outstanding_money": {"amount": 6400, "currency": "USD"},
"buyer_contact": {"email": "buyer@example.com"},
"save_payment_method": true,
"save_payment_method_phone": "+14155552671"
}
- When the checkout acts for no customer,
buyer_contact.emailis required, and Flint keeps the card for your customer with that email, creating one if needed. When the buyer confirmed their email, Flint keeps it for that customer. The customer that holds the card while it waits for confirmation gets no ownership of the order: when the buyer paid as a guest, the order stays unlinked from that customer, as in Associate the customer before collection. - Flint records the card once the payment succeeds. When the merchant captures later, that's once the payment is approved, and the checkout stays open until the capture, so the buyer confirms on the approved receipt.
- Nothing is texted before the payment, and a declined payment saves nothing.
- The card works for nothing until the buyer confirms it within 24 hours. A card not confirmed in time isn't saved: Flint removes it from Stripe, and no one can pay with it.
A few seconds after the payment succeeds or is approved, the session read with the checkout credential has payment_method_save:
{
"payment_method_save": {
"status": "pending",
"phone_last_digits": "71",
"email_confirmation_required": false,
"expires_at": "2026-09-27T15:04:05Z"
}
}
On your confirmation page, read email_confirmation_required before requesting a code. When true, request channel: "email" and confirm that one code: the card is saved by email, and the number is not added to the customer. When false, request a texted code as below. A paid session accepts only this purpose:
<!-- docs-test {"skip":"Customer verification email/code flow requires browser and inbox QA; outside payment-request coverage."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/customer-verifications \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: save-cart-123-1" \
-H "Content-Type: application/json" \
-d '{"purpose": "confirm_saved_payment_method", "channel": "sms"}'
Send no email: the code goes to the number from the payment, in a text from Flint Pay, so name Flint Pay where the buyer types it. Confirm the code with the confirm route. The response is the checkout session with its payment_method_save, and no checkout_auth_token, because the session keeps its credential.
- Saved. The texted code saves the card when the payment created the customer, when the buyer confirmed the customer's email in this checkout, or when the number is already the customer's saved number with an active card saved with it.
statusbecomessavedandsaved_withissms. At the buyer's next checkout, a code texted to the number opens it. - Email required. Otherwise
email_confirmation_requiredreadstruefrom the moment the save is pending. Start with the emailed code to finish in one step. API callers can still confirm a texted code first, then an emailed code; that saves the card with the number. - No text. When the text doesn't arrive, offer to email the code instead with
"channel": "email". An emailed code alone saves the card by email, and the number is dropped. Flint emails a code only when the customer's email is the email the payment was made with; the response shows it masked, such asb•••@example.com, so show it as returned. - Expired. After 24 hours,
statusreadsexpired. The buyer can save a card at their next checkout.
A card saved with a number makes it the customer's saved number. The cards saved with the number it replaces are archived, and payment_method.archived fires for each. payment_method.activated fires once the card can be charged. A card that expires sends no event.
Limits on codes#
Flint limits codes per checkout, per email, per number, and per network, so that checkout can't be used to flood an inbox or phone or to guess codes. A request over a limit that would reveal whether an email has saved details answers like an email with none.
| What | Limit |
|---|---|
| An emailed code | Works for 15 minutes and 5 tries. A new request replaces the checkout's earlier code. |
| A texted code | Works for 10 minutes and 5 tries. A new request within those 10 minutes texts the same code again. |
| One checkout, before paying | 5 emailed code requests, and 6 text requests that send at most 3 texts. |
| One saved card, after paying | 3 confirmation codes on each channel. |
| One email, at your business | 3 codes in 15 minutes and 10 in 24 hours. |
| One phone number, at every business | 3 texts in 10 minutes and 10 in 24 hours. |
| Your business | 1,000 texts in 24 hours. |
| Your backend's IP address | 30 code requests or confirmations a second and 200 a minute. In an hour, 100 texts sent, 100 codes emailed by auto requests, and 300 text and auto requests together. |
| Wrong tries, per email or per number | 10 in 24 hours or 30 in 7 days, across all its codes. Past either, Flint sends it no codes and accepts none. |
- A limit over a window of an hour or less is a throttle:
429 RATE_LIMIT_EXCEEDEDwithRetry-After. A daily or weekly limit is a quota:409 LIMIT_REACHEDwithlimitandresets_at. When several limits apply at once, the response names the one that resets last. Wrong tries stay the exception: every limit on them answers like an expired, replaced, or used code, so the response never says whether a guess was right or whether the email ran out of tries. - Limits on your backend's address count separately for each merchant environment. Other businesses that call Flint from the same address don't share them.
- An
autorequest over any limit, and a text request over a limit on texts, answer409 ACTION_NOT_ALLOWEDwithdetails[0].reason: not_offered, the same as an email with no saved details or no number. The answers never say whether an email reached its limit on wrong tries. - Flint-hosted checkout counts the buyer's own network instead: 10 texts sent, 10 codes emailed by
auto, and 30 text andautorequests together an hour, and 3 verification requests or confirmations a second and 20 a minute.
Test codes in a sandbox#
In a sandbox, Flint sends no texts. A texted code's request answers as if Flint texted the number, and the number must still be a valid US or Canadian mobile phone number. To confirm it:
| Code | Result |
|---|---|
000000 | A wrong code. |
999999 | 503 SERVICE_UNAVAILABLE. |
| Any other six digits | Confirms the code. |
Emailed codes arrive as in live mode. Sandboxes covers what else differs.
Apply gift cards#
Show gift card entry when the order's gift_card_tender_enabled is true: it is a USD order that accepts changes, is not a subscription purchase, and the merchant has at least one gift card that is not closed in this environment. Spent but open cards count because a refund can restore their value. The answer changes on the next order read after a card is issued or closed.
A buyer types a gift card code into your page, and your backend applies it to the order with the checkout credential:
<!-- docs-test {"skip":"Gift-card redemption requires a separately funded gift-card fixture; outside card-payment coverage."} -->
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/gift-cards \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: apply-gift-card-cart-123-1" \
-H "Content-Type: application/json" \
-d '{"code": "ABCD-EFGH-JKMN-PQRS", "expected_version": 1790760300}'
The order's gift_card_estimate then says how much the cards cover and what Stripe still charges. Applying reserves and debits nothing. An order can hold up to 20 gift cards, and gift card value can't pay for a subscription order. Orders covers the estimate and the accepted_gift_card_allocation you send with POST /v1/orders/{order_id}/pay. Sell, redeem, and refund gift cards shows where this fits, from selling the card to refunding a split-tender order. Moving gift cards from a Stripe coupon setup? Stripe gift cards covers selling and importing them.
Flint manages the order's gift card redemptions during payment. A redemption that spent value has status: "succeeded"; don't call its capture or cancel route from your checkout. Read the payment attempt and order to determine the checkout's payment outcome.
Apply codes the buyer typed with the checkout credential, never with your API key. Requests with an API key aren't challenged or counted, so a storefront that used one would let anyone guess codes through your backend as fast as it can send them.
A code that doesn't work returns the same 400 INVALID_REQUEST with detail code INVALID_VALUE on code whether it's unknown, belongs to another merchant, or is inactive.
Recover from a challenge#
Flint counts failed codes for the checkout session, for the calling IP address, and for your merchant environment. After enough failures in an hour, every lookup needs a fresh proof from the buyer's browser, even with a valid code. Gift cards lists the thresholds. The apply request then fails with 409 GIFT_CARD_CHALLENGE_REQUIRED:
{
"error": {
"type": "conflict_error",
"code": "GIFT_CARD_CHALLENGE_REQUIRED",
"message": "Complete the gift card challenge, then send its proof in Flint-Gift-Card-Challenge.",
"param": "Flint-Gift-Card-Challenge",
"doc_url": "https://developers.withflintpay.com/docs/errors#gift_card_challenge_required",
"remediation": {
"retry": "none",
"next_actions": [
{
"action_type": "complete_gift_card_challenge",
"url": "https://checkout.withflintpay.com/gift-card-challenge/gccf_example"
}
]
},
"details": [
{
"code": "GIFT_CARD_CHALLENGE_REQUIRED",
"param": "Flint-Gift-Card-Challenge",
"message": "Complete the gift card challenge, then send its proof in Flint-Gift-Card-Challenge.",
"reason": "proof_required"
}
]
}
}
The same url is on the session as gift_card_challenge.url while the session is open. Treat it as opaque, and never build it yourself.
- Your backend sends POST /v1/orders/{order_id}/gift-cards to Flint
- Flint returns 409, with the challenge url to Your backend
- Your backend returns challenge url to Browser
- Browser sends load url in an iframe to Flint
- Flint returns postMessage with proof to Browser
- Browser sends proof to Your backend
- Your backend sends same request, with the proof to Flint
- Your backend tells the browser a challenge is needed and passes along the
url. - The browser loads
urlin an iframe on your checkout page. The buyer stays on your page, and the code stays in your form. - When the buyer passes, the challenge page posts a message to your page. Your page sends the
proofin it to your backend, over your CSRF-protected session. - Your backend repeats the same apply request with the header
Flint-Gift-Card-Challenge: <proof>. Reuse the sameIdempotency-Key: an apply error is safe to retry with a new proof, and a replay of a recorded success returns it without spending the new proof.
A proof authorizes one lookup, for its own checkout session, for five minutes. It's spent before the lookup runs, so a code that turns out to be unavailable still uses it. While a challenge is required, every apply request needs a new proof, including a retry after any error, so remount the iframe before each request. The requirement can last up to an hour after the failures that triggered it.
details[0].reason says what happened:
reason | Meaning | What to do |
|---|---|---|
proof_required | No proof was sent. | Show the challenge at remediation.next_actions[0].url. |
proof_rejected | The proof is malformed, unknown, expired, already used, or was issued for another session, merchant, environment, or mode. | Show the challenge again for a new proof. |
page_origin_required | The session is headless and has no page_origin, so it can't show the challenge. There is no next action. | Create or replace the session with page_origin. |
Show the challenge#
Allow Flint's checkout origin, https://checkout.withflintpay.com in production, in your page's frame-src. You need no script-src change, because your page loads no Flint script. Don't set a sandbox attribute on the iframe; if you must, include allow-scripts and allow-same-origin. The iframe needs about 65 pixels of height and at least 300 pixels of width.
Your page must be the session's page_origin, and it can't itself be framed by another origin, because every ancestor has to be allowed. Pages that send Cross-Origin-Embedder-Policy: require-corp aren't supported.
function showGiftCardChallenge({ challengeUrl, checkoutSessionId, onProof, onFailure }) {
const frameOrigin = new URL(challengeUrl).origin;
const frame = document.createElement("iframe");
frame.src = challengeUrl;
frame.title = "Gift card verification";
frame.style.cssText = "border:0;width:100%;min-width:300px;height:65px";
function onMessage(event) {
if (event.origin !== frameOrigin || event.source !== frame.contentWindow) return;
const message = event.data;
if (!message || message.checkout_session_id !== checkoutSessionId) return;
if (message.type === "flint.gift_card_challenge.completed") {
cleanup();
onProof(message.proof);
} else if (message.type === "flint.gift_card_challenge.failed") {
cleanup();
onFailure(message.reason);
}
}
// A frame that never answers (blocked, offline, or a page that can't load) must not leave the buyer waiting.
const timer = setTimeout(() => { cleanup(); onFailure("timeout"); }, 60_000);
function cleanup() {
clearTimeout(timer);
window.removeEventListener("message", onMessage);
frame.remove();
}
window.addEventListener("message", onMessage);
document.querySelector("#gift-card-challenge").append(frame);
}
The page sends one message and then does nothing more. It never receives messages, and it posts only to your page_origin, never to *. To get another proof, load the URL again.
Message type | Fields | When |
|---|---|---|
flint.gift_card_challenge.completed | checkout_session_id, proof, expires_at (RFC 3339 UTC, five minutes after issue) | The buyer passed. |
flint.gift_card_challenge.failed | checkout_session_id, reason | verification_failed: the challenge didn't verify, so load the page again. unavailable: the page loaded but can't run the challenge now, because the session isn't open, verification isn't configured, the provider is unreachable, or the buyer was rate limited when requesting a proof. |
If the challenge page itself can't load, because it's rate limited, unavailable, or not found, the frame shows a browser error and posts no message. The timeout in the sample covers that case. The check can ask the buyer to interact, so allow at least a minute before giving up.
Accept a message only when event.origin equals the origin of gift_card_challenge.url, event.source is your iframe's contentWindow, type is one of the two above, and checkout_session_id is the session on your page. Ignore any other type: Flint can add messages and fields. Send the proof only to your own backend endpoint for this checkout, and don't store or log it.
Test the challenge in a sandbox#
A sandbox session shows the same challenge page, and it always passes. Proofs are still bound to the session, single use, and good for five minutes, so you can test the whole flow, including a rejected or reused proof. In test mode, page_origin can be http://localhost:3000.
Your backend's IP#
Flint counts failures against the IP address your backend calls from, not the buyer's. The buyer_ip_address you can send when paying is used only for risk screening and doesn't change this count. Buyers who go through one backend share the IP address's failure count, and other merchants on the same hosting egress can share it too. That only causes more challenges, never fewer.
Affirm and ACH debit#
Add affirm or ach_debit to payments.enabled_payment_options, or leave the field out to inherit your checkout settings. Both follow the same steps as a card: read payment_collection, mount the Payment Element, create a ConfirmationToken, and pay the order with the checkout credential. Turn each on first, as Affirm payments and ACH debit payments describe.
Affirm sends the buyer away#
The buyer approves the plan on Affirm's site or app, then comes back to your checkout. Tell Flint where to send them with payment_return_url when you create the session:
{
"type": "order",
"surface": "headless",
"order_id": "ord_1kmn0aExample",
"payments": {"enabled_payment_options": ["card", "affirm"]},
"payment_return_url": "https://shop.example.com/checkout/cart_123/return"
}
- A headless session that offers Affirm needs
payment_return_url, or the create fails with400 INVALID_REQUESTand detail codeREQUIRED. - The URL must be an absolute HTTPS URL with no credentials, query string, or fragment, or the request returns
400 INVALID_REQUEST. In test mode,http://localhostandhttp://127.0.0.1with any port also work. - Omit
payment_return_urlon pay requests made with the checkout credential, as step 11 explains. Put your checkout ID in the session's URL path, as above. - When Affirm is offered,
payment_collection.stripe.return_urlis Flint's return relay. Create the ConfirmationToken with that exactreturn_url, not your own page. - For a
stripeaction, callstripe.handleNextActionas for 3D Secure. For aurlaction, open the returned Flint URL. Both paths send the buyer to Affirm. - Affirm returns the buyer through Flint's relay. A
stripeaction returns to the session's configured URL without added query parameters. Aurlaction returns to its pinned destination withpayment_intent_idadded, or to the Flint completion page when no destination was configured. With the checkout credential, the session's configured return URL supplies that destination. Read the order and attempt from your backend to learn the outcome, then continue as in step 11. - Affirm needs at least 15 minutes left in the session's payment window. Inside the last 15 minutes, the payment fails with
PAYMENT_OPTION_UNAVAILABLEand reasonaction_window_too_shortbefore the buyer is sent anywhere, so offer card instead.
Affirm payments covers eligibility, amount limits, declines, and refunds.
ACH debit settles later#
Bank verification and the debit authorization run inside the Payment Element, so there's nothing extra to build. Create the ConfirmationToken with the buyer's billing name and email: without them the payment fails with 400 INVALID_REQUEST. ACH needs no return URL, because the buyer never leaves your page.
After the buyer submits, the attempt stays processing until the buyer's bank answers, which takes days. It isn't resumable meanwhile, and the order isn't paid.
- Show the buyer that the payment is processing. Don't tell them it failed, and don't start another payment for the order.
- Fulfill from
order.paid, never from the pay response, and check the order'sdispute_statusfirst (access rules). - An order with a line item that tracks inventory is card only, because Flint doesn't hold stock while a debit is unresolved.
ACH debit payments covers settlement, failures, and bank returns.
Collect an invoice or a return balance#
An invoice and a Return resolution each own collection for their order, so each has its own checkout session type:
| Collects | With your API key | With a customer session |
|---|---|---|
| An order | POST /v1/checkout-sessions | Not available |
| An invoice | POST /v1/checkout-sessions with type: invoice | POST /v1/me/checkout-sessions with type: invoice |
| A return or exchange balance | POST /v1/checkout-sessions with type: return_resolution | POST /v1/me/checkout-sessions with type: return_resolution |
POST /v1/checkout-sessions with type: order refuses both: an invoiced order fails with 409 RESOURCE_IN_USE, and a return's replacement order fails with 409 ACTION_NOT_ALLOWED and reason return_checkout, whose details[0].current_resource names the resolution to launch from.
All the launch types take surface, redirects, payment_return_url, and page_origin, and follow the same reuse rules. Headless launches return checkout_auth_token; hosted launches return url and omit checkout_auth_token. The invoice and return types also take return_url, and an invoice launch takes invoice_schedule_entry_id to collect one installment of a payment schedule.
A return balance is fixed. Its checkout doesn't quote or select delivery or add a shipping charge, and you arrange delivery of the replacement yourself.
Request a headless session#
Send "surface": "headless" to collect in your own checkout. Without it, the session is hosted.
<!-- docs-test {"skip":"Invoice checkout launch is outside payment-request coverage; invoice lifecycle needs its own fixture."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: pay-inv-1kmn0a-headless" \
-H "Content-Type: application/json" \
-d '{
"type": "invoice",
"invoice_id": "inv_1kmn0aExample",
"surface": "headless",
"page_origin": "https://shop.example.com",
"payment_return_url": "https://shop.example.com/invoices/inv_1kmn0aExample/return"
}'
- A headless session takes
payment_return_urland noredirects; a hosted session takesredirectsand nopayment_return_url. A headless session whose payment options include Affirm needspayment_return_url, or the request fails with400 INVALID_REQUESTand detail codeREQUIRED. - An invoice request can also send
return_url. When it sends both, they must match, or the request fails with400 INVALID_REQUESTonreturn_url. - Send
page_originto show a gift card challenge. It follows the rules in Set the page origin, except that an invoice or return launch can change it after creation.
How a launch treats page_origin:
- An explicit
page_originreplaces the origin on a reused open headless session. - Without
page_origin, a reused session keeps its origin. A new headless session that replaces an earlier one for the same invoice or return balance, for example after it expired or ended, inherits that session's origin if it's still valid. - Send
"surface": "headless"on every launch. A launch withsurfaceomitted orhostednever inherits an origin, and sendingpage_originwith it fails with400 INVALID_REQUESTonpage_origin.
Read the response#
A launch returns the checkout session in data, with checkout_auth_token among its fields for a headless session, like POST /v1/checkout-sessions for an order:
{
"data": {
"checkout_session_id": "cs_1kmn0aExample",
"type": "invoice",
"surface": "headless",
"status": "open",
"order_id": "ord_1kmn0aExample",
"invoice_id": "inv_1kmn0aExample",
"checkout_auth_token": "ckat_1kmn0aExample"
},
"request_id": "req_1kmn0aExample"
}
checkout_auth_tokenis the checkout credential. Store and relay it as in step 5. A hosted session hasurlinstead.- Read the invoice, or its payment attempts, with their own GETs: the launch returns only the session.
- The status says whether Flint created the session:
201for a new one,200when it returned the open session again. A retry with the originalIdempotency-Keyrepeats the first response, including its status, and setsmeta.idempotency_replayed.
Use the checkout credential to read the session's payment_collection and the order in order_id. For an invoice with a payment schedule, payment_collection describes the installment being collected. Read its amounts from the order and call POST /v1/orders/{order_id}/pay as in an order checkout.
For a return balance, the launch reports type: return_resolution. Later session reads and checkout session events report type: order. Flint creates a payment intent when the resolution is ready for payment. Read its payment_intent_id from the order's payment_collection.stripe.elements.selectable_payment_intents. Create the ConfirmationToken, then send it with that ID to POST /v1/orders/{order_id}/pay using the checkout credential:
{
"action": "confirm_payment_intents",
"payment_intents": [
{
"payment_intent_id": "pi_1kmn0aExample",
"payment_source": {
"credential_type": "stripe_confirmation_token",
"stripe": {"confirmation_token": "ctoken_1kmn0bExample"}
}
}
],
"expected_outstanding_money": {"amount": 162, "currency": "USD"}
}
Use the order's current outstanding amount for expected_outstanding_money.
Reuse and switching#
An invoice or a return has at most one open checkout session at a time. A launch request finds it and decides:
| Open session | What Flint does |
|---|---|
| Same surface | Returns that session and responds 200. Headless launches issue a new credential; hosted launches return its URL and omit the credential. |
| Other surface, no payment in progress | Closes it, creates one with the surface you asked for, and responds 201. |
| Other surface, payment in progress | Fails with 409 ACTION_NOT_ALLOWED and reason in_progress. details[0].current_resource names the open session; read it for its surface. |
A payment attempt never moves between surfaces. To switch, finish or cancel the payment on the existing session, or request its current surface.
Invoicing and Return resolutions describe what each launch route checks before it creates a session.
Start a subscription#
For a known customer and an existing plan, create a headless checkout with subscription_plan_id, collect a payment credential, and submit it to the checkout's order. Flint saves the card and creates the subscription when that order completes.
<!-- docs-test {"skip":"Subscription checkout launch requires a plan fixture; outside one-time payment coverage."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: signup-customer-123" \
-H "Content-Type: application/json" \
-d '{
"type": "subscription_plan",
"surface": "headless",
"subscription_plan_id": "plan_1kmn0aExample",
"customer_id": "cus_1kmn0aExample",
"payments": {"enabled_payment_options": ["card"]}
}'
Take data.order_id and relay the checkout credential. Read the session and the order with the checkout credential before collecting. The order's settlement_amounts.outstanding_money decides the path:
| Amount due now | Collection guidance | Pay request |
|---|---|---|
| Greater than zero | payment_collection | action: "pay" with payment_source |
| Zero, including a trial with no initial charge | setup_collection | action: "setup" with setup_payment_source |
Create the credential from the chosen block's Stripe account and Elements options. A trial with a setup fee or another initial charge uses the paid path. Follow the returned guidance rather than inferring the amount from the plan price.
Show the renewal terms#
Show the terms next to your pay button. The session's subscription_terms holds what the subscription bills: recurring_total_money every billing_interval_count billing_interval, before tax, plus trial_period_days, setup_fee_money, contract_term_months, and early_termination_fee_money when the plan has them. Flint freezes them when it creates the checkout's order, so a later plan change doesn't alter them. Many US states require the price, how often it renews, and how to cancel to appear beside the button the buyer presses to subscribe.
Pay the first charge#
For an amount due now, use the one-shot payment request. The subscription charges renewals without the buyer present, so the payment keeps the card for them:
- Create both Elements groups, the card fields and the Apple Pay and Google Pay group, with
setupFutureUsage: "off_session". Only a card or a wallet card can pay a subscription, and the collection guidance lists no other payment method for one. - The Payment Element then shows a line saying the buyer allows future charges, which is what the subscription does.
- A backend that pays with a Stripe payment method ID in
payment_source.stripe.payment_methodneeds nothing more: Flint confirms the payment withsetup_future_usage: "off_session".
When the payment succeeds, Stripe attaches the card to the subscription's customer, and Flint saves it with usage: "off_session" and creates the subscription with it.
Save the card with nothing due#
Zero-balance collection returns next_step: "collect_setup_payment_source" and Elements mode: "setup". After elements.submit() succeeds, call stripe.createPaymentMethod({elements}) and send the returned payment method ID in setup_payment_source.stripe.payment_method:
<!-- docs-test {"skip":"Zero-total subscription setup requires its subscription checkout and verified buyer fixture."} -->
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/pay \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: signup-customer-123-attempt-1" \
-H "Content-Type: application/json" \
-d '{
"action": "setup",
"setup_payment_source": {
"credential_type": "stripe_payment_method",
"stripe": {
"payment_method": "pm_1kmn0aExample"
}
},
"expected_outstanding_money": {
"amount": 0,
"currency": "USD"
}
}'
Take the currency and outstanding amount from a fresh order read. A request your relay makes for the buyer sends the checkout credential instead of your API key. Flint confirms both paths. Run any returned client action for a payment intent, then confirm that payment intent again without payment_source, using the same checkout credential. This continues the holding attempt without starting another. For setup actions, run the returned client action, then call order pay again with action: "setup" and omit setup_payment_source. Use a new Idempotency-Key for this continuation. It continues the same setup attempt and creates no new attempt:
{
"action": "setup",
"expected_version": 7
}
Take expected_version, when you send it, from the order's current version. A stale version returns 409 VERSION_CONFLICT. If no setup exists, omission returns 400 INVALID_REQUEST with detail REQUIRED and param: setup_payment_source; send the credential to start. A terminal or replaced setup returns 409 ACTION_NOT_ALLOWED naming the attempt and its status. Reusing the continuation's idempotency key replays its result. action: "resume" with order_payment_attempt_id also remains supported.
Who the subscription belongs to#
A checkout created with customer_id saves the card to that customer. A checkout created without one saves it to the customer whose email the buyer confirmed with a code, or, when no customer has the buyer_contact.email, to a minimal customer Flint creates for it. A typed email never attaches a subscription to a customer that already exists. For an initial charge, Flint picks the customer when the payment starts, because Stripe attaches the card when the payment succeeds; a zero-balance setup picks it after the setup succeeds. Flint links the subscription and the order to that customer only after the payment or setup succeeds, as it does when a paid order settles. The link gives the checkout credential no access to that customer's other saved payment methods or details.
When the buyer leaves the email field on a subscription checkout that acts for no customer, ask whether they need a code before they type their card:
<!-- docs-test {"skip":"Subscription customer verification requires browser and inbox QA."} -->
curl -X POST https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample/customer-verifications \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Idempotency-Key: signup-email-cart-123" \
-H "Content-Type: application/json" \
-d '{"email": "buyer@example.com", "purpose": "save_payment_method", "channel": "auto"}'
A 200 response with channel: "email" means a code is needed. Show the code field, confirm it, and use the returned checkout credential for payment. 409 ACTION_NOT_ALLOWED with details[0].reason: not_offered means no code was sent: the email needs no code for this checkout, a cap on codes was reached, or codes can't be sent right now. Show no code step for that response. If the email changes, drop the old step and ask again when the buyer leaves the field.
This request reveals whether the email belongs to an existing customer of your business, as the refusal at payment does. Every lookup counts against recognition's limits, even when it finds no customer. While a code for this purpose and email still works, another automatic request returns it without sending another email. An explicit channel: "email" request can resend the code and skips recognition's network caps, but keeps the shared limits: 5 requests per checkout, 3 per email in 15 minutes, and 10 per email in 24 hours. This combination returns 400 INVALID_REQUEST with an INVALID_VALUE detail on channel for an order that does not start a subscription.
Keep handling the refusal at payment for a buyer who skips the early step or reaches a limit. When the buyer's email belongs to an existing customer and the checkout hasn't confirmed it, pay returns 409 ACTION_NOT_ALLOWED with details[0].reason: verification_required before anything is charged or saved. This covers paid signups, free trials and zero-balance setups, and carts that mix a subscription with other items. To continue:
- Request a code with
POST /v1/checkout-sessions/{checkout_session_id}/customer-verifications,purposesave_payment_method, and the buyer'semail, as in Confirm the buyer's email. - Confirm the code the buyer types. The response holds a new checkout credential.
- Pay again with that credential. The checkout now acts for the customer, and the subscription, order, and card belong to them.
A subscription signup that pays with a saved payment method needs the same authority, and a typed email can't supply it. When the order has no customer_id and the checkout acts for no customer, pay returns 409 ACTION_NOT_ALLOWED with details[0].reason: configuration_required, resource_type: order, and the order's ID as resource_id, whatever email the buyer typed. The error has no param. Its next_actions holds an update_order entry for PATCH /v1/orders/{order_id} with required_fields: ["customer_id"]. Nothing is charged. Set customer_id on the order, then pay again with the same Idempotency-Key. With a checkout credential, confirming the buyer's email in checkout also works.
A signup with an email no customer has needs no code. can_save_payment_method and save_payment_method_requires_verification stay false for a subscription checkout, because they describe the optional option to save a card for faster checkout. Don't wait for them to turn true: make the automatic request when the buyer leaves the email field, and still handle verification_required at payment. To skip the code, create the checkout with the customer's customer_id.
Confirm the signup#
After the attempt succeeds, read the order's subscription_id and the subscription. Check the customer, the subscription status (active or trialing), and the active saved payment method. Grant access from subscription webhooks or an authoritative backend read. Don't call POST /v1/subscriptions after this signup: the completed order already created the subscription.
To show the new subscription on your confirmation page, your relay can read it with the checkout credential:
GET /v1/subscriptions/sub_1kmn0aExample
Authorization: Bearer ckat_1kmn0aExample
The checkout credential reads only the subscription its own checkout created, and only once the session is paid. Before then the read returns 403 FORBIDDEN with details[0].reason checkout_session_payment_required. The response is the Subscription without the fields only your API key can read, and expand isn't available with the checkout credential.
Develop locally#
A sandbox key works against the same API host as a live key, so your backend can run on your machine:
- In test mode,
redirects.success_url,payment_return_url, and the invoice and returnreturn_urlaccepthttp://localhostandhttp://127.0.0.1with any port, andpage_originacceptslocalhost, names ending in.localhost, and127.0.0.1. Live mode needs HTTPS. - Apple Pay doesn't show on
localhost. It needs an HTTPS hostname registered withPOST /v1/payment-method-domains, so test it through an HTTPS tunnel to your machine, or on a staging hostname, after registering that hostname. A missing Apple Pay button onlocalhostdoesn't mean wallets are broken. See Apple Pay and Google Pay setup.
Test before you ship#
Testing has the test cards. At minimum, run:
- An immediate card success, 3D Secure success and cancellation, and insufficient funds.
- A duplicate submit, and recovery from a network timeout.
- An order total that changes before payment, and a tip and a promotion code applied after delivery is selected.
- A wallet that's available and one that isn't.
- Checkout expiry and replacement, an order change made with your API key while the session is open, and recovery of an in-progress attempt after the session expires.
- A webhook retry with a duplicate delivery.
If you offer them, also test:
- For saved cards, a returning buyer by email and by text, a wrong code, saving by email, and saving with a phone number then confirming it.
- For gift cards, five failed codes, a valid code that needs a proof, a reused proof, and a frame that never answers.
- For Affirm, approval, decline, and abandonment.
- For ACH debit, a debit that settles and one the bank rejects.
- For invoices and returns, switching a checkout between surfaces.