Repository navigation
Billing: a cancel during Pro's free trial ends the trial and Pro at once - #249
Merged
Merged
Conversation
Stripe's portal cancels at the period end, which in a trial is the trial's end, so a cancelled trial kept Pro until then. The webhook now sees a trialing GenClass subscription set to cancel by its trial's end (cancel_at with flexible billing, or cancel_at_period_end), cancels it in Stripe right away and writes Free. Paid plans are unchanged: cancelled in the portal, they run to the end of the paid month. The portal's own cancel mode stays at_period_end, because it is one setting for every subscription and "immediately" would end paid plans at once too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
When someone cancels Pro during the 3-day free trial, the trial and Pro now end at once. Before, they ran to the end of the trial.
/account/billing). The site has no cancel button of its own. Account deletion already cancels at once.telemetry-worker/src/stripe.ts). It looks for atrialingGenClass subscription set to cancel by its trial's end:cancel_at≤trial_end(what the portal sets with flexible billing) orcancel_at_period_end: true. It cancels that subscription in Stripe right away, reads it back, and writes Free. Thecustomer.subscription.deletedthat follows writes the same thing and cancels nothing a second time. Nothing was paid, so nothing is refunded. If Stripe fails, the webhook answers 500 and Stripe's retry finishes the job. This covers account subscriptions and version-4 project subscriptions.subscription_cancel.modestaysat_period_end: it is one setting for every subscription, soimmediatelywould end paid plans at once too. A trial set to cancel after a paid month (only possible by hand in the Stripe dashboard) is also left to Stripe.stripe-setup.mjssay the same. Nothing on the CLI needed to change: "Cancel any time" and "nothing is charged if you cancel before the trial ends" are still true.Tests
test/project-plans.test.ts, new block "Pro's trial: a cancel during the 3 free days ends the trial and Pro at once":cancel_at), and withcancel_at_period_end: oneDELETE, account on Free,GET /api/billing/prosays no Pro, no second trial at the next checkoutcustomer.subscription.deleted, aninvoice.paid, and redeliveries: nothing is cancelled twiceDELETE, Pro kept to the period end, "will not renew" line, Free only ondeletedtrialCancelledcases one by one, and the trial line on the billing pageWith the fix turned off, the 5 trial-path tests fail and the 4 others still pass.
cd telemetry-worker && npx vitest run: 32 files, 892 tests pass. The first full run had one flaky failure, inindex.test.ts"a client that goes away cannot cancel ingest", a 5 ms timing check in the collector, not billing. It passed 3 times alone and on the full rerun.tsc --stricton the changed files: no errors.Not done here
immediately) used only when every GenClass subscription on the customer is trialing. That's a Stripe change the owner would have to run withscripts/stripe-setup.mjs.The matching site wording (pricing FAQ and terms) is in a genclass-site PR.
🤖 Generated with Claude Code