Esenda
Embedded Checkout

Iframe Customisation

Match the embedded checkout to your brand with colours, fonts and spacing.

You can change how the embedded checkout looks by passing a theme in the checkout URL. A theme is a small JSON object that sets colours, a font stack, button and field corner-radius values, and padding. Anything you leave out keeps the checkout's default appearance.

Before you start

You need a checkout_session_url from the Checkout Session Request, and an iframe set up as described in Iframe Setup, on a domain registered in Domain Setup.

Test your theme

Use the Theme Validator to validate and preview a theme before you ship it. Paste your theme configuration or use Check URL to validate a complete checkout URL or query string.

Quick start

  1. Add an iframe to your page. The allow attribute is required, see Iframe Setup.

    <iframe
      id="payment-iframe"
      src="YOUR_CHECKOUT_SESSION_URL"
      allow="payment; clipboard-write"
      title="Esenda Checkout"
      width="100%"
      height="1040"
    ></iframe>
  2. Add your theme to the session URL as the checkoutTheme query parameter, then load it in the iframe. Run this script after the iframe element exists in the DOM (for example, place it after the iframe markup).

    // Replace with the checkout_session_url from your API response.
    const checkoutSessionUrl =
      "https://demo-checkout.esenda.com/shortcode/partner_link/ORDER_ID";
    
    const theme = {
      version: 1,
      primaryColor: "#2457A6",
      primaryTextColor: "#FFFFFF",
      fontFamily: "sans-serif",
    };
    
    const checkoutUrl = new URL(checkoutSessionUrl);
    checkoutUrl.searchParams.set("checkoutTheme", JSON.stringify(theme));
    
    document.getElementById("payment-iframe").src = checkoutUrl.toString();

searchParams.set URL-encodes the JSON for you and replaces any existing checkoutTheme parameter, so the URL always carries exactly one theme.

How themes are validated

The checkout validates the whole theme before applying it. If any part of the theme is invalid, none of it is applied and the checkout falls back to its default appearance. There is no partial theming.

A theme is rejected if:

  • version is missing or isn't 1
  • it contains a property not listed in Theme properties
  • any value is outside its accepted range or format
  • the parameter value isn't valid JSON, or isn't a single JSON object
  • the URL contains more than one checkoutTheme parameter
  • the JSON is larger than 4096 bytes (UTF-8 encoded)
  • any colour pair fails the contrast requirements

If your theme isn't showing up, work through this list first, then load it into the Theme Validator to see which check fails.

Theme properties

Only version is required.

Schema

PropertyTypeRequired
versionNumber, must be 1Yes

Colours

All colour values must be opaque six-digit hex codes including the #, for example "#2457A6". Three-digit shorthand (#FFF), eight-digit hex with alpha, named colours (white) and other CSS formats (rgb(), hsl()) are rejected.

PropertyApplies to
primaryColorPrimary checkout actions
primaryTextColorText on primary-coloured actions
textColorGeneral checkout text
backgroundColorCheckout background
fieldBackgroundColorForm field backgrounds
borderColorForm field borders

Typography

PropertyAccepted valuesApplies to
fontFamily"default", "sans-serif", "serif", "monospace"Checkout font stack. Each value maps to a predefined stack of locally installed fonts. "default" keeps the checkout's standard font.

Custom or web fonts aren't supported.

Shape and spacing

All values are whole numbers in pixels.

PropertyRangeApplies to
buttonRadius0–16Button corner radius
inputRadius0–16Form field corner radius
contentPadding8–24Padding around checkout content

Contrast requirements

To keep the checkout readable and accessible, every theme must pass these minimum contrast ratios. The ratios follow WCAG 2.1: 4.5:1 for text and 3:1 for interface components.

If you omit a colour, the checkout uses its default value for that colour in the check. This means changing a single colour can cause a failure against a default you didn't set.

ForegroundBackgroundMinimum ratioChecked
primaryTextColorprimaryColor4.5:1Always
textColorbackgroundColor4.5:1Always
textColorfieldBackgroundColor4.5:1Always
primaryColorbackgroundColor3:1When you set primaryColor, backgroundColor or fieldBackgroundColor
primaryColorfieldBackgroundColor3:1When you set primaryColor, backgroundColor or fieldBackgroundColor
borderColorfieldBackgroundColor3:1When you set borderColor or fieldBackgroundColor

If a pair fails, change either colour in the pair until it passes. The Theme Validator runs these checks against the checkout's defaults for you, or you can test individual pairs with WebAIM's contrast checker.

Limitations

  • Themes only style the checkout inside the iframe. They don't affect your surrounding page.
  • Some parts of the checkout are rendered by payment providers and may not support every theme property.

On this page