Frameworks
HTML
On a site you edit by hand, Plandalf is one script tag and one attribute. Use this page for static sites, site generators and any platform that lets you paste HTML.
Add the script
These are the steps your checkout's Share screen shows for HTML. Copy the snippets from there and they already hold your script address and checkout slug.
Install the SDK
Place the script tag right before </body> on every page that needs the checkout. The SDK is async — it won't block page render.
<script async src="https://YOUR-ORG.plandalf.dev/js/plandalf-sdk.js"></script>Add the trigger button
Drop this on any clickable element — button, link, div, whatever. The SDK auto-binds the click on load (and via MutationObserver for elements added later).
<button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>Make the first open instant (optional)
Paste this under the SDK script tag on the pages that hold the trigger. It fetches the checkout UI (about 1.2 MB) in the background while the page sits idle, so the click only pays for creating the session. Leave it off pages with no checkout: visitors download it whether or not they buy. In a React app, call sdk.preload('checkout') from the ready callback in an effect instead.
<script> // Optional: fetch the checkout UI while the page is idle, so the first click opens at once. window.plandalf = window.plandalf || function () { (window.plandalf.q = window.plandalf.q || []).push(arguments); }; plandalf('ready', (sdk) => sdk.preload('checkout')); </script>
Programmatic alternative: plandalf.present('YOUR-CHECKOUT').
A full page looks like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pricing</title>
</head>
<body>
<button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>
<script async src="https://YOUR-ORG.plandalf.dev/js/plandalf-sdk.js"></script>
</body>
</html>
Open a checkout from a button
Add data-plandalf-present to any button, link or other element, with your checkout's slug as the value:
<button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>
Choose how it opens with data-plandalf-frame (modal, slideout, bottom or fullscreen) and, for a modal, its width with data-plandalf-size. See Buy buttons.
From your own code
Call plandalf.present() from a click handler. It returns a handle you can await for the result:
// Open the checkout from your own click handler
const flow = plandalf.present('YOUR-CHECKOUT');
// flow is a Promise, plus .events (async-iterable) and .close()
const result = await flow;
if (result.status === 'complete') router.push('/thanks');
// Or watch it live instead of awaiting the end:
// for await (const event of flow.events) console.log(event.type);
To call it before the script has loaded, add the queue stub first, and use plandalf('ready', …):
<script>
window.plandalf = window.plandalf || function () { (window.plandalf.q = window.plandalf.q || []).push(arguments); };
plandalf('ready', (sdk) => {
document.querySelector('#upgrade').addEventListener('click', () => sdk.present('YOUR-CHECKOUT'));
});
</script>
There is more in Open a checkout from code.
Show a checkout on the page
Add data-plandalf-mount to an empty element. The checkout renders inside it when the page loads:
<div data-plandalf-mount="YOUR-CHECKOUT" style="min-height: 480px"></div>
Or mount it from code into any container:
// Mount the checkout inline into your own container
const flow = plandalf.mount('#checkout', 'YOUR-CHECKOUT');
// Inline checkouts don't resolve on completion — listen instead:
for await (const event of flow.events) {
if (event.type === 'complete') router.push('/thanks');
}
Show a deadline timer
Add an empty element with your deadline timer's slug. The script draws the live countdown inside it. To charge the deadline timer's current price, add data-plandalf-apply-promo with the same slug to your buy button.
<div data-plandalf-promo="YOUR-PROMO"></div>
<button data-plandalf-present="YOUR-CHECKOUT" data-plandalf-apply-promo="YOUR-PROMO">Buy Now</button>
Add data-plandalf-hide-on-expire to the countdown element to hide it when the countdown ends. See Countdowns.
From a bundler
If you bundle your JavaScript, install the SDK and connect your buy button to it in your entry file.
npm install @plandalf/sdk
<button id="buy">Buy Now</button>
import { Plandalf } from '@plandalf/sdk';
const checkout = new Plandalf({ apiBase: 'https://YOUR-ORG.plandalf.dev' });
document.querySelector('#buy').addEventListener('click', () => {
checkout.present('YOUR-CHECKOUT');
});
Check it's working
Open the page
If you used the hosted script, type
typeof window.plandalfin the browser console. Look for"function".Click your button
Plandalf should display your checkout over the page.
Make a test purchase
Add
localhostand your staging site in Plandalf under Settings → Advanced → Test domains. Checkouts there use Stripe test cards. See Test mode.
If it isn't working
- If your site sends a Content Security Policy, allow
https://*.plandalf.devandhttps://js.stripe.cominscript-src,connect-srcandframe-src. - Add
data-debug="true"to the script tag and the console logs each step the script takes.
See Troubleshooting.
