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
-
Add an iframe to your page. The
allowattribute 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> -
Add your theme to the session URL as the
checkoutThemequery 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:
versionis missing or isn't1- 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
checkoutThemeparameter - 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
| Property | Type | Required |
|---|---|---|
version | Number, must be 1 | Yes |
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.
| Property | Applies to |
|---|---|
primaryColor | Primary checkout actions |
primaryTextColor | Text on primary-coloured actions |
textColor | General checkout text |
backgroundColor | Checkout background |
fieldBackgroundColor | Form field backgrounds |
borderColor | Form field borders |
Typography
| Property | Accepted values | Applies 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.
| Property | Range | Applies to |
|---|---|---|
buttonRadius | 0–16 | Button corner radius |
inputRadius | 0–16 | Form field corner radius |
contentPadding | 8–24 | Padding 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.
| Foreground | Background | Minimum ratio | Checked |
|---|---|---|---|
primaryTextColor | primaryColor | 4.5:1 | Always |
textColor | backgroundColor | 4.5:1 | Always |
textColor | fieldBackgroundColor | 4.5:1 | Always |
primaryColor | backgroundColor | 3:1 | When you set primaryColor, backgroundColor or fieldBackgroundColor |
primaryColor | fieldBackgroundColor | 3:1 | When you set primaryColor, backgroundColor or fieldBackgroundColor |
borderColor | fieldBackgroundColor | 3:1 | When 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.