Build a headless storefront
Flint hosts two buyer-facing surfaces that you can replace with your own: the checkout where a buyer pays, and the account they come back to afterward. Replace either one, or both. Flint stays authoritative for the order total, the payment, and which buyer owns which records.
A storefront also needs somewhere to browse products and keep a cart. You have two ways to get one:
- Use a shop. Flint hosts the product grid, the product pages, and the cart, and a buyer checks out in Flint's hosted checkout. A shop also gives your own pages the catalog and a cart with no backend: its public reads and resolve take no API key and work from a browser, so a static site or an AI-built site can run its own cart and send the buyer to checkout.
- Build the cart yourself. Your backend creates the order for each cart, then a checkout session for it, and the rest of this storefront path applies, starting with Build your own checkout. Choose this when your app already holds the cart, prices come from outside the catalog, or the checkout must run on your own page.
Choose what to build#
Hosted checkout and Flint's account need no frontend work. Hosted or headless says when building your own checkout pays off.
Headless checkout session
Your own checkout
Render the cart, delivery, and payment screens on your domain. Stripe Elements collects the card. Flint prices the order and runs the payment.
Customer session
Your own customer account
Show order history, subscriptions, Returns, invoices, and saved cards in your app, read through /v1/me for one signed-in buyer.
Hosted or headless#
Start with hosted checkout. For a catalog with a cart, that can be a shop with no backend at all. Otherwise your backend creates the order and a checkout session, sends the buyer to the session's url, and fulfills from the order.paid webhook after checking the order's dispute_status (access rules). For a storefront order, hosted checkout already:
- Collects the shipping address, quotes your delivery methods, and lets the buyer choose an option, a pickup store, or a delivery window.
- Asks for a tax location when automatic tax needs one, and shows a location you set on the order.
- Shows a promotion code field, the tip step, and gift card entry, including the challenge after repeated failed codes.
- Takes cards, Apple Pay and Google Pay with no domain registration, Affirm, and ACH debit, and handles 3D Secure.
- Offers saved cards to returning buyers who confirm their email with a code.
- Tells the buyer when the order changed, was paid another way, or is already being paid.
Build your own checkout when you need one of these:
| You need | Hosted checkout | Your own checkout |
|---|---|---|
| Checkout on your domain | checkout.withflintpay.com, or a custom domain for $15 a month, in live mode only | Your domain |
| Your own layout and steps | Your logo, colors, font, and corner radius | Any page you build |
| A language other than English | English only | Any language you write |
| Your own questions, such as a PO number or a gift note | Not on checkout sessions. Payment links support custom fields. | Collect them on your page and store them in the order's metadata |
| Checkout on the same page as the buyer's account | A redirect to Flint's page and back | One page |
Your own checkout adds this work:
- A backend route for each buyer action (saving contact, quoting and selecting delivery, applying codes and gift cards, paying), each relaying the checkout credential.
- CSRF protection, origin checks, and rate limits on those routes. Your page also runs your own JavaScript, which widens your PCI scope; see Securing a headless checkout.
- Registering each checkout hostname for Apple Pay and Google Pay.
- The cases hosted checkout handles for you: 3D Secure and other next actions, Affirm's return to
payment_return_url, the gift card challenge iframe forpage_origin,409 VERSION_CONFLICTwhen the order changes, and a session that ends while the buyer is on the page.
Both surfaces use the same orders, sessions, and webhooks, so the order and fulfillment code you write for hosted checkout carries over if you switch later.
Choose a combination#
Neither requires the other. Every combination works:
| Checkout | Account | What you set |
|---|---|---|
| Flint's | Flint's | Nothing. Hosted checkout sessions and a flint_hosted account are the defaults. |
| Yours | Flint's | Create checkout sessions with "surface": "headless". Send signed-in buyers to their account with a customer access link. |
| Flint's | Yours | Set customer_account.mode to merchant_hosted with your merchant_account_url, so Flint's email links to your pages. |
| Yours | Yours | Both of the above. |
If you are building both, build the checkout first. It sets up the backend relay and credential handling that the account reuses.
How the pieces connect#
The full loop for a signed-in buyer who pays in your checkout and then opens your account:
- Browser sends sign in with your own login to Your backend
- Your backend sends find or create the customer to Flint
- Your backend sends create the order with customer_id to Flint
- Your backend sends create a headless checkout session to Flint
- Flint returns checkout credential to Your backend
- Browser sends pay, with a ConfirmationToken from Stripe Elements to Your backend
- Your backend sends POST /v1/orders/{order_id}/pay with the checkout credential to Flint
- Flint sends order.paid webhook to Your backend
- Browser sends open the account to Your backend
- Your backend sends POST /v1/customer-sessions to Flint
- Your backend sends GET /v1/me/orders with the session secret to Flint
- Flint returns this buyer's orders, including the new one to Your backend
For this headless storefront, the browser talks to your backend and to Stripe.js.
Warning: Your backend is required
Flint has no publishable key. Your storefront reaches Flint through your server. Both credentials below stay on that server, tied to your own browser session. The only calls a merchant page can make directly from the browser are the keyless public reads and resolve calls: GET /v1/payment-links/{payment_link_id}/public and POST /v1/payment-links/{payment_link_id}/resolve to start a payment-link checkout, and GET /v1/shops/{shop_id}/public, GET /v1/shops/{shop_id}/listings/{shop_listing_id}/public, and POST /v1/shops/{shop_id}/resolve to run a cart on your own page. 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.
Two credentials, two questions#
A headless storefront holds two kinds of buyer credential. They look alike and are not interchangeable.
| Checkout credential | Customer session | |
|---|---|---|
| Answers | Is this the buyer paying for this order? | Which buyer is this? |
| Scope | One checkout session and its order | One customer, across all their records |
| Sent as | Authorization: Bearer ckat_... | Authorization: Bearer flint_cses_... |
| You get it from | checkout_auth_token when you create a checkout session | secret from POST /v1/customer-sessions, after you authenticate the buyer |
| Lasts | Up to 30 days. After the session ends, it can still read the session. After payment, it can also read the order. | 1 hour by default, refreshable for 7 days |
| Takes payment | Yes, for its order | Only to renew or retry the buyer's own subscription, on a saved card |
The difference that matters: a customer session can't pay for an order, an invoice, or a Return balance. When a signed-in buyer pays an invoice from your account page, your backend launches a checkout session for it with POST /v1/me/checkout-sessions and type: invoice, and the payment runs on that session's checkout credential. In the other direction, a checkout credential can't read the buyer's other orders, because it is bound to one.
The two meet at the order. The account launches a checkout to take money, and checkout learns who the buyer is from the order's customer_id.
Carry a signed-in buyer into checkout#
When the buyer is signed in to your storefront, attach their Flint customer to the order before you create the checkout session. Their saved payment methods then resolve in checkout, and the paid order is already in their account.
When the buyer signs in during checkout#
A checkout session takes its customer from the order when you create it, and the order's customer can't change while that session is open. If the buyer signs in after you created the session, close it with POST /v1/checkout-sessions/{checkout_session_id}/close, set customer_id on the order, and create a new session. Send the session's version as expected_version when you close it, so you don't close a session that changed after your read without seeing the change. A stale value returns 409 VERSION_CONFLICT; read the session again before you decide.
Guest buyers#
A buyer doesn't need an account to pay. For a guest, send the email they enter as buyer_contact.email when you pay the order, or save it on the session as they type. A save on the session can carry the session's version as expected_version, as Buyer contact shows. A typed email never joins an order to a customer that already exists. Once the order is fully paid, Flint creates a minimal customer when no customer has that email, links the order to it, and sends customer.created. When a customer already has the email, the order stays unlinked with the buyer email retained, and it doesn't appear in that customer's /v1/me or hosted account. The same holds for a subscription signup, which first needs the buyer to confirm the email with a code, as Who the subscription belongs to describes.
When a guest whose order was linked to a customer Flint created later signs up with you, creating their customer with on_email_conflict: "return_existing" returns that customer, as in step 1, and those orders come with it. Guest orders left unlinked don't.
Guest orders that have the buyer's email but no customer stay unlinked until the buyer proves they own the email. Request a code with POST /v1/customer-verifications, confirm what the buyer types, then call POST /v1/customers/{customer_id}/link-guest-purchases. Link a buyer's guest purchases walks through it. Never treat a bare email, an order ID, or a customer session as proof.
Who decides what a buyer can see#
You do, up to the moment you mint a customer session. After that, Flint enforces it on every /v1/me request.
- Links from Flint's email are routing hints. In
merchant_hostedmode, links carryflint_resource_typeandflint_resource_idso you can open the right page after sign-in. They grant nothing. Sign the buyer in, mint their session, and read the resource through/v1/me. A404means it belongs to someone else. - Email changes depend on the account mode. In
merchant_hostedmode, the merchant API can set, change, or clearemail. Inflint_hostedmode, it can do so until the buyer authenticates or verifies ownership of the email. After that, the buyer requests the change withPOST /v1/me/email-change-requestsand confirms the codes Flint sends withPOST /v1/me/email-change-requests/{email_change_request_id}/confirm.
Move between the two surfaces#
| From | To | How |
|---|---|---|
| Your account | A payment | POST /v1/me/checkout-sessions with type: invoice or type: return_resolution, and "surface": "headless". Collect it like any invoice or return balance. |
| Your checkout | Flint's account | Create a customer access link with POST /v1/customers/{customer_id}/access-links and redirect to its url, a one-time sign-in link. Available only in flint_hosted mode. |
| Flint's email | Your account | merchant_hosted mode with route_templates. See Point Flint's email at your pages. |
Before you go live#
- API keys, checkout credentials, and customer session secrets never reach the browser, a URL, or a log.
- Your relay derives Flint IDs from your own session state, never from IDs the browser sends.
- A signed-in buyer's order has
customer_idset before its checkout session is created. - Fulfillment runs from a verified
order.paidwebhook or a backend read, never from a browser success callback, and checks the order'sdispute_statusfirst. - Customer sessions are revoked on sign-out with
POST /v1/me/session/revoke, and all of a customer's sessions on a password change or suspected takeover. - If you built the account, Flint's email links to it, and your login preserves the
flint_*parameters through sign-in.