From 2f621279c2e174678e9a082efb16ffec0b1e525c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 27 May 2024 14:14:31 +0200 Subject: [PATCH] chore: Add null checks for team in Stripe webhook --- app/Http/Controllers/Webhook/Stripe.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Webhook/Stripe.php b/app/Http/Controllers/Webhook/Stripe.php index 87b18c009..200d3dd1c 100644 --- a/app/Http/Controllers/Webhook/Stripe.php +++ b/app/Http/Controllers/Webhook/Stripe.php @@ -170,9 +170,11 @@ public function events(Request $request) $quantity = data_get($data, 'items.data.0.quantity', 10); } $team = data_get($subscription, 'team'); - $team->update([ - 'custom_server_limit' => $quantity, - ]); + if ($team) { + $team->update([ + 'custom_server_limit' => $quantity, + ]); + } ServerLimitCheckJob::dispatch($team); } $subscription->update([ @@ -214,7 +216,9 @@ public function events(Request $request) $customerId = data_get($data, 'customer'); $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail(); $team = data_get($subscription, 'team'); - $team->trialEnded(); + if ($team) { + $team->trialEnded(); + } $subscription->update([ 'stripe_subscription_id' => null, 'stripe_plan_id' => null,