From 9b9d8072d1e0031826e97f425b3fc46284a0925c Mon Sep 17 00:00:00 2001 From: Steven Fox <62109327+steven-fox@users.noreply.github.com> Date: Thu, 22 May 2025 14:39:45 -0400 Subject: [PATCH] do not create a license upon inactive subscription creation --- app/Jobs/HandleCustomerSubscriptionCreatedJob.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Jobs/HandleCustomerSubscriptionCreatedJob.php b/app/Jobs/HandleCustomerSubscriptionCreatedJob.php index e6634d20..770ebe36 100644 --- a/app/Jobs/HandleCustomerSubscriptionCreatedJob.php +++ b/app/Jobs/HandleCustomerSubscriptionCreatedJob.php @@ -8,6 +8,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\Log; use Laravel\Cashier\Cashier; use Laravel\Cashier\Events\WebhookHandled; use Laravel\Cashier\SubscriptionItem; @@ -29,6 +30,12 @@ public function handle(): void return; } + if ($stripeSubscription->status !== 'active') { + Log::info("The subscription for customer [{$stripeSubscription->customer}] is not active. Not proceeding to license creation."); + + return; + } + /** @var User $user */ $user = Cashier::findBillable($stripeSubscription->customer);