Skip to main content

Embedding the Cart in an Iframe

You can show your configurable cart inside a page on your own website, such as https://www.example.com/start-your-business. Your customers check out without leaving your domain, and your URL stays in their address bar.

When the cart detects that it is inside an iframe, it hides its own header and progress bar so it fits into your page's layout.

The cart embedded in a partner page. The partner's sidebar, page title and step indicator surround the cart, which has no header of its own The cart inside an example partner site, "Lumen Business Hub". The sidebar, page title and step indicator belong to the partner's page. The framed area is the cart.

How it works​

1. Register your domains​

Browsers only show the cart in an iframe on domains that SwyftFilings has registered for your partner ID. On any other domain, the browser blocks the iframe.

Send your SwyftFilings contact:

  • your partner ID;
  • every domain that will host the iframe, including subdomains (for example www.example.com and example.com);
  • which environment each domain is for: sandbox or production.

Wait until SwyftFilings confirms the domains are registered before you go live. Domains are registered for each environment separately.

note

You don't need to set any headers on your own server for this. The cart's response tells the browser which sites may frame it, based on the partnerId in the cart URL.

Local development

Pages served from https://localhost (port 443) can always show the cart, so you can build and test before your domains are registered. http://localhost and other ports, such as https://localhost:3000, are blocked.

2. Add the iframe to your page​

<iframe
id="swyft-cart"
title="Start your business"
src="https://www.swyftfilings.com/cart/partner?partnerId={PARTNER_ID}"
allow="payment"
style="width: 100%; height: 100vh; min-height: 900px; border: none;"
></iframe>
  • Always include partnerId in the src. The cart uses it to load your branding and products, and to decide whether your domain may frame it. Without it, the iframe is blocked.
  • allow="payment" lets Google Pay and Apple Pay work inside the iframe. Card and PayPal payments work without it.
  • Height: the cart does not report its height to your page. Give the iframe a fixed or viewport-based height that fits the longest step, as in the example.

If you add a sandbox attribute to the iframe, it must include at least:

sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"

The cart needs these to save the customer's progress, submit forms, open PayPal, and open the Customer Portal in a new tab after checkout.

3. Follow the customer's progress (optional)​

Each time the customer moves to another step, the cart sends a CART_NAVIGATION message to your page:

{
"type": "CART_NAVIGATION",
"payload": {
"page": "/partner/?partnerId=acme-tax-pros&step=package-selector",
"partnerId": "acme-tax-pros"
}
}

payload.page is the cart path, without the /cart prefix. The step value tells you where the customer is:

stepStep
contact-infoContact information
package-selectorChoose a package
(add-on name, for example registered-agent)An add-on step
review-orderReview order
checkoutPayment
application-detailsApplication details (after payment)
confirmationOrder placed

Use these messages for your own analytics, to show your own progress indicator, or to scroll your page to the top when the step changes.

A partner page whose own step indicator highlights &quot;Package&quot; while the cart shows the package step The partner page's step indicator follows the cart's CART_NAVIGATION messages. Here the customer is on the package step.

Always check the sender's origin:

<script>
const CART_ORIGIN = "https://www.swyftfilings.com";

window.addEventListener("message", (event) => {
if (event.origin !== CART_ORIGIN) return;
if (event.data?.type !== "CART_NAVIGATION") return;

const step = new URLSearchParams(event.data.payload.page.split("?")[1]).get("step");

document.getElementById("swyft-cart").scrollIntoView({ behavior: "smooth" });
// e.g. analytics.track("cart_step_viewed", { step });
});
</script>

4. Send the customer to a step (optional)​

Your page can send the same message to move the cart to another page. Use a path in the same format the cart sends:

const cart = document.getElementById("swyft-cart");

cart.contentWindow.postMessage(
{
type: "CART_NAVIGATION",
payload: { page: "/partner/?partnerId={PARTNER_ID}&step=review-order" },
},
"https://www.swyftfilings.com"
);

The cart keeps the customer's answers in their browser, so moving between steps doesn't lose them. Only send customers to steps they have already reached. A later step can't be completed without the earlier ones.

Testing​

  1. Ask SwyftFilings to register your test domain for the sandbox environment.

  2. Use the sandbox cart URL in your iframe:

    https://www.qa.swyftfilings.com/cart/partner?partnerId={PARTNER_ID}

    In your message listener, set CART_ORIGIN to https://www.qa.swyftfilings.com.

  3. Place a test order with a sandbox test card provided by your SwyftFilings contact.

  4. Before going live, switch the iframe src and CART_ORIGIN to production and confirm that your production domains are registered.

Troubleshooting​

The iframe is blank​

If your domain isn't registered for the environment, or partnerId is missing from the iframe src, the browser blocks the cart. The iframe shows a blank page or a "refused to connect" icon:

A partner page whose cart iframe is blank, showing only a broken-page icon

The browser console (DevTools → Console) explains why. Look for a frame-ancestors error:

Console error: Framing violates the Content Security Policy directive frame-ancestors

The "Framing" line names the cart's site, not yours. Check that the iframe src includes partnerId, then ask SwyftFilings to register the domain of your page, the one in your browser's address bar, for that environment. To test before then, use https://localhost.

Other problems​

SymptomLikely cause
The iframe is blank, and the browser console mentions frame-ancestorsYour domain isn't registered for this environment, or partnerId is missing from the iframe src. For local testing, use https://localhost without a port.
The cart loads without your branding or products, or shows an errorThe partner ID is wrong, or your partner account is inactive.
Google Pay or Apple Pay doesn't appearThe iframe is missing allow="payment".
PayPal or "Access my account" doesn't openThe sandbox attribute is missing allow-popups or allow-popups-to-escape-sandbox.
The bottom of a step is cut offThe iframe is too short. Increase its height.