Repository navigation
Billing: show a pending cancellation and what Free will be - #303
Merged
Merged
Conversation
…matting helpers A cancellation made by date in Stripe (only `cancel_at` set) was read as a renewal, and the account was told nothing until the plan was gone. - Store `cancel_at`. One `pendingCancelAt` decides when a cancellation is pending; Stripe keeps `cancel_at` after a subscription ends, so an ended or lapsed row no longer reads as pending. - One event per transition: billing.cancel_scheduled, billing.cancel_undone, and billing.canceled only when the plan actually ends. - Billing page, get_billing (`afterCancel`) and `reelsaw billing <email>` show Free's limits, where the account would be over them, what that refuses and what else changes, plus a Keep button that opens the portal. - Mails: "your plan ends on <day>" when scheduled and "you're on Free now" at the end, both built from the same preview. - Generic formatting (plural, pluralWord, formatBytes, formatMb, formatDay, utcDay) lives once in packages/shared/src/format.ts; local copies and inline plural/date spellings are replaced and a guard test fails on new ones. Sizes are binary units throughout. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The README tools table is generated from each tool description's first sentence, so docs:check rewrote the hand-edited row. Say what get_billing returns after a scheduled cancellation in that first sentence instead. Signed-off-by: dillonstreator <dillonstreator@gmail.com>
Open
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.
Why
When a subscription was cancelled by date in Stripe, only
cancel_atwas set andcancel_at_period_endstayed false. Reelsaw read only the flag, so the Billing page said "Renews on …" while Stripe said "Cancels …". Nobody was told the account was about to fall back to Free, or what Free would refuse.A second problem:
billing.canceledfired both when a cancellation was scheduled and when the plan ended.What changed
Cancellation state
billing_subscriptions.cancel_atcolumn. Migration 0061 backfills it for rows already set to cancel at period end.mapSubscriptionreadscancel_at, or the period end when the flag is set.rowDiffersis the one list of fields that sync and reconcile both compare.pendingCancelAtis the one check for "a cancellation is pending": the paid plan still holds (active, trialing, or past_due inside its grace period). Stripe keepscancel_atafter a subscription ends, so ended, lapsed and complimentary rows don't count as pending.Events. One per transition:
billing.cancel_scheduledwithendsAt, also emitted when the date moves;billing.cancel_undone;billing.canceledonly when the plan actually ends, withendedAt.What Free will be.
freePreviewreturns:overagesin quota.ts), with what each refuses;The same preview feeds:
get_billing(afterCancel);reelsaw billing <email>;Shared formatting.
packages/shared/src/format.tsnow holdsplural,pluralWord,formatBytes,formatMb,formatDayandutcDay.plurals, several byte/MB formatters that disagreed with each other, and the local day formatters. So are the inline${n} clip${n === 1 ? "" : "s"},clip(s)andtoLocaleDateStringspellings.test/shared-helpers-guard.test.tsfails on a new local copy or inline spelling, and checks what each helper outputs.For reviewers
Visible copy changes:
The changeset notes all three.
Consumers of
billing.canceled: it no longer fires when a cancellation is scheduled. Anything that listened for that moment should usebilling.cancel_scheduled.Docs: docs/specs/ee.md, README and the
get_billingdescription are updated.Testing
pnpm linthas no errors.detectScenestests whose shell stand-ins for ffmpeg can't run on Windows. This change doesn't touch them.