completed addon checkout in mobile event admin

This commit is contained in:
Codex Agent
2025-12-17 17:24:26 +01:00
parent 5f3e7ae8c8
commit ece38fc009
7 changed files with 277 additions and 58 deletions

View File

@@ -5,17 +5,20 @@ namespace App\Services\Addons;
use App\Models\Event;
use App\Models\EventPackageAddon;
use App\Models\Tenant;
use App\Services\Paddle\PaddleCustomerService;
use App\Services\Paddle\PaddleClient;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Throwable;
class EventAddonCheckoutService
{
public function __construct(
private readonly EventAddonCatalog $catalog,
private readonly PaddleClient $paddle,
private readonly PaddleCustomerService $customers,
) {}
/**
@@ -29,6 +32,14 @@ class EventAddonCheckoutService
$acceptedWaiver = (bool) ($payload['accepted_waiver'] ?? false);
$acceptedTerms = (bool) ($payload['accepted_terms'] ?? false);
try {
$customerId = $this->customers->ensureCustomerId($tenant);
} catch (Throwable $exception) {
throw ValidationException::withMessages([
'customer' => __('Konnte Paddle-Kundenkonto nicht anlegen: :message', ['message' => $exception->getMessage()]),
]);
}
if (! $addonKey || ! $this->catalog->find($addonKey)) {
throw ValidationException::withMessages([
'addon_key' => __('Unbekanntes Add-on.'),
@@ -68,7 +79,7 @@ class EventAddonCheckoutService
];
$requestPayload = array_filter([
'customer_id' => $tenant->paddle_customer_id,
'customer_id' => $customerId,
'items' => [
[
'price_id' => $priceId,