Skip to content

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.

Build your own checkout

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.

Build your own customer account

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 needHosted checkoutYour own checkout
Checkout on your domaincheckout.withflintpay.com, or a custom domain for $15 a month, in live mode onlyYour domain
Your own layout and stepsYour logo, colors, font, and corner radiusAny page you build
A language other than EnglishEnglish onlyAny language you write
Your own questions, such as a PO number or a gift noteNot 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 accountA redirect to Flint's page and backOne 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 for page_origin, 409 VERSION_CONFLICT when 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:

CheckoutAccountWhat you set
Flint'sFlint'sNothing. Hosted checkout sessions and a flint_hosted account are the defaults.
YoursFlint'sCreate checkout sessions with "surface": "headless". Send signed-in buyers to their account with a customer access link.
Flint'sYoursSet customer_account.mode to merchant_hosted with your merchant_account_url, so Flint's email links to your pages.
YoursYoursBoth 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:

Headless storefrontResponse
BrowserYour backendFlintsign in with your own loginfind or create the customercreate the order with customer_idcreate a headless checkout sessioncheckout credentialpay, with a ConfirmationToken from Stripe ElementsPOST /v1/orders/{order_id}/pay with the checkout credentialorder.paid webhookopen the accountPOST /v1/customer-sessionsGET /v1/me/orders with the session secretthis buyer's orders, including the new one
  1. Browser sends sign in with your own login to Your backend
  2. Your backend sends find or create the customer to Flint
  3. Your backend sends create the order with customer_id to Flint
  4. Your backend sends create a headless checkout session to Flint
  5. Flint returns checkout credential to Your backend
  6. Browser sends pay, with a ConfirmationToken from Stripe Elements to Your backend
  7. Your backend sends POST /v1/orders/{order_id}/pay with the checkout credential to Flint
  8. Flint sends order.paid webhook to Your backend
  9. Browser sends open the account to Your backend
  10. Your backend sends POST /v1/customer-sessions to Flint
  11. Your backend sends GET /v1/me/orders with the session secret to Flint
  12. 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 credentialCustomer session
AnswersIs this the buyer paying for this order?Which buyer is this?
ScopeOne checkout session and its orderOne customer, across all their records
Sent asAuthorization: Bearer ckat_...Authorization: Bearer flint_cses_...
You get it fromcheckout_auth_token when you create a checkout sessionsecret from POST /v1/customer-sessions, after you authenticate the buyer
LastsUp 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 paymentYes, for its orderOnly 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.

  1. Find or create the customer#

    Keep the Flint customer ID on your own user record, so later checkouts skip this step. The first time a user needs one, create the customer with on_email_conflict: "return_existing" and your user ID as external_reference_id:

    cURL
    curl -X POST https://api.withflintpay.com/v1/customers \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Idempotency-Key: customer-user_8812" \
      -H "Content-Type: application/json" \
      -d '{
        "email": "buyer@example.com",
        "name": "Avery Chen",
        "external_reference_id": "user_8812",
        "on_email_conflict": "return_existing"
      }'
    

    201 means Flint created the customer. 200 means a customer already had that email, usually the one Flint created from the buyer's earlier guest checkout, and Flint returned it unchanged. The fields you sent aren't applied to it, so if its external_reference_id is null, store your user ID with PATCH /v1/customers/{customer_id}.

    Use return_existing only for an email your sign-up has verified. The existing customer's orders appear in the user's account, so an unverified address would show one person another's purchases. Guest orders from an email that already had a customer don't appear until the user claims them with link-guest-purchases.

    After that, key on the stored customer ID, not the email. A customer's email can change after you store it, so your copy of the address can drift.

  2. Create the order for that customer#

    cURL
    curl -X POST https://api.withflintpay.com/v1/orders \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Idempotency-Key: order-cart-123" \
      -H "Content-Type: application/json" \
      -d '{
        "customer_id": "cus_1kmn0aExample",
        "line_items": [
          { "type": "variant", "variant_id": "var_1kmn0aExample", "quantity": 1 }
        ]
      }'
    

    If the cart already has an order, set the customer with PATCH /v1/orders/{order_id} and customer_id instead. An order's customer is set once and can't be changed.

  3. Create the checkout session#

    cURL
    curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Idempotency-Key: checkout-cart-123" \
      -H "Content-Type: application/json" \
      -d '{
        "type": "order",
        "surface": "headless",
        "order_id": "ord_1kmn0aExample",
        "page_origin": "https://shop.example.com"
      }'
    

    Store checkout_auth_token with your browser session, and relay checkout calls as Build your own checkout describes.

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.

  • HTTP 409
    A checkout session is open for the order. Close the session in details[0].current_resource, then set the customer.
  • HTTP 409
    field_locked: The order already has a customer. Start a new order for a different buyer.

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_hosted mode, links carry flint_resource_type and flint_resource_id so 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. A 404 means it belongs to someone else.
  • Email changes depend on the account mode. In merchant_hosted mode, the merchant API can set, change, or clear email. In flint_hosted mode, it can do so until the buyer authenticates or verifies ownership of the email. After that, the buyer requests the change with POST /v1/me/email-change-requests and confirms the codes Flint sends with POST /v1/me/email-change-requests/{email_change_request_id}/confirm.

Move between the two surfaces#

FromToHow
Your accountA paymentPOST /v1/me/checkout-sessions with type: invoice or type: return_resolution, and "surface": "headless". Collect it like any invoice or return balance.
Your checkoutFlint's accountCreate 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 emailYour accountmerchant_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_id set before its checkout session is created.
  • Fulfillment runs from a verified order.paid webhook or a backend read, never from a browser success callback, and checks the order's dispute_status first.
  • 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.
Sell with a shop and a cartA hosted shop page and cart, buy buttons, and keyless reads for your own cart.Build your own checkoutThe headless checkout session, Stripe Elements, payment attempts, and delivery.Build your own customer accountEverything /v1/me lets a signed-in buyer read and do.Securing a headless checkoutThe trust boundary both surfaces share, and what changes for PCI.Customer sessionsMinting, refresh rotation, and revocation.

Was this helpful?