neuer checkout-pfad: /de/bestellen/paketID und /en/checkout/PackageID

This commit is contained in:
Codex Agent
2025-12-20 16:17:21 +01:00
parent 18297aa3f1
commit 6500b8df2c
18 changed files with 331 additions and 345 deletions

View File

@@ -5,6 +5,8 @@ namespace App\Http\Controllers;
use App\Models\Package;
use App\Models\Tenant;
use App\Models\User;
use App\Support\CheckoutRoutes;
use App\Support\LocaleConfig;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
@@ -42,6 +44,7 @@ class CheckoutGoogleController extends Controller
{
$payload = $request->session()->get(self::SESSION_KEY, []);
$packageId = $payload['package_id'] ?? null;
$locale = $payload['locale'] ?? null;
try {
$googleUser = Socialite::driver('google')->user();
@@ -49,14 +52,14 @@ class CheckoutGoogleController extends Controller
Log::warning('Google checkout login failed', ['message' => $e->getMessage()]);
$this->flashError($request, __('checkout.google_error_fallback'));
return $this->redirectBackToWizard($packageId);
return $this->redirectBackToWizard($packageId, $locale);
}
$email = $googleUser->getEmail();
if (! $email) {
$this->flashError($request, __('checkout.google_missing_email'));
return $this->redirectBackToWizard($packageId);
return $this->redirectBackToWizard($packageId, $locale);
}
$raw = $googleUser->getRaw();
@@ -83,7 +86,7 @@ class CheckoutGoogleController extends Controller
$request->session()->put('checkout_google_status', 'prefill');
return $this->redirectBackToWizard($packageId);
return $this->redirectBackToWizard($packageId, $locale);
}
$user = DB::transaction(function () use ($existing, $googleUser, $email) {
@@ -114,7 +117,7 @@ class CheckoutGoogleController extends Controller
$this->ensurePackageAttached($user, (int) $packageId);
}
return $this->redirectBackToWizard($packageId);
return $this->redirectBackToWizard($packageId, $locale);
}
private function createTenantForUser(User $user, ?string $displayName, string $email): Tenant
@@ -188,19 +191,19 @@ class CheckoutGoogleController extends Controller
]);
}
private function redirectBackToWizard(?int $packageId): RedirectResponse
private function redirectBackToWizard(?int $packageId, ?string $locale = null): RedirectResponse
{
if ($packageId) {
return redirect()->route('purchase.wizard', ['package' => $packageId]);
return redirect()->to(CheckoutRoutes::wizardUrl($packageId, $locale));
}
$firstPackageId = Package::query()->orderBy('price')->value('id');
if ($firstPackageId) {
return redirect()->route('purchase.wizard', ['package' => $firstPackageId]);
return redirect()->to(CheckoutRoutes::wizardUrl($firstPackageId, $locale));
}
return redirect()->route('packages', [
'locale' => app()->getLocale(),
'locale' => LocaleConfig::canonicalize($locale ?? app()->getLocale()),
]);
}