From 83f9e69eede4eb1c2a9aee1c293d92f6e2a8ca10 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Thu, 14 May 2026 19:46:34 -0300 Subject: [PATCH] feat(billing): surface generic trial state on billing settings + 7d default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BillingController::index reads onTrial from Account::isOnTrial() (covers generic trial without a Stripe subscription) and falls back to account.trial_ends_at when no subscription exists. Vue page already had the badge + 'Trial ends' UI wired — just needed the right props. - Drop default trial_days from 8 to 7 for consistency with messaging. --- app/Http/Controllers/App/BillingController.php | 4 ++-- config/cashier.php | 2 +- tests/Feature/Auth/TrialOnSignupTest.php | 4 ++-- tests/Feature/Middleware/TrialMiddlewareAccessTest.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/App/BillingController.php b/app/Http/Controllers/App/BillingController.php index d955b6ea..07eda978 100644 --- a/app/Http/Controllers/App/BillingController.php +++ b/app/Http/Controllers/App/BillingController.php @@ -138,8 +138,8 @@ public function index(Request $request): Response|RedirectResponse return Inertia::render('settings/account/Billing', [ 'hasSubscription' => $account->subscribed(Account::SUBSCRIPTION_NAME), - 'onTrial' => $subscription?->onTrial() ?? false, - 'trialEndsAt' => $subscription?->trial_ends_at, + 'onTrial' => $account->isOnTrial(), + 'trialEndsAt' => $subscription?->trial_ends_at ?? $account->trial_ends_at, 'subscription' => $subscription?->only([ 'stripe_status', 'ends_at', diff --git a/config/cashier.php b/config/cashier.php index 44c30230..ed1ff73b 100644 --- a/config/cashier.php +++ b/config/cashier.php @@ -135,6 +135,6 @@ | */ - 'trial_days' => env('CASHIER_TRIAL_DAYS', 8), + 'trial_days' => env('CASHIER_TRIAL_DAYS', 7), ]; diff --git a/tests/Feature/Auth/TrialOnSignupTest.php b/tests/Feature/Auth/TrialOnSignupTest.php index c3a7ebc2..f47434a0 100644 --- a/tests/Feature/Auth/TrialOnSignupTest.php +++ b/tests/Feature/Auth/TrialOnSignupTest.php @@ -27,7 +27,7 @@ $starterPlan = Plan::where('slug', Slug::Starter)->firstOrFail(); expect($user->account->plan_id)->toBe($starterPlan->id); - expect($user->account->trial_ends_at?->toDateTimeString())->toBe('2026-05-22 12:00:00'); + expect($user->account->trial_ends_at?->toDateTimeString())->toBe('2026-05-21 12:00:00'); expect($user->account->stripe_id)->toBeNull(); }); @@ -57,7 +57,7 @@ 'registration_ip' => '127.0.0.1', ]); - Carbon::setTestNow('2026-05-22 12:01:00'); + Carbon::setTestNow('2026-05-21 12:01:00'); expect($user->account->fresh()->isOnTrial())->toBeFalse(); }); diff --git a/tests/Feature/Middleware/TrialMiddlewareAccessTest.php b/tests/Feature/Middleware/TrialMiddlewareAccessTest.php index 1ecee913..2f3f2b27 100644 --- a/tests/Feature/Middleware/TrialMiddlewareAccessTest.php +++ b/tests/Feature/Middleware/TrialMiddlewareAccessTest.php @@ -54,7 +54,7 @@ $workspace->members()->attach($user->id, ['role' => Role::Member->value]); $user->update(['current_workspace_id' => $workspace->id]); - Carbon::setTestNow('2026-05-22 12:01:00'); + Carbon::setTestNow('2026-05-21 12:01:00'); $response = $this->actingAs($user->fresh())->get(route('app.accounts'));