Checkout blocks
Your app's page inside the store's hosted checkout, the thank-you page or an order's page. It hears about the cart without personal data, keeps a value on the order, and proves to your backend where it was shown.
Declare it
A block is a page of your app that merchants place in the checkout, from the places you allow. Declare it in your manifest:
{
"manifest": {
"checkout_blocks": [
{
"handle": "gift-wrap-note",
"name": "Gift wrap note",
"url": "https://gift-wrap.example.com/checkout-block",
"targets": ["checkout.delivery", "thank_you"],
"height": 120
}
]
}
}handlestringrequiredUp to 40 lower-case letters, digits and dashes, unique in the version.namestringrequiredWhat merchants see when placing it, 1 to 60 characters.urlurlrequiredThe page the frame opens: HTTPS, orhttp://localhostwhile developing.targetsstring[]requiredWhere merchants may place it:checkout.contact,checkout.delivery,checkout.payment,checkout.summary,thank_youororder_status.heightnumberThe frame's height until the block resizes it, 40 to 600 pixels. 120 by default.
An app version declares up to 10 blocks.
Talk to the checkout
import { createCheckoutBlock } from "@snizu/app-bridge/checkout";
const block = createCheckoutBlock();
block.autoResize();
const { target, locale, direction, cart, order } = await block.init;
render(cart ?? order);
// Again whenever the cart changes.
block.onUpdate((next) => render(next.cart ?? next.order));
// Kept on the cart as app.<your app>.gift_wrap,
// and on the order like a checkout field.
await block.setAttribute("gift_wrap", "yes");
const token = await block.getSessionToken();
await fetch("/api/checkout-block", {
headers: { authorization: `Bearer ${token}` },
});initPromiseThe first message:target,locale,direction,store(its name), andcartwhile paying ororderafter.onUpdate(listener)Called with every laterinit, when the cart changes. Returns a function that stops it.resize(height?)Sets the frame's height, 0 to 1,200 pixels; the page's own height by default.autoResize()Keeps the frame as tall as the page. Returns a function that stops it.setAttribute(key, value)Keeps a value on the cart: up to 10 keys of 500 characters;nullclears one. Only while paying.getSessionToken()A token for your backend about this cart or order and place.destroy()Stops listening to the checkout.
The cart and order come without personal data: their lines, totals, currency and the country they go to, and an order's name. No name, email, phone or street.
A block that says nothing within ten seconds is put away, so a slow app never stops a shopper paying.
Verify its token
A shopper holds the block's token, so it's never signed with your client secret itself. Its key is made from it:
typcheckout_blockA checkout block's token. An admin session token never passes as one, and the other way round.deststore_…The store.subcart_… | ord_…The cart or order it was shown for.targetstringWhere it was shown.audstringYour app's client ID.nbf, exp, iatsecondsValid for five minutes.jtistringUnique to each token, so you can refuse a replay.
export function verifyCheckoutToken(token, secret, clientId, now = Date.now() / 1000) {
const key = createHmac("sha256", secret)
.update("snizu checkout block token v1")
.digest("hex");
return verifyToken(token, key, clientId, "checkout_block", now);
}verifyToken is the same as for embedded pages. The app snizu app create writes has both, with tests, and a GET /api/checkout-block route that uses this one.
Was this page helpful?
Updated 25 Nov 2026