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
Fix ticket widget not working in Firefox and Safari
Dave Earleydabbb16faff2
diff --git a/backend/app/DomainObjects/OrderDomainObject.php b/backend/app/DomainObjects/OrderDomainObject.phpindex 9a5baed0f..5782dd2af 100644--- a/backend/app/DomainObjects/OrderDomainObject.php+++ b/backend/app/DomainObjects/OrderDomainObject.php@@ -29,6 +29,8 @@ class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements Ipublic ?EventDomainObject $event = null;+ public ?string $sessionIdentifier = null;+public static function getAllowedFilterFields(): array{return [@@ -253,4 +255,15 @@ class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements I{return $this->invoices;}++ public function setSessionIdentifier(?string $sessionIdentifier): OrderDomainObject+ {+ $this->sessionIdentifier = $sessionIdentifier;+ return $this;+ }++ public function getSessionIdentifier(): ?string+ {+ return $this->sessionIdentifier;+ }}diff --git a/backend/app/Http/Actions/Orders/Public/CreateOrderActionPublic.php b/backend/app/Http/Actions/Orders/Public/CreateOrderActionPublic.phpindex bf024a9df..9f0f48fde 100644--- a/backend/app/Http/Actions/Orders/Public/CreateOrderActionPublic.php+++ b/backend/app/Http/Actions/Orders/Public/CreateOrderActionPublic.php@@ -48,10 +48,12 @@ class CreateOrderActionPublic extends BaseAction]));+ $order->setSessionIdentifier($sessionId);+$response = $this->resourceResponse(resource: OrderResourcePublic::class,data: $order,- statusCode: ResponseCodes::HTTP_CREATED+ statusCode: ResponseCodes::HTTP_CREATED,);return $response->withCookie(diff --git a/backend/app/Http/Actions/Orders/Public/GetOrderActionPublic.php b/backend/app/Http/Actions/Orders/Public/GetOrderActionPublic.phpindex 01b7e0e92..ff8133af4 100644--- a/backend/app/Http/Actions/Orders/Public/GetOrderActionPublic.php+++ b/backend/app/Http/Actions/Orders/Public/GetOrderActionPublic.php@@ -6,13 +6,15 @@ use HiEvents\Http\Actions\BaseAction;use HiEvents\Resources\Order\OrderResourcePublic;use HiEvents\Services\Application\Handlers\Order\DTO\GetOrderPublicDTO;use HiEvents\Services\Application\Handlers\Order\GetOrderPublicHandler;+use HiEvents\Services\Infrastructure\Session\CheckoutSessionManagementService;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;class GetOrderActionPublic extends BaseAction{public function __construct(- private readonly GetOrderPublicHandler $getOrderPublicHandler+ private readonly GetOrderPublicHandler $getOrderPublicHandler,+ private readonly CheckoutSessionManagementService $sessionService,){}@@ -25,9 +27,17 @@ class GetOrderActionPublic extends BaseActionincludeEventInResponse: $this->isIncludeRequested($request, 'event'),));- return $this->resourceResponse(+ $response = $this->resourceResponse(resource: OrderResourcePublic::class,data: $order,);++ if ($request->query->has('session_identifier')) {+ $response->headers->setCookie(+ $this->sessionService->getSessionCookie()+ );+ }++ return $response;}}diff --git a/backend/app/Resources/Order/OrderResourcePublic.php b/backend/app/Resources/Order/OrderResourcePublic.phpindex 4654c5092..7880d22ed 100644--- a/backend/app/Resources/Order/OrderResourcePublic.php+++ b/backend/app/Resources/Order/OrderResourcePublic.php@@ -8,7 +8,6 @@ use HiEvents\DomainObjects\Status\OrderStatus;use HiEvents\Resources\Attendee\AttendeeResourcePublic;use HiEvents\Resources\BaseResource;use HiEvents\Resources\Event\EventResourcePublic;-use HiEvents\Resources\Order\Invoice\InvoiceResource;use HiEvents\Resources\Order\Invoice\InvoiceResourcePublic;use Illuminate\Http\Request;@@ -64,6 +63,9 @@ class OrderResourcePublic extends BaseResource!is_null($this->getAttendees()),fn() => AttendeeResourcePublic::collection($this->getAttendees())),+ $this->mergeWhen($this->getSessionIdentifier() !== null, fn() => [+ 'session_identifier' => $this->getSessionIdentifier(),+ ]),];}}diff --git a/backend/app/Services/Infrastructure/Session/CheckoutSessionManagementService.php b/backend/app/Services/Infrastructure/Session/CheckoutSessionManagementService.phpindex 792067f84..d7552ac84 100644--- a/backend/app/Services/Infrastructure/Session/CheckoutSessionManagementService.php+++ b/backend/app/Services/Infrastructure/Session/CheckoutSessionManagementService.php@@ -22,7 +22,7 @@ class CheckoutSessionManagementService}/**- * Get the session ID from the cookie, or generate a new one if it doesn't exist.+ * Get the session ID from query param, cookie, or generate a new one.*/public function getSessionId(): string{@@ -30,7 +30,9 @@ class CheckoutSessionManagementServicereturn $this->sessionId;}- $this->sessionId = $this->request->cookie(self::SESSION_IDENTIFIER) ?? $this->createSessionId();+ $this->sessionId = $this->request->query(self::SESSION_IDENTIFIER)+ ?? $this->request->cookie(self::SESSION_IDENTIFIER)+ ?? $this->createSessionId();return $this->sessionId;}diff --git a/frontend/src/api/order.client.ts b/frontend/src/api/order.client.tsindex eb80c8001..8d9ed1c24 100644--- a/frontend/src/api/order.client.ts+++ b/frontend/src/api/order.client.ts@@ -116,8 +116,24 @@ export const orderClientPublic = {return response.data;},- findByShortId: async (eventId: number, orderShortId: string, includes: string[] = []) => {- const response = await publicApi.get<GenericDataResponse<Order>>(`events/${eventId}/order/${orderShortId}?include=${includes.join(',')}`);+ findByShortId: async (+ eventId: number,+ orderShortId: string,+ includes: string[] = [],+ sessionIdentifier?: string+ ) => {+ const query = new URLSearchParams();+ if (includes.length > 0) {+ query.append("include", includes.join(","));+ }+ if (sessionIdentifier) {+ query.append("session_identifier", sessionIdentifier);+ }++ const response = await publicApi.get<GenericDataResponse<Order>>(+ `events/${eventId}/order/${orderShortId}?${query.toString()}`+ );+return response.data;},diff --git a/frontend/src/components/routes/product-widget/SelectProducts/index.tsx b/frontend/src/components/routes/product-widget/SelectProducts/index.tsxindex 8f6d74aa6..44d3c3265 100644--- a/frontend/src/components/routes/product-widget/SelectProducts/index.tsx+++ b/frontend/src/components/routes/product-widget/SelectProducts/index.tsx@@ -103,7 +103,10 @@ const SelectProducts = (props: SelectProductsProps) => {.then(() => {const url = '/checkout/' + eventId + '/' + data.data.short_id + '/details';if (props.widgetMode === 'embedded') {- window.open(url, '_blank');+ window.open(+ url + '?session_identifier=' + data.data.session_identifier + '&utm_source=embedded_widget',+ '_blank'+ );setOrderInProcessOverlayVisible(true);return;}diff --git a/frontend/src/queries/useGetOrderPublic.ts b/frontend/src/queries/useGetOrderPublic.tsindex c098c917e..77dfb1285 100644--- a/frontend/src/queries/useGetOrderPublic.ts+++ b/frontend/src/queries/useGetOrderPublic.ts@@ -1,25 +1,44 @@import {useQuery} from "@tanstack/react-query";import {orderClientPublic} from "../api/order.client.ts";import {IdParam, Order} from "../types.ts";+import {useMemo} from "react";+import {isSsr} from "../utilites/helpers.ts";-export const GET_ORDER_PUBLIC_QUERY_KEY = 'getOrderPublic';+export const GET_ORDER_PUBLIC_QUERY_KEY = "getOrderPublic";-export const useGetOrderPublic = (eventId: IdParam, orderShortId: IdParam, includes: string[] = []) => {- return useQuery<Order>({- queryKey: [GET_ORDER_PUBLIC_QUERY_KEY, eventId, orderShortId],+const getSessionIdentifierFromUrl = (): string | null => {+ if (isSsr()) return null;++ const url = new URL(window.location.href);+ return url.searchParams.get("session_identifier");+};++export const useGetOrderPublic = (+ eventId: IdParam,+ orderShortId: IdParam,+ includes: string[] = []+) => {+ const sessionIdentifier = useMemo(getSessionIdentifierFromUrl, []);+ return useQuery<Order>({+ queryKey: [+ GET_ORDER_PUBLIC_QUERY_KEY,+ eventId,+ orderShortId,+ sessionIdentifier,+ ],queryFn: async () => {const {data} = await orderClientPublic.findByShortId(Number(eventId),String(orderShortId),includes,+ sessionIdentifier ?? undefined);return data;},-refetchOnWindowFocus: false,staleTime: 500,retryOnMount: false,- retry: false+ retry: false,});-}+};diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 1d851bf82..9ed8652cf 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -475,6 +475,7 @@ export interface Order {question_answers?: QuestionAnswer[];event?: Event;latest_invoice?: Invoice;+ session_identifier?: string;}export interface Invoice {