Docs

Integrate the Subicon checkout

Add the snippet below to your site (HTML, WordPress, Webflow, React...) and your visitors can buy without leaving your domain.

#Quick start

HTML
<script async defer src="https://js.subicon.io/embed.js"></script>

<div data-subicon-product-id="prod_xxx"></div>

You will find your prod_xxx in the dashboard for each product, in the "Embed code" section.

#Display modes

  • Inlinethe checkout is rendered directly in the page, auto-resizing to its content (default)
  • Modalyour element becomes a trigger — clicking it opens the checkout in a centered modal (close with Escape or by clicking outside)
  • Redirectyour element sends the buyer to a Subicon-hosted checkout page

#Reference of data-* attributes

AttributeDescription
data-subicon-product-idRequired. Public product ID (prod_xxx) — find it in the dashboard.
data-subicon-plan-idOptional. Locks the checkout to a specific pricing plan (plan_xxx).
data-subicon-modeOptional. inline (default), modal, or redirect.
data-subicon-accentOptional. Accent color for buttons — default purple. Choices: purple, blue, green, red, orange, pink, cyan, gray.
data-subicon-refOptional. Affiliate referral code.
data-subicon-return-urlOptional. URL to redirect to after a successful payment.
data-subicon-langOptional. fr or en. Default: detected from the buyer's browser.
data-subicon-on-completeOptional. Name of a global function called on a successful payment with the result, e.g. data-subicon-on-complete="myCb" calls window.myCb({ orderId }).
data-subicon-on-errorOptional. Name of a global function called if the payment fails or is cancelled.

#JavaScript API

For advanced use cases, open the checkout programmatically — this always uses modal mode:

JavaScript
Subicon.openCheckout({
  productId: 'prod_xxx',
  planId: 'plan_xxx',                         // optional — lock to one plan
  accent: 'purple',                           // optional — brand color (default)
  ref: 'AFFILIATE_CODE',                      // optional — affiliate referral
  returnUrl: 'https://your-site.com/thanks',  // optional — redirect after payment
  lang: 'fr',                                 // optional — 'fr' | 'en'
  onComplete: (data) => console.log('Paid! order:', data.orderId),
  onError: (err) => console.error('Checkout failed', err),
});

openCheckout(options) takes the following options:

OptionDescription
productIdRequired. Public product ID (prod_xxx) — find it in the dashboard.
planIdOptional. Locks the checkout to a specific pricing plan (plan_xxx).
accentOptional. Accent color for buttons — default purple. Choices: purple, blue, green, red, orange, pink, cyan, gray.
refOptional. Affiliate referral code.
returnUrlOptional. URL to redirect to after a successful payment.
langOptional. fr or en. Default: detected from the buyer's browser.
onCompleteOptional. Function called on a successful payment, receiving the result (see Callbacks).
onErrorOptional. Function called if the payment fails or is cancelled.

Dynamic contentIf you add data-subicon-* elements after the page has loaded (single-page apps, React…), call Subicon.scan() to mount them. It is safe to call multiple times.

JavaScript
// Mount data-subicon-* elements added to the DOM after load (SPA, React…)
Subicon.scan();

#Callbacks & result

React to the checkout outcome via the data-subicon-on-* attributes or the openCheckout callbacks:

  • onComplete(data)called when the payment succeeds; data contains the orderId.
  • onError(error)called if the payment fails or the buyer cancels.

With data-* attributes, the value is the NAME of a global function (e.g. data-subicon-on-complete="myCb" → window.myCb). With the JavaScript API, you pass the function directly.

If returnUrl is set, the buyer is redirected there after payment with ?status=success&order_id=… appended — onComplete still fires just before the redirect.

#Examples

Plain HTML — drop these tags into any page:

HTML
<!-- Load the loader once (e.g. in <head>) -->
<script async defer src="https://js.subicon.io/embed.js"></script>

<!-- Inline checkout -->
<div data-subicon-product-id="prod_xxx"></div>

<!-- …or a modal trigger (any element) -->
<button data-subicon-product-id="prod_xxx" data-subicon-mode="modal">Buy now</button>

<!-- …or a redirect link -->
<a data-subicon-product-id="prod_xxx" data-subicon-mode="redirect">Buy now</a>

React / Next.js — load the script once and re-scan on mount:

React
import Script from 'next/script';
import { useEffect } from 'react';

export function BuyButton() {
  // Re-scan after this component mounts so the loader picks up the button.
  useEffect(() => { window.Subicon?.scan(); }, []);
  return (
    <>
      <Script src="https://js.subicon.io/embed.js" strategy="afterInteractive" />
      <button data-subicon-product-id="prod_xxx" data-subicon-mode="modal">
        Buy now
      </button>
    </>
  );
}

#Custom styling

In modal and redirect modes, the button or link is your own HTML element — Subicon only attaches a click handler. You can fully style it with your own CSS, Tailwind classes, framework components, etc. In inline mode, you can style the wrapper div (size, margin, max-width) but the checkout itself is rendered inside an iframe and cannot be styled from outside — use the accent color to match your brand.