Sell digital products from a single Cloudflare Worker
The Cloudflare Shop Kit handles checkout, delivery and license keys for e-books, templates, software and time passes. Open source under the MIT license, with building blocks for German and EU legal notices.
What it does
- Checkout with Stripe (including Managed Payments) or Polar, limited to the products in your catalog.
- Webhooks with signature checks and idempotency: every payment is delivered exactly once.
- Downloads from R2 via signed links, valid for 7 days, at most 5 downloads.
- License keys signed with Ed25519, verifiable offline, optionally as time passes with an expiry date.
- Refunds and disputes revoke licenses and downloads automatically.
- Price notes that match the sales channel: § 19 UStG for German small businesses, merchant-of-record notice for Polar and Stripe Managed Payments.
Quickstart
- Unzip, then run
npm ci --ignore-scriptsandnpm test. All provider APIs are mocked; D1 and R2 run in Miniflare. - Describe your product in
catalog.yamland runnpm run catalog. - Create a Cloudflare API token with Workers Scripts, D1 and R2 edit rights, plus a Polar access token (
checkouts:write,products:read) or a Stripe restricted key (Checkout Sessions write). - Run
node scripts/deploy.mjs. It creates D1 and R2, applies migrations, deploys, sets secrets and prints the webhook URL. - Add the webhook in Polar (
order.paid,order.refunded) or Stripe, store its secret, deploy again and link to/buy/<sku>.
The full guide, the architecture and the endpoint list are in README.md inside the ZIP. The German pages cover the Schnellstart, the Architektur and the Rechtsbausteine in more detail.
Legal building blocks
With a merchant of record, the provider sells to the customer, charges VAT and handles withdrawal and refunds; the order page links the provider's buyer terms. For direct sales, the Stripe checkout asks for explicit consent to early performance (§ 356(5) BGB), the consent is stored and confirmed by e-mail (§ 312f BGB). This is not legal advice; have your own texts reviewed.
Verify a license key
The license checker (German) verifies a key in your browser with the shop's public key – the same way your software can do it offline.