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
Hide post checkout questions for non complete orders
Dave Earley3a702217ec23
diff --git a/backend/app/DomainObjects/OrderDomainObject.php b/backend/app/DomainObjects/OrderDomainObject.phpindex cf05e4044..eb6bdd60e 100644--- a/backend/app/DomainObjects/OrderDomainObject.php+++ b/backend/app/DomainObjects/OrderDomainObject.php@@ -21,6 +21,8 @@ class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements I/** @var Collection<QuestionAndAnswerViewDomainObject>|null */public ?Collection $questionAndAnswerViews = null;+ public ?EventDomainObject $event = null;+public static function getAllowedSorts(): AllowedSorts{return new AllowedSorts(@@ -145,4 +147,15 @@ class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements I{return $this->questionAndAnswerViews;}++ public function setEvent(?EventDomainObject $event): OrderDomainObject+ {+ $this->event = $event;+ return $this;+ }++ public function getEvent(): ?EventDomainObject+ {+ return $this->event;+ }}diff --git a/backend/app/Http/Actions/BaseAction.php b/backend/app/Http/Actions/BaseAction.phpindex c6dbabedf..90e7abecf 100644--- a/backend/app/Http/Actions/BaseAction.php+++ b/backend/app/Http/Actions/BaseAction.php@@ -203,4 +203,9 @@ abstract class BaseAction extends Controller{return QueryParamsDTO::fromArray($request->query->all());}++ public function isIncludeRequested(Request $request, string $include): bool+ {+ return in_array($include, explode(',', $request->query('include', '')), true);+ }}diff --git a/backend/app/Http/Actions/Events/GetEventPublicAction.php b/backend/app/Http/Actions/Events/GetEventPublicAction.phpindex 5918101dc..144720264 100644--- a/backend/app/Http/Actions/Events/GetEventPublicAction.php+++ b/backend/app/Http/Actions/Events/GetEventPublicAction.php@@ -34,6 +34,7 @@ class GetEventPublicAction extends BaseAction$this->logger->debug(__('Event with ID :eventId is not live and user is not authenticated', ['eventId' => $eventId]));+return $this->notFoundResponse();}diff --git a/backend/app/Http/Actions/Orders/GetOrderActionPublic.php b/backend/app/Http/Actions/Orders/GetOrderActionPublic.phpindex a23514a6e..e516dae83 100644--- a/backend/app/Http/Actions/Orders/GetOrderActionPublic.php+++ b/backend/app/Http/Actions/Orders/GetOrderActionPublic.php@@ -2,70 +2,32 @@namespace HiEvents\Http\Actions\Orders;-use HiEvents\DomainObjects\AttendeeDomainObject;-use HiEvents\DomainObjects\OrderItemDomainObject;-use HiEvents\DomainObjects\Status\OrderStatus;-use HiEvents\DomainObjects\TicketDomainObject;-use HiEvents\DomainObjects\TicketPriceDomainObject;-use HiEvents\Exceptions\UnauthorizedException;use HiEvents\Http\Actions\BaseAction;-use HiEvents\Repository\Eloquent\Value\Relationship;-use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Resources\Order\OrderResourcePublic;-use HiEvents\Services\Infrastructure\Session\CheckoutSessionManagementService;+use HiEvents\Services\Handlers\Order\DTO\GetOrderPublicDTO;+use HiEvents\Services\Handlers\Order\GetOrderPublicHandler;use Illuminate\Http\JsonResponse;-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;-use Symfony\Component\Routing\Exception\ResourceNotFoundException;+use Illuminate\Http\Request;class GetOrderActionPublic extends BaseAction{- private OrderRepositoryInterface $orderRepository;-- private CheckoutSessionManagementService $sessionIdentifierService;-- public function __construct(OrderRepositoryInterface $orderRepository, CheckoutSessionManagementService $sessionIdentifierService)- {- $this->orderRepository = $orderRepository;- $this->sessionIdentifierService = $sessionIdentifierService;- }-- public function __invoke(int $eventId, string $orderShortId): JsonResponse+ public function __construct(+ private readonly GetOrderPublicHandler $getOrderPublicHandler+ ){- $order = $this->orderRepository- ->loadRelation(new Relationship(- domainObject: AttendeeDomainObject::class,- nested: [- new Relationship(- domainObject: TicketDomainObject::class,- nested: [- new Relationship(- domainObject: TicketPriceDomainObject::class,- )- ],- name: 'ticket',- )- ],- ))- ->loadRelation(new Relationship(- domainObject: OrderItemDomainObject::class,- ))- ->findByShortId($orderShortId);-- if (!$order) {- throw new ResourceNotFoundException(__('Order not found'));- }-- if ($order->getStatus() === OrderStatus::RESERVED->name) {- $this->verifySessionId($order->getSessionId());- }-- return $this->resourceResponse(OrderResourcePublic::class, $order);}- private function verifySessionId(string $orderSessionId): void+ public function __invoke(int $eventId, string $orderShortId, Request $request): JsonResponse{- if (!$this->sessionIdentifierService->verifySession($orderSessionId)) {- throw new UnauthorizedException(__('Sorry, we could not verify your session. Please restart your order.'));- }+ $order = $this->getOrderPublicHandler->handle(new GetOrderPublicDTO(+ eventId: $eventId,+ orderShortId: $orderShortId,+ includeEventInResponse: $this->isIncludeRequested($request, 'event'),+ ));++ return $this->resourceResponse(+ resource: OrderResourcePublic::class,+ data: $order,+ );}}diff --git a/backend/app/Resources/Event/EventResourcePublic.php b/backend/app/Resources/Event/EventResourcePublic.phpindex cda988b84..d70dc0a10 100644--- a/backend/app/Resources/Event/EventResourcePublic.php+++ b/backend/app/Resources/Event/EventResourcePublic.php@@ -15,6 +15,14 @@ use Illuminate\Http\Request;*/class EventResourcePublic extends BaseResource{+ public function __construct(+ mixed $resource,+ private readonly bool $includePostCheckoutData = false,+ )+ {+ parent::__construct($resource);+ }+public function toArray(Request $request): array{return [@@ -37,7 +45,7 @@ class EventResourcePublic extends BaseResource),'settings' => $this->when(!is_null($this->getEventSettings()),- fn() => new EventSettingsResourcePublic($this->getEventSettings())+ fn() => new EventSettingsResourcePublic($this->getEventSettings(), $this->includePostCheckoutData),),// @TODO - public question resource'questions' => $this->when(diff --git a/backend/app/Resources/Event/EventSettingsResourcePublic.php b/backend/app/Resources/Event/EventSettingsResourcePublic.phpindex 1a2c5cfaf..397a1d2a2 100644--- a/backend/app/Resources/Event/EventSettingsResourcePublic.php+++ b/backend/app/Resources/Event/EventSettingsResourcePublic.php@@ -10,11 +10,24 @@ use Illuminate\Http\Resources\Json\JsonResource;*/class EventSettingsResourcePublic extends JsonResource{+ public function __construct(+ mixed $resource,+ private readonly bool $includePostCheckoutData = false,+ )+ {+ parent::__construct($resource);+ }+public function toArray($request): array{return ['pre_checkout_message' => $this->getPreCheckoutMessage(),- 'post_checkout_message' => $this->getPostCheckoutMessage(),++ $this->mergeWhen($this->includePostCheckoutData, [+ 'post_checkout_message' => $this->getPostCheckoutMessage(),+ 'online_event_connection_details' => $this->getOnlineEventConnectionDetails(),+ ]),+'ticket_page_message' => $this->getTicketPageMessage(),'continue_button_text' => $this->getContinueButtonText(),'required_attendee_details' => $this->getRequireAttendeeDetails(),@@ -35,7 +48,6 @@ class EventSettingsResourcePublic extends JsonResource'location_details' => $this->getLocationDetails(),'is_online_event' => $this->getIsOnlineEvent(),- 'online_event_connection_details' => $this->getOnlineEventConnectionDetails(),'seo_title' => $this->getSeoTitle(),'seo_description' => $this->getSeoDescription(),diff --git a/backend/app/Resources/Order/OrderResourcePublic.php b/backend/app/Resources/Order/OrderResourcePublic.phpindex 5d31b67b1..fbda59e73 100644--- a/backend/app/Resources/Order/OrderResourcePublic.php+++ b/backend/app/Resources/Order/OrderResourcePublic.php@@ -4,8 +4,10 @@ namespace HiEvents\Resources\Order;use Carbon\Carbon;use HiEvents\DomainObjects\OrderDomainObject;+use HiEvents\DomainObjects\Status\OrderStatus;use HiEvents\Resources\Attendee\AttendeeResourcePublic;use HiEvents\Resources\BaseResource;+use HiEvents\Resources\Event\EventResourcePublic;use Illuminate\Http\Request;/**@@ -37,6 +39,13 @@ class OrderResourcePublic extends BaseResource'is_payment_required' => $this->isPaymentRequired(),'promo_code' => $this->getPromoCode(),'taxes_and_fees_rollup' => $this->getTaxesAndFeesRollup(),+ 'event' => $this->when(+ !is_null($this->getEvent()),+ fn() => new EventResourcePublic(+ resource: $this->getEvent(),+ includePostCheckoutData: $this->getStatus() === OrderStatus::COMPLETED->name,+ ),+ ),'address' => $this->when(!is_null($this->getAddress()),fn() => $this->getAddress()diff --git a/backend/app/Services/Handlers/Order/DTO/GetOrderPublicDTO.php b/backend/app/Services/Handlers/Order/DTO/GetOrderPublicDTO.phpnew file mode 100644index 000000000..40216adb3--- /dev/null+++ b/backend/app/Services/Handlers/Order/DTO/GetOrderPublicDTO.php@@ -0,0 +1,16 @@+<?php++namespace HiEvents\Services\Handlers\Order\DTO;++use HiEvents\DataTransferObjects\BaseDTO;++class GetOrderPublicDTO extends BaseDTO+{+ public function __construct(+ public int $eventId,+ public string $orderShortId,+ public bool $includeEventInResponse = false,+ )+ {+ }+}diff --git a/backend/app/Services/Handlers/Order/GetOrderPublicHandler.php b/backend/app/Services/Handlers/Order/GetOrderPublicHandler.phpnew file mode 100644index 000000000..214257aab--- /dev/null+++ b/backend/app/Services/Handlers/Order/GetOrderPublicHandler.php@@ -0,0 +1,90 @@+<?php++namespace HiEvents\Services\Handlers\Order;++use HiEvents\DomainObjects\AttendeeDomainObject;+use HiEvents\DomainObjects\EventDomainObject;+use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\Generated\EventDomainObjectAbstract;+use HiEvents\DomainObjects\Generated\TicketDomainObjectAbstract;+use HiEvents\DomainObjects\OrderDomainObject;+use HiEvents\DomainObjects\OrderItemDomainObject;+use HiEvents\DomainObjects\Status\OrderStatus;+use HiEvents\DomainObjects\TicketDomainObject;+use HiEvents\DomainObjects\TicketPriceDomainObject;+use HiEvents\Exceptions\UnauthorizedException;+use HiEvents\Repository\Eloquent\Value\Relationship;+use HiEvents\Repository\Interfaces\OrderRepositoryInterface;+use HiEvents\Services\Handlers\Order\DTO\GetOrderPublicDTO;+use HiEvents\Services\Infrastructure\Session\CheckoutSessionManagementService;+use Symfony\Component\Routing\Exception\ResourceNotFoundException;++class GetOrderPublicHandler+{+ public function __construct(+ private readonly OrderRepositoryInterface $orderRepository,+ private readonly CheckoutSessionManagementService $sessionIdentifierService+ )+ {+ }++ public function handle(GetOrderPublicDTO $getOrderData): OrderDomainObject+ {+ $order = $this->getOrderDomainObject($getOrderData);++ if (!$order) {+ throw new ResourceNotFoundException(__('Order not found'));+ }++ if ($order->getStatus() === OrderStatus::RESERVED->name) {+ $this->verifySessionId($order->getSessionId());+ }++ return $order;+ }++ private function verifySessionId(string $orderSessionId): void+ {+ if (!$this->sessionIdentifierService->verifySession($orderSessionId)) {+ throw new UnauthorizedException(+ __('Sorry, we could not verify your session. Please restart your order.')+ );+ }+ }++ private function getOrderDomainObject(GetOrderPublicDTO $getOrderData): ?OrderDomainObject+ {+ $orderQuery = $this->orderRepository+ ->loadRelation(new Relationship(+ domainObject: AttendeeDomainObject::class,+ nested: [+ new Relationship(+ domainObject: TicketDomainObject::class,+ nested: [+ new Relationship(+ domainObject: TicketPriceDomainObject::class,+ )+ ],+ name: TicketDomainObjectAbstract::SINGULAR_NAME,+ )+ ],+ ))+ ->loadRelation(new Relationship(+ domainObject: OrderItemDomainObject::class,+ ));++ if ($getOrderData->includeEventInResponse) {+ $orderQuery->loadRelation(new Relationship(+ domainObject: EventDomainObject::class,+ nested: [+ new Relationship(+ domainObject: EventSettingDomainObject::class,+ )+ ],+ name: EventDomainObjectAbstract::SINGULAR_NAME+ ));+ }++ return $orderQuery->findByShortId($getOrderData->orderShortId);+ }+}diff --git a/frontend/src/api/order.client.ts b/frontend/src/api/order.client.tsindex b1a8b63d0..9ee16ec56 100644--- a/frontend/src/api/order.client.ts+++ b/frontend/src/api/order.client.ts@@ -93,8 +93,8 @@ export const orderClientPublic = {return response.data;},- findByShortId: async (eventId: number, orderShortId: string, sessionIdentifier: string) => {- const response = await publicApi.get<GenericDataResponse<Order>>(`events/${eventId}/order/${orderShortId}?session_identifier=${sessionIdentifier}`);+ findByShortId: async (eventId: number, orderShortId: string, includes: string[] = []) => {+ const response = await publicApi.get<GenericDataResponse<Order>>(`events/${eventId}/order/${orderShortId}?include=${includes.join(',')}`);return response.data;},diff --git a/frontend/src/components/routes/ticket-widget/OrderSummaryAndTickets/index.tsx b/frontend/src/components/routes/ticket-widget/OrderSummaryAndTickets/index.tsxindex 8374248ff..4ac67dec4 100644--- a/frontend/src/components/routes/ticket-widget/OrderSummaryAndTickets/index.tsx+++ b/frontend/src/components/routes/ticket-widget/OrderSummaryAndTickets/index.tsx@@ -1,7 +1,6 @@import {t} from "@lingui/macro";import {useGetOrderPublic} from "../../../../queries/useGetOrderPublic.ts";import {useNavigate, useParams} from "react-router-dom";-import {useGetEventPublic} from "../../../../queries/useGetEventPublic.ts";import classes from './OrderSummaryAndTickets.module.scss';import {LoadingMask} from "../../../common/LoadingMask";import {Order, Ticket} from "../../../../types.ts";@@ -33,11 +32,11 @@ const OrderStatus = ({order}: { order: Order }) => {export const OrderSummaryAndTickets = () => {const {eventId, orderShortId} = useParams();- const {data: order, isFetched: orderIsFetched} = useGetOrderPublic(eventId, orderShortId);- const {data: event, isFetched: eventIsFetched} = useGetEventPublic(eventId);+ const {data: order, isFetched: orderIsFetched} = useGetOrderPublic(eventId, orderShortId, ['event']);+ const event = order?.event;const navigate = useNavigate();- if (!orderIsFetched || !eventIsFetched || !order || !event) {+ if (!orderIsFetched || !order || !event) {return <LoadingMask/>;}@@ -135,4 +134,4 @@ export const OrderSummaryAndTickets = () => {);}-export default OrderSummaryAndTickets;\ No newline at end of file+export default OrderSummaryAndTickets;diff --git a/frontend/src/queries/useGetOrderPublic.ts b/frontend/src/queries/useGetOrderPublic.tsindex 0fff331cd..2ae6dc936 100644--- a/frontend/src/queries/useGetOrderPublic.ts+++ b/frontend/src/queries/useGetOrderPublic.ts@@ -1,11 +1,10 @@import {useQuery} from "@tanstack/react-query";import {orderClientPublic} from "../api/order.client.ts";import {IdParam, Order} from "../types.ts";-import {getSessionIdentifier} from "../utilites/sessionIdentifier.ts";export const GET_ORDER_PUBLIC_QUERY_KEY = 'getOrderPublic';-export const useGetOrderPublic = (eventId: IdParam, orderShortId: IdParam) => {+export const useGetOrderPublic = (eventId: IdParam, orderShortId: IdParam, includes: string[] = []) => {return useQuery<Order>({queryKey: [GET_ORDER_PUBLIC_QUERY_KEY, eventId, orderShortId],@@ -13,7 +12,7 @@ export const useGetOrderPublic = (eventId: IdParam, orderShortId: IdParam) => {const {data} = await orderClientPublic.findByShortId(Number(eventId),String(orderShortId),- getSessionIdentifier(),+ includes,);return data;},diff --git a/frontend/src/queries/usePollGetOrderPublic.ts b/frontend/src/queries/usePollGetOrderPublic.tsindex ea84ddd9e..4d24edc2b 100644--- a/frontend/src/queries/usePollGetOrderPublic.ts+++ b/frontend/src/queries/usePollGetOrderPublic.ts@@ -2,7 +2,6 @@ import {useQuery} from "@tanstack/react-query";import {orderClientPublic} from "../api/order.client.ts";import {IdParam, Order} from "../types.ts";import {GET_ORDER_PUBLIC_QUERY_KEY} from "./useGetOrderPublic.ts";-import {getSessionIdentifier} from "../utilites/sessionIdentifier.ts";export const usePollGetOrderPublic = (eventId: IdParam, orderShortId: IdParam, enabled: boolean) => {return useQuery<Order>({@@ -12,7 +11,6 @@ export const usePollGetOrderPublic = (eventId: IdParam, orderShortId: IdParam, econst {data} = await orderClientPublic.findByShortId(Number(eventId),String(orderShortId),- getSessionIdentifier(),);return data;},diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 5648650bf..ce68fe519 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -396,6 +396,7 @@ export interface Order {promo_code_id?: number;taxes_and_fees_rollup?: TaxesAndFeesRollup;question_answers?: QuestionAnswer[];+ event?: Event;}export interface OrderItem {