Embed
JavaScript API
Open checkout from your own code and listen for payment events.
The embed script exposes window.Stakk.
Load
<script src="https://stakk.cc/embed.js"></script>Methods
<script>
Stakk.init({ shopId: "your-shop" });
Stakk.open({
shopId: "your-shop",
productId: "PRODUCT_ID",
quantity: 1,
coupon: "SAVE10",
email: "buyer@example.com",
gateway: "BITCOIN",
fields: { username: "alex" },
});
</script>| Method | Description |
|---|---|
Stakk.init({ shopId, checkoutBaseUrl }) | Set defaults. Called automatically on load |
Stakk.open(options) | Open checkout for one product |
Stakk.addItem(item) | Push a product onto the embed cart |
Stakk.checkout(options) | Open checkout from the cart |
Stakk.close() | Close the modal |
Stakk.getItems() | Current cart lines |
Stakk.getItemCount() | Cart line count |
open / checkout options: shopId, productId, quantity, variantId, coupon, email, gateway, theme, locale, affiliate, returnUrl, fields.
Events
<script>
document.addEventListener("stakk:ready", () => {
console.log("Checkout opened");
});
document.addEventListener("stakk:success", (event) => {
console.log("Paid", event.detail);
});
document.addEventListener("stakk:close", () => {
console.log("Closed");
});
</script>stakk:success fires after a paid order. stakk:ready fires when the modal opens. stakk:close fires when it closes.