From 1258b2c128156e83198f2af504839f963ae41e6a Mon Sep 17 00:00:00 2001 From: Steven Fox <62109327+steven-fox@users.noreply.github.com> Date: Fri, 30 May 2025 09:18:13 -0400 Subject: [PATCH] fix: argument #1 ($plan) must be of type string, null given, in MobilePricing::createCheckoutSession() --- app/Livewire/MobilePricing.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Livewire/MobilePricing.php b/app/Livewire/MobilePricing.php index b90c47e1..7bded0f7 100644 --- a/app/Livewire/MobilePricing.php +++ b/app/Livewire/MobilePricing.php @@ -24,8 +24,15 @@ public function handlePurchaseRequest(array $data) return $this->createCheckoutSession($data['plan'], $user); } - public function createCheckoutSession(string $plan, ?User $user = null) + public function createCheckoutSession(?string $plan, ?User $user = null) { + // This method is somehow getting called without a plan being passed in. + // Not sure how (probably folks hacking or a bot thing), + // but we will just return early when this happens. + if (! $plan) { + return; + } + // If a user isn't passed into this method, Livewire will instantiate // a new User. So we need to check that the user exists before using it, // and then use the authenticated user as a fallback.