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.

This page walks through each integration pattern for @marlin/checkout in full detail. Choose the tab that matches your environment.
The data-attribute pattern requires no build step. Add the CDN script to your page, mark any button or link with data-marlin-checkout, and the SDK auto-binds click handlers on DOMContentLoaded.
1

Add the script

Paste the CDN script tag before the closing </body> tag of your page.
<script src="https://unpkg.com/@marlin/checkout/dist/checkout.js"></script>
2

Mark your trigger element

Add data-marlin-checkout to any clickable element. Include either data-invoice-id for a one-time payment or data-plan-slug for a subscription.
<!-- One-time payment -->
<button data-marlin-checkout data-invoice-id="inv_abc123">
  Pay $25.00
</button>

<!-- Subscription -->
<button data-marlin-checkout data-plan-slug="pro-monthly" data-theme="dark">
  Subscribe
</button>
Supported data-* attributes:
AttributeRequiredDescription
data-marlin-checkoutYesMarks the element as a checkout trigger. The SDK binds a click handler automatically.
data-invoice-idOne of theseInvoice ID for a one-time payment.
data-plan-slugOne of thesePlan slug for a subscription.
data-themeNoWidget color theme: light, dark, or auto (default).
You must provide either data-invoice-id or data-plan-slug. Omitting both causes the SDK to throw when the element is clicked.

Staging override

To point the widget at a staging environment, set globalThis.MARLIN_WIDGET_URL before any MarlinCheckout calls. The SDK reads this value at open-time.
// Set this before importing or calling MarlinCheckout
globalThis.MARLIN_WIDGET_URL = "https://staging-widget.marlin.fi";

Widget behavior

The widget closes automatically when the user presses the Escape key or clicks the dark backdrop outside the iframe. Your onClose callback fires in both cases.
ActionResult
Escape keyOverlay fades out, onClose fires
Backdrop click (outside iframe)Overlay fades out, onClose fires
handle.close()Overlay fades out, onClose fires
Successful paymentonSuccess fires, then onClose fires
Widget erroronError fires, then onClose fires