Skip to content

fix(billing): refuse plan changes during a pro trial - #10520

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/trial-switch-cap-reset
Nov 30, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/trial-switch-cap-reset

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • A Pro trial's fixed allowance is checked against the current billing period's usage. Switching monthly↔yearly restarts Stripe's period, so each switch reset the trial's spend to zero and the cap started over.
  • POST /api/billing/switch-plan now refuses any tier or interval change while the subscription is trialing (409). It checks the DB row before claiming admission, and checks Stripe's status after retrieving the subscription in case the row lags.
  • assertPersonalCheckoutAllowed now refuses every personal /subscription/upgrade during a Pro trial, not only Team upgrades, so the plugin's update path can't change the price either. The unused plan parameter is gone.
  • Trial users are told to end the trial (Settings > Billing) or wait for it, then change plan.

Tests

  • switch-plan/route.test.ts: a tier change and an interval change during a trial both get 409, and Stripe is never touched. Red on the pre-fix route.
  • trial.integration.ts: a personal checkout during a trial is refused with CONFLICT. Red on the pre-fix guard.

A trial's fixed allowance is counted per billing period, and a price change
restarts Stripe's period, so switching monthly/yearly during a trial started
the cap over each time. Refuse switch-plan (checked against the row and
Stripe) and any personal /subscription/upgrade while a Pro trial runs.
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Nov 30, 2026 7:23pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Blocks personal plan changes during a Pro trial so switching billing intervals cannot restart the trial allowance.

  • Pro trial plan switches now stop before changing the price.
  • Personal checkout now checks for a Pro trial whatever plan is requested.

No new actionable issues found. Tests were reviewed but not run.

Reviews (2) · Last reviewed commit: "fix(billing): scope the trial guard to p..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/billing/authorization.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 09c0b11 into staging Nov 30, 2026
85 checks passed

This branch was successfully deployed

1 active deployment
Preview — 2e9a7469 Deployed Nov 30, 2026 by vercel[bot]
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