Embedded Checkout is Stripe Checkout mounted inside your site. Your server creates a Checkout Session with an embedded UI mode and returns its client_secret; Stripe.js inserts an iframe into an empty div on your page and runs the whole payment form inside it. The buyer never leaves your URL unless a payment method needs a redirect.
What Stripe renamed in dahlia
Stripe's changelog lists these as breaking changes dated 2026-03-25. The old names stop working once you move to the new version, not before:
| Before | Now | From |
|---|
stripe.initEmbeddedCheckout() | stripe.createEmbeddedCheckoutPage() | Stripe.js dahlia and later (@stripe/stripe-js 9+). Same options, same returned object. |
ui_mode: "embedded" | ui_mode: "embedded_page" | API version 2026-03-25.dahlia and later. The old value is rejected. |
ui_mode: "hosted" | ui_mode: "hosted_page" | API version 2026-03-25.dahlia and later. Still the default. |
ui_mode: "custom" | ui_mode: "elements" | API version 2026-03-25.dahlia and later, for Elements with Checkout Sessions. |
stripe.initCheckout() | stripe.initCheckoutElementsSdk() | Stripe.js dahlia and later. This is Elements with Checkout Sessions, not embedded Checkout. |
Which versions throw
The method rename follows the Stripe.js version your page loads; the ui_mode rename follows your server's API version. Stripe recommends keeping both on the same release train.
| How your page loads Stripe.js | initEmbeddedCheckout | TypeScript types | React |
|---|
| @stripe/stripe-js 8 or lower, or js.stripe.com/v3, acacia, basil, or clover | Works. createEmbeddedCheckoutPage also works at runtime. | Declare initEmbeddedCheckout only | @stripe/react-stripe-js 5 and earlier call initEmbeddedCheckout |
| @stripe/stripe-js 9, or js.stripe.com/dahlia | Throws an IntegrationError | Declare createEmbeddedCheckoutPage only | @stripe/react-stripe-js 6 calls createEmbeddedCheckoutPage |
| @stripe/stripe-js 10 (the current npm latest), or js.stripe.com/endive | Throws an IntegrationError | Declare createEmbeddedCheckoutPage only | @stripe/react-stripe-js 7 calls createEmbeddedCheckoutPage |
Every Stripe.js version served today, back to v3, already has createEmbeddedCheckoutPage, so you can switch the call name before you upgrade the package. Only the TypeScript types on @stripe/stripe-js 8 and earlier lack it.
A working embedded Checkout
1. Create the session on your server
Creating a session needs your secret key, so it runs on a server. Return the client secret:
// server.js (Express). The secret key stays on the server.
const stripe = require("stripe")(process.env.STRIPE_SECRET_KEY);
app.post("/create-checkout-session", async (req, res) => {
const session = await stripe.checkout.sessions.create({
ui_mode: "embedded_page", // "embedded" before API version 2026-03-25.dahlia
mode: "payment",
line_items: [{ price: "price_...", quantity: 1 }],
// No success_url or cancel_url: they are not allowed with embedded_page.
return_url: "https://example.com/return?session_id={CHECKOUT_SESSION_ID}",
});
// The browser needs the client secret, not the ID or a URL.
res.json({ clientSecret: session.client_secret });
});
return_url is required when redirect-based payment methods are enabled. Stripe replaces {CHECKOUT_SESSION_ID} with the session ID when it sends the buyer there.
2. Mount it with Stripe.js
<div id="checkout"><!-- Stripe inserts the checkout iframe here --></div>
<script src="https://js.stripe.com/endive/stripe.js"></script>
<script type="module" src="/checkout.js"></script>
// checkout.js
const stripe = Stripe("pk_test_...");
const fetchClientSecret = async () => {
const response = await fetch("/create-checkout-session", { method: "POST" });
const data = await response.json();
if (data.error) throw new Error(data.error);
return data.clientSecret; // a string, not the whole object
};
// Was stripe.initEmbeddedCheckout() before Stripe.js dahlia.
const checkout = await stripe.createEmbeddedCheckoutPage({ fetchClientSecret });
checkout.mount("#checkout");
mount takes a CSS selector or a DOM element. unmount() detaches Checkout so you can mount it again; destroy() removes it for good, and you create a new instance afterward. Don't place the container inside another iframe: Stripe warns that some payment methods redirect to confirm.
3. Or mount it in React
import { useCallback } from "react";
import { loadStripe } from "@stripe/stripe-js";
import { EmbeddedCheckoutProvider, EmbeddedCheckout } from "@stripe/react-stripe-js";
// Outside the component, so the Stripe object is created once.
const stripePromise = loadStripe("pk_test_...");
export function CheckoutPage() {
// useCallback keeps the function stable: the provider reads options once.
const fetchClientSecret = useCallback(
() =>
fetch("/create-checkout-session", { method: "POST" })
.then((res) => res.json())
.then((data) => data.clientSecret),
[],
);
return (
<EmbeddedCheckoutProvider stripe={stripePromise} options={{ fetchClientSecret }}>
<EmbeddedCheckout />
</EmbeddedCheckoutProvider>
);
}
EmbeddedCheckoutProvider creates the instance once and ignores later changes to stripe, fetchClientSecret, clientSecret, or onComplete, with a console warning. To load a new session, unmount the provider and mount a new one, for example by changing its key. Unmounting destroys the Checkout instance for you.
@stripe/react-stripe-js 6 and later call createEmbeddedCheckoutPage; 5 and earlier call the old name, which throws on dahlia. Upgrade the two packages together:
# Upgrade the pair together: each react-stripe-js major pins one stripe-js major.
npm install @stripe/stripe-js@10 @stripe/react-stripe-js@7
The return page and onComplete
redirect_on_completion on the session decides what happens after payment:
always (the default) sends every buyer to return_url. Your return page reads the session's status from your server:
app.get("/session-status", async (req, res) => {
const session = await stripe.checkout.sessions.retrieve(req.query.session_id);
// "complete": show the confirmation. "open": the payment failed or was
// canceled, so mount Checkout again. Fulfill from the webhook, not here.
res.json({ status: session.status, email: session.customer_details?.email });
});
if_required redirects only buyers who used a redirect-based method. Cards finish in place, where Checkout shows its own success state unless you pass onComplete.never never redirects, removes the return_url requirement, and disables redirect-based payment methods.
onComplete runs only with if_required or never. Stripe's pattern destroys the instance and renders your own confirmation:
// The session was created with redirect_on_completion: "if_required".
const checkout = await stripe.createEmbeddedCheckoutPage({
fetchClientSecret,
onComplete: async () => {
checkout.destroy(); // a destroyed instance cannot be mounted again
showReceipt(await fetch("/purchase-details").then((r) => r.json()));
},
});
checkout.mount("#checkout");
Neither the return page nor onComplete is a fulfillment signal. Stripe states that webhooks are required for fulfillment, because a buyer can pay and lose their connection before your page loads. Fulfill from checkout.session.completed; the webhook events reference covers which event to trust.
The errors, and what each means
Each message is quoted from the served Stripe.js script or from @stripe/react-stripe-js, so it matches what your console shows.
On Flint, checkout that prices the order for you
Flint is a payments API with orders, tax, and inventory built in, running on Stripe rails. The order is the record of the sale from the start: Flint computes its total, collects payment against it, keeps refunds and reporting on it, and sends order.paid when it is paid. You choose where the buyer pays it.
A prebuilt page: hosted checkout
Your backend creates a checkout session for an order and sends the buyer to its url. Your page needs only that URL, with no client secret and no Stripe.js to load:
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-order-tote-001" \
-d '{
"type": "order",
"order_id": "ord_1kmn0aExample",
"redirects": {
"success_url": "https://example.com/thanks",
"cancel_url": "https://example.com/cart"
}
}'
Flint's checkout page carries your logo, colors, font, and corner radius. It quotes your delivery methods, collects the tax location, takes promotion codes, tips, and gift cards, and accepts cards, Apple Pay and Google Pay with no domain registration, Affirm, and ACH debit, with 3D Secure handled.
Checkout on your own page: a headless session
For checkout inside your site, Flint does not hand you an iframe of its layout. You own every screen, in any language, on your own domain, and Stripe Elements collects the card on Stripe's domain, so card numbers never reach your servers or Flint's. Create the session with surface: "headless":
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-pro-annual-001" \
-d '{
"type": "order",
"order_id": "ord_1kmn0aExample",
"surface": "headless",
"page_origin": "https://shop.example.com",
"payment_return_url": "https://shop.example.com/checkout/return"
}'
The response has no url. It carries checkout_auth_token, a ckat_ credential scoped to this one checkout, which stays on your backend. Read the order and pass its payment_collection to the browser to mount the Payment Element:
// Your backend read GET /v1/orders/{order_id} and passed on payment_collection.
// It holds no secrets: the publishable key is Stripe's, for Stripe.js.
const { stripe: collection } = paymentCollection;
const guidance = collection.elements;
const stripe = Stripe(collection.publishable_key, {
...(collection.account_id ? { stripeAccount: collection.account_id } : {}),
});
// Apple Pay and Google Pay ride on card in Stripe Elements.
const TYPES = { card: "card", apple_pay: "card", google_pay: "card", affirm: "affirm", ach_debit: "us_bank_account" };
const elements = stripe.elements({
mode: guidance.mode,
amount: guidance.amount_money.amount,
currency: guidance.amount_money.currency.toLowerCase(),
paymentMethodCreation: guidance.payment_method_creation, // "manual"
paymentMethodTypes: [...new Set(guidance.payment_options.flatMap((o) => TYPES[o] ?? []))],
});
elements
.create("payment", {
// Show only the wallets Flint offers; Stripe's default can show others.
wallets: {
applePay: guidance.payment_options.includes("apple_pay") ? "auto" : "never",
googlePay: guidance.payment_options.includes("google_pay") ? "auto" : "never",
},
})
.mount("#payment-element");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const { error: submitError } = await elements.submit();
if (submitError) return showMessage(submitError.message);
// A single-use credential. Flint confirms the payment, not the browser.
const { error, confirmationToken } = await stripe.createConfirmationToken({ elements });
if (error) return showMessage(error.message);
const result = await fetch("/checkout/pay", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ confirmationToken: confirmationToken.id }),
}).then((r) => r.json());
handlePaymentResult(result); // succeeded, requires_action, or failed
});
Your backend sends the token to Flint with the balance the buyer approved. If the order changed in between, Flint returns 409 VERSION_CONFLICT before charging anything:
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/pay \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: pay-ord_1kmn0aExample-ctoken_1kmn0aExample" \
-d '{
"action": "pay",
"payment_source": {
"credential_type": "stripe_confirmation_token",
"stripe": {"confirmation_token": "ctoken_1kmn0aExample"}
},
"expected_outstanding_money": {"amount": 9900, "currency": "USD"},
"expected_version": 1790760000,
"buyer_contact": {"email": "ada@example.com"}
}'
The response's order_payment_attempt.status plays the part of onComplete: succeeded, requires_action for 3D Secure, or failed with the decline message to show. Fulfill from the order.paid webhook.
Stripe embedded Checkout, mapped to Flint
| Job | Stripe embedded Checkout | Flint headless checkout |
|---|
| Start a checkout | Checkout Session with ui_mode: "embedded_page" | Checkout session for an order with surface: "headless" |
| What the browser holds | The session's client_secret | payment_collection, which holds no secrets; the checkout_auth_token stays on your backend |
| The checkout UI | Stripe's prebuilt page in an iframe | Your page, with the Payment Element for card and wallet fields |
| The total | Line items and prices sent on the session | Flint prices the order: tax, delivery, promotion codes, tips, and gift cards |
| Redirect-based methods | return_url | payment_return_url |
| Knowing it finished | The return page or onComplete | order_payment_attempt.status in the pay response |
| Fulfillment | checkout.session.completed | order.paid, after checking the order's dispute_status |
Both Flint surfaces use the same orders, sessions, and webhooks, so you can start on hosted checkout and move to your own page later without rewriting fulfillment. The embedded payments guide covers the payment step with 3D Secure and retries, Build your own checkout adds delivery, saved cards, and gift cards, and checkout sessions covers the hosted page.
Questions, answered
Why does stripe.initEmbeddedCheckout throw an error now?
Stripe renamed it to createEmbeddedCheckoutPage in Stripe.js dahlia, released with API version 2026-03-25.dahlia. Pages that load @stripe/stripe-js 9 or later, or a dahlia or endive script URL, get an IntegrationError from the old name. The options and returned object are unchanged, so the fix is the new name.
What is the difference between embedded_page, elements, form, and hosted_page?
They are Checkout Session UI modes. hosted_page sends the buyer to a Stripe-hosted page at session.url, and is the default. embedded_page mounts Stripe's prebuilt checkout page inside your site with createEmbeddedCheckoutPage. elements uses Checkout Sessions with individual Elements you lay out yourself, through initCheckoutElementsSdk. form is Stripe's Checkout form UI mode, started with initCheckoutFormSdk. Before 2026-03-25.dahlia, embedded_page was embedded, elements was custom, and hosted_page was hosted.
Is Stripe embedded Checkout an iframe?
Yes. You provide an empty div, and Stripe inserts an iframe into it that sends payment details to Stripe. Stripe advises against placing Checkout inside another iframe, because some payment methods redirect to another page to confirm.
Do I need a return_url with embedded Checkout?
When redirect-based payment methods are enabled, yes. success_url and cancel_url are not allowed with embedded_page, so return_url, with {CHECKOUT_SESSION_ID} in it, is where buyers land. Setting redirect_on_completion to never removes the requirement and disables redirect-based payment methods.
When is the onComplete callback called?
Only for sessions with redirect_on_completion set to if_required or never; with the default, always, the buyer is redirected instead. Stripe says onComplete is called when the session completes successfully, or when the checkout.session.completed event is sent. Use it to destroy the Checkout instance and render your own success state.
Can I fulfill the order from the return page or onComplete?
No. Stripe states that webhooks are required for fulfillment, because a buyer can pay and lose their connection before your page loads. Fulfill from checkout.session.completed on your server and use the return page only to show the result.
How do I show embedded Checkout again after the buyer leaves or a payment fails?
If your return page reads a session status of open, the payment failed or was canceled, and Stripe's quickstart says to mount Checkout again. unmount() detaches an instance you can mount again; destroy() removes it for good, after which you create a new one with createEmbeddedCheckoutPage. In React, unmounting EmbeddedCheckoutProvider destroys the instance for you.
Does Flint have an embedded checkout?
Flint gives you two ways to take the same payment. Hosted checkout is one API call that returns a URL to Flint's checkout page, branded with your logo, colors, and font. Or run checkout on your own page with a headless checkout session: Stripe Elements collects the card, and Flint prices the order, runs the payment, and sends order.paid. Flint does not offer a prebuilt checkout iframe.
Sources
- Stripe changelog: Renames Embedded Checkout initialization method (2026-03-25.dahlia), accessed 2026-11-26
- Stripe changelog: Updates Checkout Session UI mode enum values (2026-03-25.dahlia), accessed 2026-11-26
- Stripe changelog: Renames Checkout initialization method (2026-03-25.dahlia), accessed 2026-11-26
- Stripe docs: Embed a checkout page in your site (quickstart), accessed 2026-11-26
- Stripe.js reference: Create, mount, unmount, and destroy embedded Checkout, accessed 2026-11-26
- Stripe docs: Customize redirect behavior for the full embedded page (redirect_on_completion, onComplete), accessed 2026-11-26
- Stripe API reference: Create a Checkout Session (ui_mode, return_url, success_url), accessed 2026-11-26
- Stripe API reference: The Checkout Session object (client_secret, redirect_on_completion), accessed 2026-11-26
- Stripe docs: Stripe.js versioning and support policy, accessed 2026-11-26
- Stripe.js dahlia build: the initEmbeddedCheckout and ui_mode error messages, read from the served script, accessed 2026-11-26
- react-stripe-js: EmbeddedCheckoutProvider source and peer versions, accessed 2026-11-26