You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 09c0b11
Browse filesBrowse the repository at this point in the historyBrowse files
fix(billing): refuse plan changes during a pro trial (#10520)
* fix(billing): refuse plan changes during a pro trial
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.
* fix(billing): scope the trial guard to personal pro, cover the stripe check
* chore(tests): shrink the test-types baseline for the switch-plan route test
logger.warn('Blocking team upgrade - personal plan is in its free trial',{ userId })
130
-
thrownewAPIError('CONFLICT',{
131
-
message:
132
-
'Your Pro free trial has to end before you can move to a Team plan. End it from Settings > Billing (restore it first if you canceled it), or wait for it to end, then upgrade.',
133
-
})
134
+
logger.warn('Blocking plan change - personal plan is in its free trial',{ userId })
/** Why a plan change is refused during a free trial, and how to get past it. */
139
+
exportconstTRIAL_PLAN_CHANGE_MESSAGE=
140
+
'Your plan can change once your Pro free trial ends. End the trial from Settings > Billing (restore it first if you canceled it), or wait for it to end, then change your plan.'
141
+
136
142
/**
137
143
* Classify a `/subscription/upgrade` request as a personal checkout using
138
144
* the same reference resolution as the Better Auth Stripe plugin
@@ -161,9 +167,8 @@ export function isPersonalCheckoutRequest(
161
167
*
162
168
* Blocks an account AWS Marketplace bills, a bound, incomplete Stripe
163
169
* subscription, a member already covered by an entitled organization
164
-
* subscription, and a Team upgrade of a Pro free trial: Stripe keeps the trial
165
-
* across the price change, so the team would run free without the trial's
166
-
* capped allowance. Throws {@link APIError} with a user-facing message; the
170
+
* subscription, and any plan change during a Pro free trial
171
+
* ({@link assertNoPersonalTrial}). Throws {@link APIError} with a user-facing message; the
167
172
* checkout UI surfaces it as-is.
168
173
*
169
174
* Called from the Better Auth `hooks.before` middleware, NOT from
@@ -174,12 +179,10 @@ export function isPersonalCheckoutRequest(
174
179
* Fails closed: when coverage cannot be determined, the checkout is
175
180
* rejected rather than risking a duplicate subscription.
0 commit comments