Skip to main content
Version: 1.0.0

Example: Shop checkout

A shop that takes payments with the Hosted Payment plugin needs a server: it prices the order, signs the payment and checks the result ZenPay sends back. Zenith does not host that server for you: this page shows one way to build and run your own.

Run your own checkout on Cloudflare​

The checkout template is a ready-made shop for Cloudflare Workers. It includes:

  • a shop page with a cart that opens the Hosted Payment plugin;
  • a server that prices the cart, signs the payment and checks ZenPay's callback, so the browser never sets the amount;
  • a result page that shows the confirmed status, and looks the payment up at ZenPay when the callback is late;
  • a Turnstile check and rate limits on the checkout.

The Deploy to Cloudflare button copies the template into your GitHub or GitLab account and deploys it to your Cloudflare account. The template's README walks through the remaining steps: your ZenPay credentials, your Turnstile widget and your rate limits.

Install with an AI agent​

Paste this prompt into Claude Code, Codex, Cursor or any other AI coding agent:

Install the ZenPay HPP template (v3) on my Cloudflare account by following the instructions here:
https://raw.githubusercontent.com/ianmenethil/zp-hpp-template-v3/main/.claude/INSTALLER.md

Why the server signs the payment​

The payment amount and your ZenPay credentials must never come from the shopper's browser. The server prices the cart from its own catalogue, creates the fingerprint with credentials only it holds, and hands the browser a signed payment to open the plugin with.

The result works the same way. The shopper's browser returns from the checkout with a status in its address, but the server decides the payment's status only from a callback that passes its checks, or from its own lookup at ZenPay.

Example​

Open the demo shop. It runs this template against the B2BPay sandbox: add a product, pay with a sandbox card, and the result page shows the status the server confirmed.

The routes the shop server answers, one per line:

Shop server routes, labelled
POST /api/v1/checkout ← prices the cart and signs the payment
POST /api/v1/callback?t=… ← ZenPay's callback, with the signed token
PATCH /api/v1/checkout/{payment ID} ← the shopper's return from the checkout
GET /api/v1/checkout/{payment ID} ← the status the result page asks for
GET / ← the shop page

The code sample shows the same steps in their shortest form.