Skip to main content
Two scripts put Checkout on your own page. Both are served from js.easner.com. For creating sessions, see Checkout. This page covers the browser side only.

What the browser holds

Create the session on your server with your secret key, read from the environment, and send only the client_secret (or the session id for button.js) to the page. checkout.js refuses a key that starts with easner_sk_, sk_ or rk_ by name, before anything is sent, and throws an error that says to use the publishable key. A publishable key can only call the validate route below. It cannot create sessions, read data or refund. onSuccess and the button events run in the browser and can be faked. Fulfil orders from the checkout.completed webhook.

checkout.js

Loading the script defines window.EasnerCheckout with three methods: mount, openOverlay and destroy. The pay form runs in a secure frame served from checkout.easner.com, so card details never touch your page and your page loads nothing but Easner. The script hands the frame your publishable key and client secret directly, never in a URL. If your site sends a Content Security Policy, allow the hosts in Content Security Policy.

Options

mount and openOverlay take the same options. openOverlay adds title and onClose. mount(target, options) takes the target as its first argument: a CSS selector string or a DOM element. If it matches nothing, mount throws “mount target not found”. mount replaces the target’s contents with the form’s frame, which fills the target’s width and grows and shrinks with the form, so give the target a width and no fixed height. Both mount and openOverlay return a promise that resolves to an object with one method, destroy(). The promise resolves once the form is on screen, or rejects with an Error if it could not load.

mount

Draws the pay form inside your own page. Your cart or order summary stays yours. The form shows its own Payment complete state.

openOverlay

Opens a dialog over your page. The header shows your logo and business name (or title), then a summary of the order with a View order details toggle, then the form. It is a 480 pixel dialog on larger screens and a full-screen sheet on phones.
Overlay behaviour:
  • The page behind it stops scrolling, focus stays inside the dialog, and focus returns to the element that was focused when it opened.
  • The Escape key, a click on the dimmed area, the close button and the Done button after paying all close it.
  • While a payment is being confirmed, Escape, the dimmed area and the close button do nothing, so the result is not lost.

destroy

EasnerCheckout.destroy(target?) removes what you mounted. Destroying an inline form runs no callbacks. Destroying an overlay closes it the same way the close button does, so it runs onSuccess and onComplete first if the payer had paid, then onClose. Unlike the close button, it does not wait for a payment in progress.

Callbacks

Notes:
  • A failed load also rejects the promise from mount or openOverlay, so you can use either onError or a catch. A missing mount target or a missing clientSecret in mount throws without calling onError.
  • A decline does not close anything. The payer sees the message and can try again, so onError can run more than once.
  • The success argument tells you the browser finished the payment. It does not prove funds arrived. Use the webhook to fulfil.

The validate call

Before it draws anything, checkout.js checks the publishable key with:
The request needs no Authorization header. The script sends it to the API origin it was built with, not to the page’s origin. business carries name, logo_url, accent and accent_fallback. The overlay title, logo and accent come from it.

Appearance and accent

You do not pass appearance options. What the embed looks like comes from your business settings. Accent fallback: the accent is used only if white text on it has a contrast ratio of at least 4.5 to 1. If the accent is missing, is not a hex colour or is too light, the embed uses Easner blue instead. The validate call applies the same check and returns accent_fallback as true when it substituted the blue. Inline forms draw in Easner blue until the key check returns, then switch to your accent. The embed has light appearance only. There is no dark option and no option to restyle it. Test keys add a test band above the form.

What the embed collects

The form follows the session you created on your server. Nothing extra is passed to EasnerCheckout. Custom field values and the terms answer are saved to Easner before the payment is confirmed. If saving fails, the payment does not start and the payer sees the reason. The embed also reads the custom fields, terms, and the receipt number from Easner’s public session routes on the API origin of the script, with no credentials and no secret. After a payment the form shows Payment complete, the Amount paid, and a Receipt number that reads “Receipt is on its way” until it exists. A bank payment still processing shows “Your payment is processing” and the amount only. Saved cards are not offered in the embed. Nothing in the embed script attaches a saved customer to the session or draws saved payment methods. Use the hosted page or a payment link for that. If the session details cannot be read from Easner, the form still shows what it can (email, wallets, payment methods, address when it has one), but custom fields and terms are skipped and the receipt number is not shown.

button.js

button.js opens the same overlay for any element marked data-easner-button. It needs no publishable key and no code of your own. One listener on the page covers every button, including ones added later.

Attributes

How it chooses what to open

  1. If data-easner-session is a valid cs_… id, it reads that session from the API. If the session is open and can be paid in the overlay, the overlay opens. If it is not open (completed, expired), the browser goes to the session’s hosted page instead.
  2. Otherwise, if data-easner-link (or the href of a link) is set, it reads the payment link. The overlay opens only for a card or bank link with a fixed amount or a subscription, with online payments on and the link open. A link where the customer chooses the amount, a stablecoin link, a closed link, or any address that is not a payment link goes to that address instead.
  3. A session id wins over a link on the same element. If neither is usable, the element’s href is used as the destination, and a bare button with nothing usable does nothing.
If anything fails while resolving, or the payment form cannot load, the overlay is closed and the browser goes to the hosted page or the link address. Clicks with Cmd, Ctrl, Shift or Alt held, and clicks other than the main button, keep the browser’s own behaviour. While a button resolves it has aria-busy="true", and a second click is ignored. Only one overlay can be open at a time.

Events

button.js fires these on the element that was clicked. They bubble, so you can listen on document.
Branding for the overlay (name, logo, accent) comes with the session or link from the API, so the same accent rules apply.
Never put EASNER_SECRET_KEY in a page, a script tag, a data attribute or front-end code. Only the publishable key and the session client_secret or id belong in the browser.

Content Security Policy

Most sites need nothing here. If your site sends a Content-Security-Policy header, allow Easner’s two hosts, or the pay form will not load: Nothing else is needed: the payment form, wallets and 3D Secure run inside the frame.

Allowed websites

With a live key, the form shows only on the websites on your allowed list (Console, Checkout settings, the same list that allows your return URLs). On any other site the frame shows “This website can’t take payments for this business” and mount or openOverlay rejects with that message. A test key shows the form anywhere, including localhost, so you can build before you list your site. If you have not listed any website yet, a live form shows anywhere until you do.
Last modified on November 18, 2026