Skip to main content

Documentation Index

Fetch the complete documentation index at: https://yanhgming.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

The Marlin checkout widget lets customers pay without leaving your app. It opens the hosted checkout page in a sandboxed iframe with a full-screen modal overlay, so all payment logic stays inside a secure iframe and your page never handles any sensitive data. The widget supports three integration patterns: HTML data attributes for no-build setups, a programmatic JavaScript API, and a React component.

Installation

npm install @marlin/checkout
# or
pnpm add @marlin/checkout

Integration patterns

The simplest integration. Add data-marlin-checkout to any button or link and the SDK binds the click handler automatically when the page loads. No JavaScript required beyond the script tag.
<script src="https://unpkg.com/@marlin/checkout/dist/checkout.js"></script>

<!-- One-time invoice payment -->
<button data-marlin-checkout data-invoice-id="inv_abc123">
  Pay $25.00
</button>

<!-- Subscription plan -->
<button data-marlin-checkout data-plan-slug="pro-monthly" data-theme="dark">
  Subscribe
</button>
Supported data attributes:
AttributeDescription
data-marlin-checkoutRequired. Marks the element for auto-binding.
data-invoice-idInvoice ID for a one-time payment.
data-plan-slugPlan slug for a subscription checkout.
data-themelight, dark, or auto (default).
Provide either data-invoice-id or data-plan-slug — not both.

How the widget works

When you call MarlinCheckout.open() (or click a data-attribute button), the SDK:
  1. Creates a full-screen semi-transparent backdrop overlay.
  2. Loads an <iframe> pointing to the hosted checkout page at widget.marlin.fi.
  3. Communicates with the iframe via postMessage events: ready, resize, success, error, and close.
  4. Closes on Escape key, backdrop click, or handle.close().
All wallet connection and transaction signing happens inside the sandboxed iframe. Your page never has access to wallet credentials or private keys.
The iframe is sandboxed and loaded from widget.marlin.fi. If you use a Content Security Policy, add https://widget.marlin.fi to your frame-src directive.

Override the widget URL

To point the widget at a staging environment during development, set the global override before any MarlinCheckout.open() calls:
// Set before importing or calling MarlinCheckout
globalThis.MARLIN_WIDGET_URL = "https://staging-widget.marlin.fi";

Next steps

For a complete reference of all widget options and postMessage event types, see the Widget integration reference.
If you only need a shareable payment link and do not want to embed anything, every invoice already has a paymentUrl you can send directly. See Share a hosted checkout payment link.