refactor: allow yearly to monthly swaps in BillingController

Drops the abort_if guard that blocked switching from a yearly billing
cadence to monthly. The product decision was reversed — users should
be free to move in either direction without going through support.

Removes the corresponding 'swap blocks yearly to monthly downgrade'
test.
This commit is contained in:
Paulo Castellano 2026-05-07 11:35:36 -03:00
parent dad4ab21c3
commit ff759611b9
2 changed files with 0 additions and 37 deletions

View file

@ -143,16 +143,6 @@ public function swap(Request $request, Plan $plan): RedirectResponse
'Invalid price for this plan',
);
$currentPlan = $account->plan;
$isOnYearly = $currentPlan && $subscription->stripe_price === $currentPlan->stripe_yearly_price_id;
$isTargetMonthly = $priceId === $plan->stripe_monthly_price_id;
abort_if(
$isOnYearly && $isTargetMonthly,
422,
'Cannot downgrade from yearly to monthly billing.',
);
$authorization = Gate::inspect('swapPlan', [$account, $plan]);
if ($authorization->denied()) {

View file

@ -244,33 +244,6 @@
]));
});
test('swap blocks yearly to monthly downgrade', function () {
config(['trypost.self_hosted' => false]);
$plan = Plan::where('slug', 'max')->first();
$plan->update([
'stripe_monthly_price_id' => 'price_monthly',
'stripe_yearly_price_id' => 'price_yearly',
]);
$this->account->update(['plan_id' => $plan->id]);
$this->user->unsetRelation('account');
$this->account->subscriptions()->create([
'type' => Account::SUBSCRIPTION_NAME,
'stripe_id' => 'sub_test_'.fake()->uuid(),
'stripe_status' => 'active',
'stripe_price' => 'price_yearly',
]);
$response = $this->actingAs($this->user)
->post(route('app.billing.swap', $plan), [
'price_id' => 'price_monthly',
]);
$response->assertStatus(422);
});
test('swap rejects invalid price_id for plan', function () {
config(['trypost.self_hosted' => false]);