Skip to content

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.

@snizu/app-bridgeCheckout3 min read

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:

snizu.app.json
{
  "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
      }
    ]
  }
}
  • handlestringrequired
    Up to 40 lower-case letters, digits and dashes, unique in the version.
  • namestringrequired
    What merchants see when placing it, 1 to 60 characters.
  • urlurlrequired
    The page the frame opens: HTTPS, or http://localhost while developing.
  • targetsstring[]required
    Where merchants may place it: checkout.contact, checkout.delivery, checkout.payment, checkout.summary, thank_you or order_status.
  • heightnumber
    The 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

block.ts
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}` },
});
  • initPromise
    The first message: target, locale, direction, store (its name), and cart while paying or order after.
  • onUpdate(listener)
    Called with every later init, 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; null clears 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:

client_secretyour app's
HMAC-SHA256of "snizu checkout block token v1"
hexthe HS256 key
  • typcheckout_block
    A 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.
  • targetstring
    Where it was shown.
  • audstring
    Your app's client ID.
  • nbf, exp, iatseconds
    Valid for five minutes.
  • jtistring
    Unique to each token, so you can refuse a replay.
lib/verify.js
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