Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
Add domain events (Preparation for integrations) (#457)
Dave Earleyafcb4fe39129
diff --git a/backend/app/Http/Request/Webhook/UpsertWebhookRequest.php b/backend/app/Http/Request/Webhook/UpsertWebhookRequest.phpindex b0eb746f0..28aa337aa 100644--- a/backend/app/Http/Request/Webhook/UpsertWebhookRequest.php+++ b/backend/app/Http/Request/Webhook/UpsertWebhookRequest.php@@ -2,9 +2,9 @@namespace HiEvents\Http\Request\Webhook;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Status\WebhookStatus;use HiEvents\Http\Request\BaseRequest;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;use Illuminate\Validation\Rule;class UpsertWebhookRequest extends BaseRequest@@ -13,7 +13,7 @@ class UpsertWebhookRequest extends BaseRequest{return ['url' => 'required|url',- 'event_types.*' => ['required', Rule::in(WebhookEventType::valuesArray())],+ 'event_types.*' => ['required', Rule::in(DomainEventType::valuesArray())],'status' => ['nullable', Rule::in(WebhookStatus::valuesArray())],];}diff --git a/backend/app/Jobs/Order/Webhook/DispatchAttendeeWebhookJob.php b/backend/app/Jobs/Order/Webhook/DispatchAttendeeWebhookJob.phpindex fc885634f..e7c308047 100644--- a/backend/app/Jobs/Order/Webhook/DispatchAttendeeWebhookJob.php+++ b/backend/app/Jobs/Order/Webhook/DispatchAttendeeWebhookJob.php@@ -2,7 +2,7 @@namespace HiEvents\Jobs\Order\Webhook;-use HiEvents\DomainObjects\Enums\WebhookEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Bus\Queueable;use Illuminate\Foundation\Bus\Dispatchable;@@ -14,8 +14,8 @@ class DispatchAttendeeWebhookJobuse Dispatchable, InteractsWithQueue, Queueable, SerializesModels;public function __construct(- public int $attendeeId,- public WebhookEventType $eventType,+ public int $attendeeId,+ public DomainEventType $eventType,){}diff --git a/backend/app/Jobs/Order/Webhook/DispatchCheckInWebhookJob.php b/backend/app/Jobs/Order/Webhook/DispatchCheckInWebhookJob.phpindex db5ce766b..02db36689 100644--- a/backend/app/Jobs/Order/Webhook/DispatchCheckInWebhookJob.php+++ b/backend/app/Jobs/Order/Webhook/DispatchCheckInWebhookJob.php@@ -2,7 +2,7 @@namespace HiEvents\Jobs\Order\Webhook;-use HiEvents\DomainObjects\Enums\WebhookEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Bus\Queueable;use Illuminate\Foundation\Bus\Dispatchable;@@ -14,8 +14,8 @@ class DispatchCheckInWebhookJobuse Dispatchable, InteractsWithQueue, Queueable, SerializesModels;public function __construct(- public int $attendeeCheckInId,- public WebhookEventType $eventType,+ public int $attendeeCheckInId,+ public DomainEventType $eventType,){}diff --git a/backend/app/Jobs/Order/Webhook/DispatchOrderWebhookJob.php b/backend/app/Jobs/Order/Webhook/DispatchOrderWebhookJob.phpindex fa9aa4533..e0bca0737 100644--- a/backend/app/Jobs/Order/Webhook/DispatchOrderWebhookJob.php+++ b/backend/app/Jobs/Order/Webhook/DispatchOrderWebhookJob.php@@ -2,7 +2,7 @@namespace HiEvents\Jobs\Order\Webhook;-use HiEvents\DomainObjects\Enums\WebhookEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Bus\Queueable;use Illuminate\Foundation\Bus\Dispatchable;@@ -14,8 +14,8 @@ class DispatchOrderWebhookJobuse Dispatchable, InteractsWithQueue, Queueable, SerializesModels;public function __construct(- public int $orderId,- public WebhookEventType $eventType,+ public int $orderId,+ public DomainEventType $eventType,){}diff --git a/backend/app/Jobs/Order/Webhook/DispatchProductWebhookJob.php b/backend/app/Jobs/Order/Webhook/DispatchProductWebhookJob.phpindex 12e70eb65..978b877a8 100644--- a/backend/app/Jobs/Order/Webhook/DispatchProductWebhookJob.php+++ b/backend/app/Jobs/Order/Webhook/DispatchProductWebhookJob.php@@ -2,7 +2,7 @@namespace HiEvents\Jobs\Order\Webhook;-use HiEvents\DomainObjects\Enums\WebhookEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Bus\Queueable;use Illuminate\Foundation\Bus\Dispatchable;@@ -14,8 +14,8 @@ class DispatchProductWebhookJobuse Dispatchable, InteractsWithQueue, Queueable, SerializesModels;public function __construct(- public int $productId,- public WebhookEventType $eventType,+ public int $productId,+ public DomainEventType $eventType,){}diff --git a/backend/app/Listeners/Webhook/WebhookEventListener.php b/backend/app/Listeners/Webhook/WebhookEventListener.phpnew file mode 100644index 000000000..c3f93cfd4--- /dev/null+++ b/backend/app/Listeners/Webhook/WebhookEventListener.php@@ -0,0 +1,55 @@+<?php++namespace HiEvents\Listeners\Webhook;++use HiEvents\Jobs\Order\Webhook\DispatchAttendeeWebhookJob;+use HiEvents\Jobs\Order\Webhook\DispatchCheckInWebhookJob;+use HiEvents\Jobs\Order\Webhook\DispatchOrderWebhookJob;+use HiEvents\Jobs\Order\Webhook\DispatchProductWebhookJob;+use HiEvents\Services\Infrastructure\DomainEvents\Events\AttendeeEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\BaseDomainEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\CheckinEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\ProductEvent;+use Illuminate\Config\Repository;++class WebhookEventListener+{+ public function __construct(+ private readonly Repository $config,+ )+ {+ }++ public function handle(BaseDomainEvent $event): void+ {+ $queueName = $this->config->get('queue.webhook_queue_name');++ switch (get_class($event)) {+ case AttendeeEvent::class:+ DispatchAttendeeWebhookJob::dispatch(+ attendeeId: $event->attendeeId,+ eventType: $event->type,+ )->onQueue($queueName);+ break;+ case OrderEvent::class:+ DispatchOrderWebhookJob::dispatch(+ orderId: $event->orderId,+ eventType: $event->type,+ )->onQueue($queueName);+ break;+ case ProductEvent::class:+ DispatchProductWebhookJob::dispatch(+ productId: $event->productId,+ eventType: $event->type,+ )->onQueue($queueName);+ break;+ case CheckinEvent::class:+ DispatchCheckInWebhookJob::dispatch(+ attendeeCheckInId: $event->attendeeCheckinId,+ eventType: $event->type,+ )->onQueue($queueName);+ break;+ }+ }+}diff --git a/backend/app/Providers/EventServiceProvider.php b/backend/app/Providers/EventServiceProvider.phpindex 338991f45..9d94df60a 100644--- a/backend/app/Providers/EventServiceProvider.php+++ b/backend/app/Providers/EventServiceProvider.php@@ -2,20 +2,27 @@namespace HiEvents\Providers;-use Illuminate\Auth\Events\Registered;-use Illuminate\Auth\Listeners\SendEmailVerificationNotification;+use HiEvents\Listeners\Webhook\WebhookEventListener;+use HiEvents\Services\Infrastructure\DomainEvents\Events\AttendeeEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\CheckinEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\ProductEvent;use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;+use Illuminate\Support\Facades\Event;class EventServiceProvider extends ServiceProvider{/**- * The event to listener mappings for the application.+ * Map of listeners to the events they should handle.*- * @var array<class-string, array<int, class-string>>+ * @var array<class-string, array<class-string>>*/- protected $listen = [- Registered::class => [- SendEmailVerificationNotification::class,+ private static array $domainEventMap = [+ WebhookEventListener::class => [+ ProductEvent::class,+ OrderEvent::class,+ AttendeeEvent::class,+ CheckinEvent::class,],];@@ -24,7 +31,19 @@ class EventServiceProvider extends ServiceProvider*/public function boot(): void{- //+ $this->registerDomainEventListeners();+ }++ /**+ * Dynamically register all domain event listeners.+ */+ private function registerDomainEventListeners(): void+ {+ foreach (self::$domainEventMap as $listener => $events) {+ foreach ($events as $event) {+ Event::listen($event, [$listener, 'handle']);+ }+ }}/**diff --git a/backend/app/Repository/Eloquent/BaseRepository.php b/backend/app/Repository/Eloquent/BaseRepository.phpindex b5f0e1a20..0a3364b71 100644--- a/backend/app/Repository/Eloquent/BaseRepository.php+++ b/backend/app/Repository/Eloquent/BaseRepository.php@@ -96,7 +96,7 @@ abstract class BaseRepository implements RepositoryInterfacepublic function simplePaginateWhere(array $where,- int $limit = null,+ ?int $limit = null,array $columns = self::DEFAULT_COLUMNS,): Paginator{@@ -126,7 +126,7 @@ abstract class BaseRepository implements RepositoryInterfacepublic function findFirstByField(string $field,- string $value = null,+ ?string $value = null,array $columns = ['*']): ?DomainObjectInterface{diff --git a/backend/app/Repository/Interfaces/RepositoryInterface.php b/backend/app/Repository/Interfaces/RepositoryInterface.phpindex 0b5930bc7..13783497f 100644--- a/backend/app/Repository/Interfaces/RepositoryInterface.php+++ b/backend/app/Repository/Interfaces/RepositoryInterface.php@@ -71,7 +71,7 @@ interface RepositoryInterface*/public function simplePaginateWhere(array $where,- int $limit = null,+ ?int $limit = null,array $columns = self::DEFAULT_COLUMNS,): Paginator;@@ -129,7 +129,7 @@ interface RepositoryInterface*/public function findFirstByField(string $field,- string $value = null,+ ?string $value = null,array $columns = ['*']): ?DomainObjectInterface;diff --git a/backend/app/Services/Application/Handlers/Attendee/CreateAttendeeHandler.php b/backend/app/Services/Application/Handlers/Attendee/CreateAttendeeHandler.phpindex 8ccd56d59..4ca0d841a 100644--- a/backend/app/Services/Application/Handlers/Attendee/CreateAttendeeHandler.php+++ b/backend/app/Services/Application/Handlers/Attendee/CreateAttendeeHandler.php@@ -5,7 +5,6 @@ namespace HiEvents\Services\Application\Handlers\Attendee;use Brick\Money\Money;use HiEvents\DomainObjects\AttendeeDomainObject;use HiEvents\DomainObjects\Enums\ProductType;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\AttendeeDomainObjectAbstract;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;use HiEvents\DomainObjects\Generated\OrderItemDomainObjectAbstract;@@ -31,7 +30,9 @@ use HiEvents\Services\Application\Handlers\Attendee\DTO\CreateAttendeeTaxAndFeeDuse HiEvents\Services\Domain\Order\OrderManagementService;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;use HiEvents\Services\Domain\Tax\TaxAndFeeRollupService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Database\DatabaseManager;use Illuminate\Support\Collection;use RuntimeException;@@ -49,7 +50,7 @@ class CreateAttendeeHandlerprivate readonly TaxAndFeeRepositoryInterface $taxAndFeeRepository,private readonly TaxAndFeeRollupService $taxAndFeeRollupService,private readonly OrderManagementService $orderManagementService,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -103,7 +104,7 @@ class CreateAttendeeHandler$this->fireEventsAndUpdateQuantities($attendeeDTO, $order);- $this->queueWebhooks($attendee, $order);+ $this->queueWebhooks($order);return $attendee;});@@ -247,11 +248,10 @@ class CreateAttendeeHandler));}- private function queueWebhooks(AttendeeDomainObject $attendee, OrderDomainObject $order): void+ private function queueWebhooks(OrderDomainObject $order): void{- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_CREATED,- orderId: $order->getId(),+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(DomainEventType::ORDER_CREATED, $order->getId()));}}diff --git a/backend/app/Services/Application/Handlers/Attendee/EditAttendeeHandler.php b/backend/app/Services/Application/Handlers/Attendee/EditAttendeeHandler.phpindex 08d197ada..9a714d2a8 100644--- a/backend/app/Services/Application/Handlers/Attendee/EditAttendeeHandler.php+++ b/backend/app/Services/Application/Handlers/Attendee/EditAttendeeHandler.php@@ -4,7 +4,6 @@ namespace HiEvents\Services\Application\Handlers\Attendee;use HiEvents\DomainObjects\AttendeeDomainObject;use HiEvents\DomainObjects\Enums\ProductPriceType;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\AttendeeDomainObjectAbstract;use HiEvents\DomainObjects\Generated\ProductDomainObjectAbstract;use HiEvents\DomainObjects\ProductDomainObject;@@ -14,7 +13,9 @@ use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;use HiEvents\Repository\Interfaces\ProductRepositoryInterface;use HiEvents\Services\Application\Handlers\Attendee\DTO\EditAttendeeDTO;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\AttendeeEvent;use Illuminate\Database\DatabaseManager;use Illuminate\Validation\ValidationException;use Throwable;@@ -26,7 +27,7 @@ class EditAttendeeHandlerprivate readonly ProductRepositoryInterface $productRepository,private readonly ProductQuantityUpdateService $productQuantityService,private readonly DatabaseManager $databaseManager,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -46,9 +47,11 @@ class EditAttendeeHandler$updatedAttendee = $this->updateAttendee($editAttendeeDTO);- $this->webhookDispatchService->queueAttendeeWebhook(- eventType: WebhookEventType::ATTENDEE_UPDATED,- attendeeId: $updatedAttendee->getId(),+ $this->domainEventDispatcherService->dispatch(+ new AttendeeEvent(+ type: DomainEventType::ATTENDEE_UPDATED,+ attendeeId: $updatedAttendee->getId(),+ ));return $updatedAttendee;diff --git a/backend/app/Services/Application/Handlers/Attendee/PartialEditAttendeeHandler.php b/backend/app/Services/Application/Handlers/Attendee/PartialEditAttendeeHandler.phpindex 316899d88..e724b88d3 100644--- a/backend/app/Services/Application/Handlers/Attendee/PartialEditAttendeeHandler.php+++ b/backend/app/Services/Application/Handlers/Attendee/PartialEditAttendeeHandler.php@@ -3,12 +3,13 @@namespace HiEvents\Services\Application\Handlers\Attendee;use HiEvents\DomainObjects\AttendeeDomainObject;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Status\AttendeeStatus;use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;use HiEvents\Services\Application\Handlers\Attendee\DTO\PartialEditAttendeeDTO;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\AttendeeEvent;use Illuminate\Database\DatabaseManager;use Symfony\Component\Routing\Exception\ResourceNotFoundException;use Throwable;@@ -19,7 +20,7 @@ class PartialEditAttendeeHandlerprivate readonly AttendeeRepositoryInterface $attendeeRepository,private readonly ProductQuantityUpdateService $productQuantityService,private readonly DatabaseManager $databaseManager,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -52,9 +53,11 @@ class PartialEditAttendeeHandler}if ($statusIsUpdated && $data->status === AttendeeStatus::CANCELLED->name) {- $this->webhookDispatchService->queueAttendeeWebhook(- eventType: WebhookEventType::ATTENDEE_CANCELLED,- attendeeId: $attendee->getId(),+ $this->domainEventDispatcherService->dispatch(+ new AttendeeEvent(+ type: DomainEventType::ATTENDEE_CANCELLED,+ attendeeId: $attendee->getId(),+ ));}diff --git a/backend/app/Services/Application/Handlers/CheckInList/Public/CreateAttendeeCheckInPublicHandler.php b/backend/app/Services/Application/Handlers/CheckInList/Public/CreateAttendeeCheckInPublicHandler.phpindex 11b6e12f2..74916036c 100644--- a/backend/app/Services/Application/Handlers/CheckInList/Public/CreateAttendeeCheckInPublicHandler.php+++ b/backend/app/Services/Application/Handlers/CheckInList/Public/CreateAttendeeCheckInPublicHandler.php@@ -3,12 +3,13 @@namespace HiEvents\Services\Application\Handlers\CheckInList\Public;use HiEvents\DomainObjects\AttendeeCheckInDomainObject;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\Exceptions\CannotCheckInException;use HiEvents\Services\Application\Handlers\CheckInList\Public\DTO\CreateAttendeeCheckInPublicDTO;use HiEvents\Services\Domain\CheckInList\CreateAttendeeCheckInService;use HiEvents\Services\Domain\CheckInList\DTO\CreateAttendeeCheckInsResponseDTO;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\CheckinEvent;use Psr\Log\LoggerInterface;use Throwable;@@ -17,7 +18,7 @@ class CreateAttendeeCheckInPublicHandlerpublic function __construct(private readonly CreateAttendeeCheckInService $createAttendeeCheckInService,private readonly LoggerInterface $logger,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -42,9 +43,11 @@ class CreateAttendeeCheckInPublicHandler/** @var AttendeeCheckInDomainObject $checkIn */foreach ($checkIns->attendeeCheckIns as $checkIn) {- $this->webhookDispatchService->queueCheckInWebhook(- WebhookEventType::CHECKIN_CREATED,- $checkIn->getId(),+ $this->domainEventDispatcherService->dispatch(+ new CheckinEvent(+ type: DomainEventType::CHECKIN_CREATED,+ attendeeCheckinId: $checkIn->getId(),+ ));}diff --git a/backend/app/Services/Application/Handlers/CheckInList/Public/DeleteAttendeeCheckInPublicHandler.php b/backend/app/Services/Application/Handlers/CheckInList/Public/DeleteAttendeeCheckInPublicHandler.phpindex 09efe0801..569b4c342 100644--- a/backend/app/Services/Application/Handlers/CheckInList/Public/DeleteAttendeeCheckInPublicHandler.php+++ b/backend/app/Services/Application/Handlers/CheckInList/Public/DeleteAttendeeCheckInPublicHandler.php@@ -2,42 +2,51 @@namespace HiEvents\Services\Application\Handlers\CheckInList\Public;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\Exceptions\CannotCheckInException;use HiEvents\Services\Application\Handlers\CheckInList\Public\DTO\DeleteAttendeeCheckInPublicDTO;use HiEvents\Services\Domain\CheckInList\DeleteAttendeeCheckInService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\CheckinEvent;+use Illuminate\Database\DatabaseManager;use Psr\Log\LoggerInterface;+use Throwable;class DeleteAttendeeCheckInPublicHandler{public function __construct(private readonly DeleteAttendeeCheckInService $deleteAttendeeCheckInService,private readonly LoggerInterface $logger,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,+ private readonly DatabaseManager $databaseManager){}/*** @throws CannotCheckInException+ * @throws Throwable*/public function handle(DeleteAttendeeCheckInPublicDTO $checkInData): void{- $deletedCheckInId = $this->deleteAttendeeCheckInService->deleteAttendeeCheckIn(- $checkInData->checkInListShortId,- $checkInData->checkInShortId,- );+ $this->databaseManager->transaction(function () use ($checkInData) {+ $deletedCheckInId = $this->deleteAttendeeCheckInService->deleteAttendeeCheckIn(+ $checkInData->checkInListShortId,+ $checkInData->checkInShortId,+ );- $this->logger->info('Attendee check-in deleted', [- 'check_in_list_uuid' => $checkInData->checkInListShortId,- 'attendee_public_id' => $checkInData->checkInShortId,- 'check_in_user_ip_address' => $checkInData->checkInUserIpAddress,- ]);+ $this->logger->info('Attendee check-in deleted', [+ 'check_in_list_uuid' => $checkInData->checkInListShortId,+ 'attendee_public_id' => $checkInData->checkInShortId,+ 'check_in_user_ip_address' => $checkInData->checkInUserIpAddress,+ ]);- $this->webhookDispatchService->queueCheckInWebhook(- eventType: WebhookEventType::CHECKIN_DELETED,- attendeeCheckInId: $deletedCheckInId,- );+ $this->domainEventDispatcherService->dispatch(+ new CheckinEvent(+ type: DomainEventType::CHECKIN_DELETED,+ attendeeCheckinId: $deletedCheckInId,+ )+ );+ });}}diff --git a/backend/app/Services/Application/Handlers/Order/CancelOrderHandler.php b/backend/app/Services/Application/Handlers/Order/CancelOrderHandler.phpindex 0b30fb8ff..c44af907e 100644--- a/backend/app/Services/Application/Handlers/Order/CancelOrderHandler.php+++ b/backend/app/Services/Application/Handlers/Order/CancelOrderHandler.php@@ -2,14 +2,12 @@namespace HiEvents\Services\Application\Handlers\Order;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;use HiEvents\DomainObjects\OrderDomainObject;use HiEvents\Exceptions\ResourceConflictException;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Application\Handlers\Order\DTO\CancelOrderDTO;use HiEvents\Services\Domain\Order\OrderCancelService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Database\DatabaseManager;use Symfony\Component\Routing\Exception\ResourceNotFoundException;use Throwable;diff --git a/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.php b/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.phpindex b998d84d5..1604f253e 100644--- a/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.php+++ b/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.php@@ -8,7 +8,6 @@ use Carbon\Carbon;use Exception;use HiEvents\DomainObjects\AttendeeDomainObject;use HiEvents\DomainObjects\Enums\ProductType;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\AttendeeDomainObjectAbstract;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;use HiEvents\DomainObjects\Generated\ProductPriceDomainObjectAbstract;@@ -34,7 +33,9 @@ use HiEvents\Services\Application\Handlers\Order\DTO\CreatedProductDataDTO;use HiEvents\Services\Application\Handlers\Order\DTO\OrderQuestionsDTO;use HiEvents\Services\Domain\Payment\Stripe\EventHandlers\PaymentIntentSucceededHandler;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Support\Collection;use Illuminate\Support\Facades\DB;use RuntimeException;@@ -51,7 +52,7 @@ class CompleteOrderHandlerprivate readonly QuestionAnswerRepositoryInterface $questionAnswersRepository,private readonly ProductQuantityUpdateService $productQuantityUpdateService,private readonly ProductPriceRepositoryInterface $productPriceRepository,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -87,9 +88,11 @@ class CompleteOrderHandlerOrderStatusChangedEvent::dispatch($updatedOrder);if ($updatedOrder->isOrderCompleted()) {- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_CREATED,- orderId: $updatedOrder->getId(),+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_CREATED,+ orderId: $updatedOrder->getId(),+ ));}diff --git a/backend/app/Services/Application/Handlers/Order/TransitionOrderToOfflinePaymentHandler.php b/backend/app/Services/Application/Handlers/Order/TransitionOrderToOfflinePaymentHandler.phpindex 1b41da015..b7d577734 100644--- a/backend/app/Services/Application/Handlers/Order/TransitionOrderToOfflinePaymentHandler.php+++ b/backend/app/Services/Application/Handlers/Order/TransitionOrderToOfflinePaymentHandler.php@@ -3,7 +3,6 @@namespace HiEvents\Services\Application\Handlers\Order;use HiEvents\DomainObjects\Enums\PaymentProviders;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\EventSettingDomainObject;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;use HiEvents\DomainObjects\OrderDomainObject;@@ -17,7 +16,9 @@ use HiEvents\Repository\Interfaces\EventSettingsRepositoryInterface;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Application\Handlers\Order\DTO\TransitionOrderToOfflinePaymentPublicDTO;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Database\DatabaseManager;class TransitionOrderToOfflinePaymentHandler@@ -27,7 +28,7 @@ class TransitionOrderToOfflinePaymentHandlerprivate readonly OrderRepositoryInterface $orderRepository,private readonly DatabaseManager $databaseManager,private readonly EventSettingsRepositoryInterface $eventSettingsRepository,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){@@ -62,9 +63,11 @@ class TransitionOrderToOfflinePaymentHandlercreateInvoice: $eventSettings->getEnableInvoicing(),));- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_CREATED,- orderId: $order->getId(),+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_CREATED,+ orderId: $order->getId(),+ ),);return $order;diff --git a/backend/app/Services/Application/Handlers/Product/EditProductHandler.php b/backend/app/Services/Application/Handlers/Product/EditProductHandler.phpindex 5044685ed..d45c9b710 100644--- a/backend/app/Services/Application/Handlers/Product/EditProductHandler.php+++ b/backend/app/Services/Application/Handlers/Product/EditProductHandler.php@@ -5,7 +5,6 @@ declare(strict_types=1);namespace HiEvents\Services\Application\Handlers\Product;use Exception;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Interfaces\DomainObjectInterface;use HiEvents\DomainObjects\ProductDomainObject;use HiEvents\DomainObjects\ProductPriceDomainObject;@@ -14,13 +13,14 @@ use HiEvents\Helper\DateHelper;use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Repository\Interfaces\ProductRepositoryInterface;use HiEvents\Services\Application\Handlers\Product\DTO\UpsertProductDTO;-use HiEvents\Services\Domain\Product\ProductOrderingService;use HiEvents\Services\Domain\Product\ProductPriceUpdateService;use HiEvents\Services\Domain\ProductCategory\GetProductCategoryService;use HiEvents\Services\Domain\Tax\DTO\TaxAndProductAssociateParams;use HiEvents\Services\Domain\Tax\TaxAndProductAssociationService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\ProductEvent;use HiEvents\Services\Infrastructure\HtmlPurifier\HtmlPurifierService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Database\DatabaseManager;use Throwable;@@ -36,9 +36,8 @@ class EditProductHandlerprivate readonly ProductPriceUpdateService $priceUpdateService,private readonly HtmlPurifierService $purifier,private readonly EventRepositoryInterface $eventRepository,- private readonly ProductOrderingService $productOrderingService,private readonly GetProductCategoryService $getProductCategoryService,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -65,9 +64,11 @@ class EditProductHandler$this->eventRepository->findById($productsData->event_id));- $this->webhookDispatchService->queueProductWebhook(- eventType: WebhookEventType::PRODUCT_UPDATED,- productId: $product->getId(),+ $this->domainEventDispatcherService->dispatch(+ new ProductEvent(+ type: DomainEventType::PRODUCT_UPDATED,+ productId: $product->getId(),+ ));return $this->productRepositorydiff --git a/backend/app/Services/Domain/Order/EditOrderService.php b/backend/app/Services/Domain/Order/EditOrderService.phpindex 5bfb41843..186b73dba 100644--- a/backend/app/Services/Domain/Order/EditOrderService.php+++ b/backend/app/Services/Domain/Order/EditOrderService.php@@ -2,19 +2,20 @@namespace HiEvents\Services\Domain\Order;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\OrderDomainObject;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Database\DatabaseManager;use Throwable;class EditOrderService{public function __construct(- private readonly OrderRepositoryInterface $orderRepository,- private readonly WebhookDispatchService $webhookDispatchService,- private readonly DatabaseManager $databaseManager,+ private readonly OrderRepositoryInterface $orderRepository,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,+ private readonly DatabaseManager $databaseManager,){}@@ -43,9 +44,11 @@ class EditOrderService]);- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_UPDATED,- orderId: $id,+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_UPDATED,+ orderId: $id,+ ),);return $this->orderRepository->findById($id);diff --git a/backend/app/Services/Domain/Order/MarkOrderAsPaidService.php b/backend/app/Services/Domain/Order/MarkOrderAsPaidService.phpindex ea5a6bf90..4682d3f2b 100644--- a/backend/app/Services/Domain/Order/MarkOrderAsPaidService.php+++ b/backend/app/Services/Domain/Order/MarkOrderAsPaidService.php@@ -6,7 +6,6 @@ use HiEvents\DomainObjects\AccountConfigurationDomainObject;use HiEvents\DomainObjects\AccountDomainObject;use HiEvents\DomainObjects\AttendeeDomainObject;use HiEvents\DomainObjects\Enums\PaymentProviders;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\EventDomainObject;use HiEvents\DomainObjects\EventSettingDomainObject;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;@@ -27,7 +26,9 @@ use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Repository\Interfaces\InvoiceRepositoryInterface;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Domain\Mail\SendOrderDetailsService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Database\DatabaseManager;use Throwable;@@ -38,7 +39,7 @@ class MarkOrderAsPaidServiceprivate readonly DatabaseManager $databaseManager,private readonly InvoiceRepositoryInterface $invoiceRepository,private readonly AttendeeRepositoryInterface $attendeeRepository,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,private readonly OrderApplicationFeeCalculationService $orderApplicationFeeCalculationService,private readonly EventRepositoryInterface $eventRepository,private readonly OrderApplicationFeeService $orderApplicationFeeService,@@ -88,9 +89,11 @@ class MarkOrderAsPaidServicesendEmails: false));- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_MARKED_AS_PAID,- orderId: $orderId,+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_MARKED_AS_PAID,+ orderId: $orderId,+ ),);$this->storeApplicationFeePayment($updatedOrder);diff --git a/backend/app/Services/Domain/Order/OrderCancelService.php b/backend/app/Services/Domain/Order/OrderCancelService.phpindex 31ffbc305..2c02a40dd 100644--- a/backend/app/Services/Domain/Order/OrderCancelService.php+++ b/backend/app/Services/Domain/Order/OrderCancelService.php@@ -3,7 +3,6 @@namespace HiEvents\Services\Domain\Order;use HiEvents\DomainObjects\AttendeeDomainObject;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\EventSettingDomainObject;use HiEvents\DomainObjects\OrderDomainObject;use HiEvents\DomainObjects\Status\AttendeeStatus;@@ -13,7 +12,9 @@ use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Contracts\Mail\Mailer;use Illuminate\Database\DatabaseManager;use Throwable;@@ -27,7 +28,7 @@ class OrderCancelServiceprivate readonly OrderRepositoryInterface $orderRepository,private readonly DatabaseManager $databaseManager,private readonly ProductQuantityUpdateService $productQuantityService,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -55,9 +56,11 @@ class OrderCancelServiceeventSettings: $event->getEventSettings(),));- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_CANCELLED,- orderId: $order->getId(),+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_CANCELLED,+ orderId: $order->getId(),+ ),);});}diff --git a/backend/app/Services/Domain/Payment/Stripe/EventHandlers/ChargeRefundUpdatedHandler.php b/backend/app/Services/Domain/Payment/Stripe/EventHandlers/ChargeRefundUpdatedHandler.phpindex 5ba5122e6..3aea1ba79 100644--- a/backend/app/Services/Domain/Payment/Stripe/EventHandlers/ChargeRefundUpdatedHandler.php+++ b/backend/app/Services/Domain/Payment/Stripe/EventHandlers/ChargeRefundUpdatedHandler.php@@ -4,7 +4,6 @@ namespace HiEvents\Services\Domain\Payment\Stripe\EventHandlers;use Brick\Money\Money;use HiEvents\DomainObjects\Enums\PaymentProviders;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;use HiEvents\DomainObjects\OrderDomainObject;use HiEvents\DomainObjects\Status\OrderRefundStatus;@@ -12,7 +11,9 @@ use HiEvents\Repository\Interfaces\OrderRefundRepositoryInterface;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Repository\Interfaces\StripePaymentsRepositoryInterface;use HiEvents\Services\Domain\EventStatistics\EventStatisticsUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use HiEvents\Values\MoneyValue;use Illuminate\Database\DatabaseManager;use Illuminate\Log\Logger;@@ -28,7 +29,7 @@ class ChargeRefundUpdatedHandlerprivate readonly DatabaseManager $databaseManager,private readonly EventStatisticsUpdateService $eventStatisticsUpdateService,private readonly OrderRefundRepositoryInterface $orderRefundRepository,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -82,9 +83,11 @@ class ChargeRefundUpdatedHandler'refund_id' => $refund->id,]);- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_REFUNDED,- orderId: $order->getId(),+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_REFUNDED,+ orderId: $order->getId()+ ),);});}@@ -102,9 +105,9 @@ class ChargeRefundUpdatedHandlerprivate function updateOrderRefundedAmount(int $orderId, float $refundedAmount): void{$this->orderRepository->increment(- $orderId,- OrderDomainObjectAbstract::TOTAL_REFUNDED,- $refundedAmount+ id: $orderId,+ column: OrderDomainObjectAbstract::TOTAL_REFUNDED,+ amount: $refundedAmount);}diff --git a/backend/app/Services/Domain/Payment/Stripe/EventHandlers/PaymentIntentSucceededHandler.php b/backend/app/Services/Domain/Payment/Stripe/EventHandlers/PaymentIntentSucceededHandler.phpindex 9a403f0fd..1da220c18 100644--- a/backend/app/Services/Domain/Payment/Stripe/EventHandlers/PaymentIntentSucceededHandler.php+++ b/backend/app/Services/Domain/Payment/Stripe/EventHandlers/PaymentIntentSucceededHandler.php@@ -8,7 +8,6 @@ use Brick\Math\Exception\RoundingNecessaryException;use Brick\Money\Exception\UnknownCurrencyException;use Carbon\Carbon;use HiEvents\DomainObjects\Enums\PaymentProviders;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;use HiEvents\DomainObjects\Generated\StripePaymentDomainObjectAbstract;use HiEvents\DomainObjects\OrderDomainObject;@@ -26,7 +25,9 @@ use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Domain\Order\OrderApplicationFeeService;use HiEvents\Services\Domain\Payment\Stripe\StripeRefundExpiredOrderService;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Cache\Repository;use Illuminate\Database\DatabaseManager;use Psr\Log\LoggerInterface;@@ -45,7 +46,7 @@ class PaymentIntentSucceededHandlerprivate readonly DatabaseManager $databaseManager,private readonly LoggerInterface $logger,private readonly Repository $cache,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,private readonly OrderApplicationFeeService $orderApplicationFeeService,){@@ -92,9 +93,11 @@ class PaymentIntentSucceededHandlerOrderStatusChangedEvent::dispatch($updatedOrder);- $this->webhookDispatchService->queueOrderWebhook(- eventType: WebhookEventType::ORDER_CREATED,- orderId: $updatedOrder->getId(),+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_CREATED,+ orderId: $updatedOrder->getId()+ ),);$this->markPaymentIntentAsHandled($paymentIntent, $updatedOrder);diff --git a/backend/app/Services/Domain/Product/CreateProductService.php b/backend/app/Services/Domain/Product/CreateProductService.phpindex 6a79f73ea..2f5179613 100644--- a/backend/app/Services/Domain/Product/CreateProductService.php+++ b/backend/app/Services/Domain/Product/CreateProductService.php@@ -3,15 +3,16 @@namespace HiEvents\Services\Domain\Product;use Exception;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\ProductDomainObject;use HiEvents\Helper\DateHelper;use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Repository\Interfaces\ProductRepositoryInterface;use HiEvents\Services\Domain\Tax\DTO\TaxAndProductAssociateParams;use HiEvents\Services\Domain\Tax\TaxAndProductAssociationService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\ProductEvent;use HiEvents\Services\Infrastructure\HtmlPurifier\HtmlPurifierService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Database\DatabaseManager;use Illuminate\Support\Collection;use Throwable;@@ -26,7 +27,7 @@ class CreateProductServiceprivate readonly HtmlPurifierService $purifier,private readonly EventRepositoryInterface $eventRepository,private readonly ProductOrderingService $productOrderingService,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -49,9 +50,11 @@ class CreateProductService$product = $this->createProductPrices($persistedProduct, $product);- $this->webhookDispatchService->queueProductWebhook(- eventType: WebhookEventType::PRODUCT_CREATED,- productId: $product->getId(),+ $this->domainEventDispatcherService->dispatch(+ new ProductEvent(+ type: DomainEventType::PRODUCT_CREATED,+ productId: $product->getId(),+ ));return $product;diff --git a/backend/app/Services/Domain/Product/DeleteProductService.php b/backend/app/Services/Domain/Product/DeleteProductService.phpindex ffdd285a4..091b94118 100644--- a/backend/app/Services/Domain/Product/DeleteProductService.php+++ b/backend/app/Services/Domain/Product/DeleteProductService.php@@ -2,13 +2,14 @@namespace HiEvents\Services\Domain\Product;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\Generated\ProductDomainObjectAbstract;use HiEvents\DomainObjects\Generated\ProductPriceDomainObjectAbstract;use HiEvents\Exceptions\CannotDeleteEntityException;use HiEvents\Repository\Interfaces\ProductPriceRepositoryInterface;use HiEvents\Repository\Interfaces\ProductRepositoryInterface;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\ProductEvent;use Illuminate\Database\DatabaseManager;use Psr\Log\LoggerInterface;use Throwable;@@ -20,7 +21,7 @@ class DeleteProductServiceprivate readonly ProductPriceRepositoryInterface $productPriceRepository,private readonly LoggerInterface $logger,private readonly DatabaseManager $databaseManager,- private readonly WebhookDispatchService $webhookDispatchService,+ private readonly DomainEventDispatcherService $domainEventDispatcherService,){}@@ -52,9 +53,11 @@ class DeleteProductService);});- $this->webhookDispatchService->queueProductWebhook(- eventType: WebhookEventType::PRODUCT_DELETED,- productId: $productId,+ $this->domainEventDispatcherService->dispatch(+ new ProductEvent(+ type: DomainEventType::PRODUCT_DELETED,+ productId: $productId,+ ));$this->logger->info(diff --git a/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.php b/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.phpnew file mode 100644index 000000000..5c833d861--- /dev/null+++ b/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.php@@ -0,0 +1,18 @@+<?php++namespace HiEvents\Services\Infrastructure\DomainEvents;++use HiEvents\Services\Infrastructure\DomainEvents\Events\BaseDomainEvent;+use Illuminate\Events\Dispatcher as EventDispatcher;++class DomainEventDispatcherService+{+ public function __construct(private readonly EventDispatcher $dispatcher)+ {+ }++ public function dispatch(BaseDomainEvent $event): void+ {+ $this->dispatcher->dispatch($event);+ }+}diff --git a/backend/app/DomainObjects/Enums/WebhookEventType.php b/backend/app/Services/Infrastructure/DomainEvents/Enums/DomainEventType.phpsimilarity index 82%rename from backend/app/DomainObjects/Enums/WebhookEventType.phprename to backend/app/Services/Infrastructure/DomainEvents/Enums/DomainEventType.phpindex 2526d3562..dbaf38aec 100644--- a/backend/app/DomainObjects/Enums/WebhookEventType.php+++ b/backend/app/Services/Infrastructure/DomainEvents/Enums/DomainEventType.php@@ -1,8 +1,10 @@<?php-namespace HiEvents\DomainObjects\Enums;+namespace HiEvents\Services\Infrastructure\DomainEvents\Enums;-enum WebhookEventType: string+use HiEvents\DomainObjects\Enums\BaseEnum;++enum DomainEventType: string{use BaseEnum;diff --git a/backend/app/Services/Infrastructure/DomainEvents/Events/AttendeeEvent.php b/backend/app/Services/Infrastructure/DomainEvents/Events/AttendeeEvent.phpnew file mode 100644index 000000000..abea0146e--- /dev/null+++ b/backend/app/Services/Infrastructure/DomainEvents/Events/AttendeeEvent.php@@ -0,0 +1,15 @@+<?php++namespace HiEvents\Services\Infrastructure\DomainEvents\Events;++use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;++class AttendeeEvent extends BaseDomainEvent+{+ public function __construct(+ public DomainEventType $type,+ public int $attendeeId,+ )+ {+ }+}diff --git a/backend/app/Services/Infrastructure/DomainEvents/Events/BaseDomainEvent.php b/backend/app/Services/Infrastructure/DomainEvents/Events/BaseDomainEvent.phpnew file mode 100644index 000000000..6d323a07f--- /dev/null+++ b/backend/app/Services/Infrastructure/DomainEvents/Events/BaseDomainEvent.php@@ -0,0 +1,10 @@+<?php++namespace HiEvents\Services\Infrastructure\DomainEvents\Events;++use Illuminate\Foundation\Events\Dispatchable;++abstract class BaseDomainEvent+{+ use Dispatchable;+}diff --git a/backend/app/Services/Infrastructure/DomainEvents/Events/CheckinEvent.php b/backend/app/Services/Infrastructure/DomainEvents/Events/CheckinEvent.phpnew file mode 100644index 000000000..3e30542e2--- /dev/null+++ b/backend/app/Services/Infrastructure/DomainEvents/Events/CheckinEvent.php@@ -0,0 +1,15 @@+<?php++namespace HiEvents\Services\Infrastructure\DomainEvents\Events;++use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;++class CheckinEvent extends BaseDomainEvent+{+ public function __construct(+ public DomainEventType $type,+ public int $attendeeCheckinId,+ )+ {+ }+}diff --git a/backend/app/Services/Infrastructure/DomainEvents/Events/OrderEvent.php b/backend/app/Services/Infrastructure/DomainEvents/Events/OrderEvent.phpnew file mode 100644index 000000000..fc7d21e9d--- /dev/null+++ b/backend/app/Services/Infrastructure/DomainEvents/Events/OrderEvent.php@@ -0,0 +1,15 @@+<?php++namespace HiEvents\Services\Infrastructure\DomainEvents\Events;++use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;++class OrderEvent extends BaseDomainEvent+{+ public function __construct(+ public DomainEventType $type,+ public int $orderId,+ )+ {+ }+}diff --git a/backend/app/Services/Infrastructure/DomainEvents/Events/ProductEvent.php b/backend/app/Services/Infrastructure/DomainEvents/Events/ProductEvent.phpnew file mode 100644index 000000000..92d89f88c--- /dev/null+++ b/backend/app/Services/Infrastructure/DomainEvents/Events/ProductEvent.php@@ -0,0 +1,15 @@+<?php++namespace HiEvents\Services\Infrastructure\DomainEvents\Events;++use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;++class ProductEvent extends BaseDomainEvent+{+ public function __construct(+ public DomainEventType $type,+ public int $productId,+ )+ {+ }+}diff --git a/backend/app/Services/Infrastructure/Webhook/WebhookDispatchService.php b/backend/app/Services/Infrastructure/Webhook/WebhookDispatchService.phpindex 150454ade..5790c015c 100644--- a/backend/app/Services/Infrastructure/Webhook/WebhookDispatchService.php+++ b/backend/app/Services/Infrastructure/Webhook/WebhookDispatchService.php@@ -3,17 +3,12 @@namespace HiEvents\Services\Infrastructure\Webhook;use HiEvents\DomainObjects\AttendeeDomainObject;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\OrderItemDomainObject;use HiEvents\DomainObjects\ProductPriceDomainObject;use HiEvents\DomainObjects\QuestionAndAnswerViewDomainObject;use HiEvents\DomainObjects\Status\WebhookStatus;use HiEvents\DomainObjects\TaxAndFeesDomainObject;use HiEvents\DomainObjects\WebhookDomainObject;-use HiEvents\Jobs\Order\Webhook\DispatchAttendeeWebhookJob;-use HiEvents\Jobs\Order\Webhook\DispatchCheckInWebhookJob;-use HiEvents\Jobs\Order\Webhook\DispatchOrderWebhookJob;-use HiEvents\Jobs\Order\Webhook\DispatchProductWebhookJob;use HiEvents\Repository\Eloquent\Value\Relationship;use HiEvents\Repository\Interfaces\AttendeeCheckInRepositoryInterface;use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;@@ -24,7 +19,7 @@ use HiEvents\Resources\Attendee\AttendeeResource;use HiEvents\Resources\CheckInList\AttendeeCheckInResource;use HiEvents\Resources\Order\OrderResource;use HiEvents\Resources\Product\ProductResource;-use Illuminate\Config\Repository;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;use Illuminate\Http\Resources\Json\JsonResource;use Illuminate\Support\Collection;use Psr\Log\LoggerInterface;@@ -39,44 +34,11 @@ class WebhookDispatchServiceprivate readonly ProductRepositoryInterface $productRepository,private readonly AttendeeRepositoryInterface $attendeeRepository,private readonly AttendeeCheckInRepositoryInterface $attendeeCheckInRepository,- private readonly Repository $config,){}- public function queueOrderWebhook(WebhookEventType $eventType, int $orderId): void- {- DispatchOrderWebhookJob::dispatch(- orderId: $orderId,- eventType: $eventType,- )->onQueue($this->config->get('queue.webhook_queue_name'));- }-- public function queueProductWebhook(WebhookEventType $eventType, int $productId): void- {- DispatchProductWebhookJob::dispatch(- productId: $productId,- eventType: $eventType,- )->onQueue($this->config->get('queue.webhook_queue_name'));- }-- public function queueCheckInWebhook(WebhookEventType $eventType, int $attendeeCheckInId): void- {- DispatchCheckInWebhookJob::dispatch(- attendeeCheckInId: $attendeeCheckInId,- eventType: $eventType,- )->onQueue($this->config->get('queue.webhook_queue_name'));- }-- public function queueAttendeeWebhook(WebhookEventType $eventType, int $attendeeId): void- {- DispatchAttendeeWebhookJob::dispatch(- attendeeId: $attendeeId,- eventType: $eventType,- )->onQueue($this->config->get('queue.webhook_queue_name'));- }-- public function dispatchAttendeeWebhook(WebhookEventType $eventType, int $attendeeId): void+ public function dispatchAttendeeWebhook(DomainEventType $eventType, int $attendeeId): void{$attendee = $this->attendeeRepository->loadRelation(new Relationship(@@ -92,7 +54,7 @@ class WebhookDispatchService);}- public function dispatchCheckInWebhook(WebhookEventType $eventType, int $attendeeCheckInId): void+ public function dispatchCheckInWebhook(DomainEventType $eventType, int $attendeeCheckInId): void{$attendeeCheckIn = $this->attendeeCheckInRepository->loadRelation(new Relationship(@@ -109,7 +71,7 @@ class WebhookDispatchService);}- public function dispatchProductWebhook(WebhookEventType $eventType, int $productId): void+ public function dispatchProductWebhook(DomainEventType $eventType, int $productId): void{$product = $this->productRepository->loadRelation(ProductPriceDomainObject::class)@@ -124,7 +86,7 @@ class WebhookDispatchService);}- public function dispatchOrderWebhook(WebhookEventType $eventType, int $orderId): void+ public function dispatchOrderWebhook(DomainEventType $eventType, int $orderId): void{$order = $this->orderRepository->loadRelation(OrderItemDomainObject::class)@@ -141,21 +103,21 @@ class WebhookDispatchService->loadRelation(QuestionAndAnswerViewDomainObject::class)->findById($orderId);- if ($eventType === WebhookEventType::ORDER_CREATED) {+ if ($eventType === DomainEventType::ORDER_CREATED) {/** @var AttendeeDomainObject $attendee */foreach ($order->getAttendees() as $attendee) {- $this->queueAttendeeWebhook(- eventType: WebhookEventType::ATTENDEE_CREATED,+ $this->dispatchAttendeeWebhook(+ eventType: DomainEventType::ATTENDEE_CREATED,attendeeId: $attendee->getId(),);}}- if ($eventType === WebhookEventType::ORDER_CANCELLED) {+ if ($eventType === DomainEventType::ORDER_CANCELLED) {/** @var AttendeeDomainObject $attendee */foreach ($order->getAttendees() as $attendee) {- $this->queueAttendeeWebhook(- eventType: WebhookEventType::ATTENDEE_CANCELLED,+ $this->dispatchAttendeeWebhook(+ eventType: DomainEventType::ATTENDEE_CANCELLED,attendeeId: $attendee->getId(),);}@@ -168,7 +130,7 @@ class WebhookDispatchService);}- private function dispatchWebhook(WebhookEventType $eventType, JsonResource $payload, int $eventId): void+ private function dispatchWebhook(DomainEventType $eventType, JsonResource $payload, int $eventId): void{/** @var Collection<WebhookDomainObject> $webhooks */$webhooks = $this->webhookRepository->findWhere([diff --git a/backend/config/queue.php b/backend/config/queue.phpindex c4260ae98..52622994f 100644--- a/backend/config/queue.php+++ b/backend/config/queue.php@@ -65,7 +65,7 @@ return ['queue' => env('SQS_QUEUE', 'default'),'suffix' => env('SQS_SUFFIX'),'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),- 'after_commit' => false,+ 'after_commit' => true,],'redis' => [diff --git a/backend/tests/Unit/Services/Application/Handlers/Order/CompleteOrderHandlerTest.php b/backend/tests/Unit/Services/Application/Handlers/Order/CompleteOrderHandlerTest.phpindex d65f42255..9d003d89e 100644--- a/backend/tests/Unit/Services/Application/Handlers/Order/CompleteOrderHandlerTest.php+++ b/backend/tests/Unit/Services/Application/Handlers/Order/CompleteOrderHandlerTest.php@@ -5,7 +5,6 @@ namespace Tests\Unit\Services\Application\Handlers\Order;use Carbon\Carbon;use Exception;use HiEvents\DomainObjects\AttendeeDomainObject;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\OrderDomainObject;use HiEvents\DomainObjects\OrderItemDomainObject;use HiEvents\DomainObjects\ProductPriceDomainObject;@@ -20,7 +19,10 @@ use HiEvents\Services\Application\Handlers\Order\DTO\CompleteOrderDTO;use HiEvents\Services\Application\Handlers\Order\DTO\CompleteOrderOrderDTO;use HiEvents\Services\Application\Handlers\Order\DTO\CompleteOrderProductDataDTO;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;-use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\BaseDomainEvent;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use Illuminate\Database\Connection;use Illuminate\Support\Collection;use Illuminate\Support\Facades\Bus;@@ -40,7 +42,7 @@ class CompleteOrderHandlerTest extends TestCaseprivate ProductQuantityUpdateService|MockInterface $productQuantityUpdateService;private ProductPriceRepositoryInterface|MockInterface $productPriceRepository;private CompleteOrderHandler $completeOrderHandler;- private WebhookDispatchService $webhookDispatchService;+ private DomainEventDispatcherService $domainEventDispatcherService;protected function setUp(): void{@@ -55,7 +57,7 @@ class CompleteOrderHandlerTest extends TestCase$this->questionAnswersRepository = Mockery::mock(QuestionAnswerRepositoryInterface::class);$this->productQuantityUpdateService = Mockery::mock(ProductQuantityUpdateService::class);$this->productPriceRepository = Mockery::mock(ProductPriceRepositoryInterface::class);- $this->webhookDispatchService = Mockery::mock(WebhookDispatchService::class);+ $this->domainEventDispatcherService = Mockery::mock(DomainEventDispatcherService::class);$this->completeOrderHandler = new CompleteOrderHandler($this->orderRepository,@@ -63,7 +65,7 @@ class CompleteOrderHandlerTest extends TestCase$this->questionAnswersRepository,$this->productQuantityUpdateService,$this->productPriceRepository,- $this->webhookDispatchService+ $this->domainEventDispatcherService);}@@ -164,8 +166,11 @@ class CompleteOrderHandlerTest extends TestCase$this->productQuantityUpdateService->shouldReceive('updateQuantitiesFromOrder')->once();- $this->webhookDispatchService->shouldReceive('queueOrderWebhook')- ->with(WebhookEventType::ORDER_CREATED, $updatedOrder->getId())+ $this->domainEventDispatcherService->shouldReceive('dispatch')+ ->withArgs(function (OrderEvent $event) use ($order) {+ return $event->type === DomainEventType::ORDER_CREATED+ && $event->orderId === $order->getId();+ })->once();$order = $this->completeOrderHandler->handle($orderShortId, $orderData);@@ -252,10 +257,10 @@ class CompleteOrderHandlerTest extends TestCase);$attendeeDTO = new CompleteOrderProductDataDTO(+ product_price_id: 1,first_name: 'John',last_name: 'Doe',- email: '[email protected]',- product_price_id: 1+ email: '[email protected]');return new CompleteOrderDTO(diff --git a/backend/tests/Unit/Services/Domain/Order/OrderCancelServiceTest.php b/backend/tests/Unit/Services/Domain/Order/OrderCancelServiceTest.phpindex 4f1f93bbb..d40e0313a 100644--- a/backend/tests/Unit/Services/Domain/Order/OrderCancelServiceTest.php+++ b/backend/tests/Unit/Services/Domain/Order/OrderCancelServiceTest.php@@ -3,7 +3,6 @@namespace Tests\Unit\Services\Domain\Order;use HiEvents\DomainObjects\AttendeeDomainObject;-use HiEvents\DomainObjects\Enums\WebhookEventType;use HiEvents\DomainObjects\EventDomainObject;use HiEvents\DomainObjects\EventSettingDomainObject;use HiEvents\DomainObjects\OrderDomainObject;@@ -14,6 +13,9 @@ use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Domain\Order\OrderCancelService;use HiEvents\Services\Domain\Product\ProductQuantityUpdateService;+use HiEvents\Services\Infrastructure\DomainEvents\DomainEventDispatcherService;+use HiEvents\Services\Infrastructure\DomainEvents\Enums\DomainEventType;+use HiEvents\Services\Infrastructure\DomainEvents\Events\OrderEvent;use HiEvents\Services\Infrastructure\Webhook\WebhookDispatchService;use Illuminate\Contracts\Mail\Mailer;use Illuminate\Database\DatabaseManager;@@ -31,7 +33,7 @@ class OrderCancelServiceTest extends TestCaseprivate DatabaseManager $databaseManager;private ProductQuantityUpdateService $productQuantityService;private OrderCancelService $service;- private WebhookDispatchService $webhookDispatchService;+ private DomainEventDispatcherService $domainEventDispatcherService;protected function setUp(): void{@@ -43,7 +45,7 @@ class OrderCancelServiceTest extends TestCase$this->orderRepository = m::mock(OrderRepositoryInterface::class);$this->databaseManager = m::mock(DatabaseManager::class);$this->productQuantityService = m::mock(ProductQuantityUpdateService::class);- $this->webhookDispatchService = m::mock(WebhookDispatchService::class);+ $this->domainEventDispatcherService = m::mock(DomainEventDispatcherService::class);$this->service = new OrderCancelService(mailer: $this->mailer,@@ -52,7 +54,7 @@ class OrderCancelServiceTest extends TestCaseorderRepository: $this->orderRepository,databaseManager: $this->databaseManager,productQuantityService: $this->productQuantityService,- webhookDispatchService: $this->webhookDispatchService,+ domainEventDispatcherService: $this->domainEventDispatcherService,);}@@ -105,8 +107,11 @@ class OrderCancelServiceTest extends TestCasereturn $mail instanceof OrderCancelled;});- $this->webhookDispatchService->shouldReceive('queueOrderWebhook')- ->with(WebhookEventType::ORDER_CANCELLED, 1)+ $this->domainEventDispatcherService->shouldReceive('dispatch')+ ->withArgs(function (OrderEvent $event) use ($order) {+ return $event->type === DomainEventType::ORDER_CANCELLED+ && $event->orderId === $order->getId();+ })->once();$this->databaseManager->shouldReceive('transaction')->once()->andReturnUsing(function ($callback) {diff --git a/frontend/src/components/modals/WebhookLogsModal/index.tsx b/frontend/src/components/modals/WebhookLogsModal/index.tsxindex d43b9c6b0..979a78f12 100644--- a/frontend/src/components/modals/WebhookLogsModal/index.tsx+++ b/frontend/src/components/modals/WebhookLogsModal/index.tsx@@ -183,11 +183,11 @@ export const WebhookLogsModal = ({onClose, webhookId}: WebhookLogsModalProps) =>)}{logs && logs.length > 0 && (- <Stack gap="md">+ <>{logs.map((log) => (<LogEntry key={log.id} log={log}/>))}- </Stack>+ </>)}</Modal>);