Skip to content

Hosted billing: purchase confirmation email, an archive of each terms version, and fuller consent records - #1561

Merged
nedtwigg merged 10 commits into
mainfrom
billing-confirmation
Nov 5, 2026
Merged

nedtwigg merged 10 commits into
mainfrom
billing-confirmation

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Part of the billing release gate, #1074. Billing still ships closed. A buyer got only Stripe's receipt and a /billing page that goes away with the plan, and only a version string recorded what they agreed to.

  • Purchase confirmation email. A new purchase notice, recorded in the webhook's transaction when a checkout completes and sent after the commit to the Stripe customer's email, so a provider-only account gets it. One per subscription, so a redelivery sends nothing; the cron retries an unsent one. It carries the seller, plan, USD price and interval, renewal, the terms version and when it was agreed, cancellation, refunds, limits, and the withdrawal right with the model form. Its price comes from the consent row, not the current catalog.

  • Each terms version keeps its text. Checked-in static files at https://dormouse.sh/terms/<version>/ and /privacy/<version>/, linked from the checkout, /billing, and the email. website/src/pages/policy-archive.test.tsx fails if TERMS_VERSION moves without its file, if a file differs from what the page renders, or if a published file changes.

  • Consent evidence. dormouse_checkout_consents also keeps the shown price, the daily voice cap, and the text presented, all derived on the server. The strings live in hosted/server/disclosure.ts, which the page renders too.

  • A real price check, and each disclosure line asserted. Checkout shows a plain "$50 a year", by the owner's decision: the Terms say the prices are in US dollars, and Release gate: Hosted billing must fulfill the subscription terms #1074's "USD price" box rests on that. expectPrice compared the page with published constants only, so a Price set up at another amount in Stripe would have been charged. stripeHoldsPrice now checks amount, currency, interval, and mode against Stripe; a mismatch or failed read expires the checkout and answers 503 CHECKOUT_UNAVAILABLE.

  • Hosted/Emails in Storybook. A story for every email Hosted sends, showing headers, HTML, and plain text, so Argos snapshots what the recipient sees. A new notice kind fails to compile until it has a story, and workers.test.ts holds the sign-in email's fixture to what is sent. TESTING_AND_MODIFICATION_GUIDE.md carries the rule. A notice's text moved to notice-message.ts so a browser can bundle it.

  • Notices really come from support. postmarkEmail sends the address it is built with and ignores a message's from, so every notice would have gone out from [email protected], against the README. Notices now use a sender built with [email protected], which must be verified in Postmark before launch.

Migrations 026 and 027. The website must deploy before or with Hosted, or the checkout's terms link 404s. A privacy-only edit now forces a new TERMS_VERSION, since both pages share one date.

pnpm test:hosted (357), tsc, spec lint, and website tests (465) pass on the fakes, with new tests mutation-checked; the root pnpm test was not run locally. Not yet run against real Stripe or Postmark: the email has not been delivered, and prices.retrieve is proven only against the fake. A sandbox retest follows.

For legal review: the email goes to every buyer, as the checkout's disclosure does, and its withdrawal paragraph says "within 14 days of buying" where the Terms say "after the contract is made".

🤖 Generated with Claude Code

nedtwigg and others added 5 commits November 3, 2026 13:03
Checkout and the billing confirmation link the agreed version's archive.
Moving TERMS_VERSION without its files, or changing a policy's text
without moving it, fails a test; published files are pinned by hash.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…given to

The disclosure lines move to one module the page renders and the consent
row keeps, with the shown price and the voice cap, all derived on the
server. Assertions pin the refund, limits, and withdrawal lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e page

expectPrice compares the page with the catalog, and the catalog's amounts
come from the published prices, so nothing compared them with Stripe. A
wrong configured amount would have been charged. Checkout now reads the
Price it opened at and expires the checkout unless Stripe holds it at that
amount, in USD, at the plan's interval and in this deployment's mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A billing notice recorded in the webhook's transaction when a checkout
completes, one per subscription, sent after the commit and retried by the
cron until sent. It repeats the consent's plan, price, and terms version,
with the seller, renewal, cancellation, refunds, limits, and the EEA and UK
withdrawal right and model form from the strings the page shows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 48c816b
Status: ✅  Deploy successful!
Preview URL: https://2e7c205e.mouseterm.pages.dev
Branch Preview URL: https://billing-confirmation.mouseterm.pages.dev

View logs

Hosted/Emails gives each billing notice and the sign-in code a story, so each
gets a snapshot of what its recipient sees. A billing notice's text moves to
notice-message.ts, which a browser can bundle. A new notice kind fails to
compile until it has a story, and the sign-in email's fixture is held to what
the Worker sends. The stories show the real From: postmarkEmail sends
EMAIL_FROM, whatever a message names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`postmarkEmail` sends the address it is built with and ignores a message's
`from`, so every notice would have gone out from [email protected]. Notices
now go by a sender built with the support address, which the README already
requires verifying in Postmark; sign-in mail keeps EMAIL_FROM.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Terms version 2026-11-03 takes its own archive beside 2026-10-30.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Terms say the prices are in US dollars.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nedtwigg
nedtwigg merged commit fde784c into main Nov 5, 2026
19 checks passed
@nedtwigg
nedtwigg deleted the billing-confirmation branch November 5, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants