wantsJson()) { return new JsonResponse('', 201); } $plan = $request->input('plan'); // A plan is only required when at least one is configured. Without a // Stripe price there is nothing to sell, so registration still succeeds // and the pricing page explains that no plans are available rather than // making the application impossible to sign up for. if (! is_string($plan) || ! Organization::isAvailablePlan($plan)) { return $this->defaultRedirect($request); } $organization = $request->user()?->currentOrganization()->first(); if ($organization === null) { return $this->defaultRedirect($request); } try { return $organization->checkoutForPlan($plan)->redirect(); } catch (Throwable $e) { // The account already exists by this point, so a Stripe outage must // not turn a completed signup into an error page. Report it and fall // back to the pricing page, where checkout can be retried. report($e); $request->session()->flash( 'billing.checkout_failed', __('Your account was created, but we could not start checkout. Please try again to finish subscribing.'), ); return redirect()->route('pricing'); } } /** * Send the new account to the home route, as Fortify does by default. */ protected function defaultRedirect(Request $request): RedirectResponse { return redirect()->intended(Fortify::redirects('register')); } }