Skip to content

Billing: show a pending cancellation and what Free will be - #303

Merged
dillonstreator merged 2 commits into
mainfrom
claude/billing-cycle-cancellation-bab763
Nov 19, 2026
Merged

dillonstreator merged 2 commits into
mainfrom
claude/billing-cycle-cancellation-bab763

Conversation

@dillonstreator

Copy link
Copy Markdown
Member

Why

When a subscription was cancelled by date in Stripe, only cancel_at was set and cancel_at_period_end stayed 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.canceled fired both when a cancellation was scheduled and when the plan ended.

What changed

Cancellation state

  • New billing_subscriptions.cancel_at column. Migration 0061 backfills it for rows already set to cancel at period end.
  • mapSubscription reads cancel_at, or the period end when the flag is set.
  • rowDiffers is the one list of fields that sync and reconcile both compare.
  • pendingCancelAt is the one check for "a cancellation is pending": the paid plan still holds (active, trialing, or past_due inside its grace period). Stripe keeps cancel_at after a subscription ends, so ended, lapsed and complimentary rows don't count as pending.

Events. One per transition:

  • billing.cancel_scheduled with endsAt, also emitted when the date moves;
  • billing.cancel_undone;
  • billing.canceled only when the plan actually ends, with endedAt.

What Free will be. freePreview returns:

  • Free's limits, admin overrides included;
  • where the account would be over them (overages in quota.ts), with what each refuses;
  • the other changes: watermark, download height, manual clips. Each line appears only when it applies.

The same preview feeds:

  • the Billing page: a "Cancels …" chip, a panel with each limit as now → Free, and a "Keep " button that opens the Stripe portal;
  • get_billing (afterCancel);
  • reelsaw billing <email>;
  • two emails: "your plan ends on ", sent once per scheduled cancellation, and "you're on Free now", sent once per subscription.

Shared formatting. packages/shared/src/format.ts now holds plural, pluralWord, formatBytes, formatMb, formatDay and utcDay.

  • Local copies are replaced: eight 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) and toLocaleDateString spellings.
  • test/shared-helpers-guard.test.ts fails on a new local copy or inline spelling, and checks what each helper outputs.
  • The existing helper bullet in docs/PRINCIPLES.md now names this module and the guard.

For reviewers

  • Visible copy changes:

    • sizes are binary units everywhere, so a model download can read 4.4 GB where it used to read 4.7 GB;
    • the CLI and MCP say "1 clip" instead of "clip(s)";
    • server text formats days in English and UTC, while screens use the viewer's locale and time zone.

    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 use billing.cancel_scheduled.

  • Docs: docs/specs/ee.md, README and the get_billing description are updated.

Testing

  • Server and web typecheck clean; pnpm lint has no errors.
  • The billing stack test (stack + Stripe mock) passes 16/16. New cases:
    • a cancellation by date, then taken back;
    • one event per step;
    • an ended subscription shows no pending cancellation.
  • Unit tests: 914/916. The two failures are the detectScenes tests whose shell stand-ins for ffmpeg can't run on Windows. This change doesn't touch them.

…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>
@vercel

vercel Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reelsaw-website Ready Ready Preview Nov 19, 2026 2:02am UTC

Request Review

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>
@dillonstreator
dillonstreator merged commit fe66f45 into main Nov 19, 2026
15 checks passed
@dillonstreator dillonstreator mentioned this pull request Nov 19, 2026
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.

1 participant