emit('error', 'Price ID not found! Please contact the administrator.'); return; } $payload = [ 'client_reference_id' => auth()->user()->id . ':' . currentTeam()->id, 'line_items' => [[ 'price' => $priceId, 'quantity' => 1, ]], 'tax_id_collection' => [ 'enabled' => true, ], 'mode' => 'subscription', 'success_url' => route('subscription.success'), 'cancel_url' => route('subscription.show',['cancelled' => true]), ]; $customer = currentTeam()->subscription?->stripe_customer_id ?? null; if ($customer) { $payload['customer'] = $customer; $payload['customer_update'] = [ 'name' => 'auto' ]; } else { $payload['customer_email'] = auth()->user()->email; } $session = Session::create($payload); return redirect($session->url, 303); } }