Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

refactor: allow yearly to monthly swaps in BillingController

Paulo Castellanoff759611b951
diff --git a/app/Http/Controllers/App/BillingController.php b/app/Http/Controllers/App/BillingController.php
index 67836c766..3926bac56 100644
--- a/app/Http/Controllers/App/BillingController.php
+++ b/app/Http/Controllers/App/BillingController.php
@@ -143,16 +143,6 @@ class BillingController extends Controller
'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()) {
diff --git a/tests/Feature/BillingControllerTest.php b/tests/Feature/BillingControllerTest.php
index 003f1772f..78be2a607 100644
--- a/tests/Feature/BillingControllerTest.php
+++ b/tests/Feature/BillingControllerTest.php
@@ -244,33 +244,6 @@ test('swap blocks downgrade when usage exceeds target plan limits', function ()
]));
});
-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]);