Skip to content

Commit 009127d

Browse files
authored
Merge branch 'main' into develop
2 parents dad3c5d + 35a2372 commit 009127d

File tree

9 files changed

+16
-84
lines changed

9 files changed

+16
-84
lines changed

backend/app/DomainObjects/OrderDomainObject.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class OrderDomainObject extends Generated\OrderDomainObjectAbstract implements I
2929

3030
public ?EventDomainObject $event = null;
3131

32-
public ?string $sessionIdentifier = null;
33-
3432
public static function getAllowedFilterFields(): array
3533
{
3634
return [
@@ -255,15 +253,4 @@ public function getInvoices(): ?Collection
255253
{
256254
return $this->invoices;
257255
}
258-
259-
public function setSessionIdentifier(?string $sessionIdentifier): OrderDomainObject
260-
{
261-
$this->sessionIdentifier = $sessionIdentifier;
262-
return $this;
263-
}
264-
265-
public function getSessionIdentifier(): ?string
266-
{
267-
return $this->sessionIdentifier;
268-
}
269256
}

backend/app/Http/Actions/Orders/Public/CreateOrderActionPublic.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ public function __invoke(CreateOrderRequest $request, int $eventId): JsonRespons
4848
])
4949
);
5050

51-
$order->setSessionIdentifier($sessionId);
52-
5351
$response = $this->resourceResponse(
5452
resource: OrderResourcePublic::class,
5553
data: $order,
56-
statusCode: ResponseCodes::HTTP_CREATED,
54+
statusCode: ResponseCodes::HTTP_CREATED
5755
);
5856

5957
return $response->withCookie(

backend/app/Http/Actions/Orders/Public/GetOrderActionPublic.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66
use HiEvents\Resources\Order\OrderResourcePublic;
77
use HiEvents\Services\Application\Handlers\Order\DTO\GetOrderPublicDTO;
88
use HiEvents\Services\Application\Handlers\Order\GetOrderPublicHandler;
9-
use HiEvents\Services\Infrastructure\Session\CheckoutSessionManagementService;
109
use Illuminate\Http\JsonResponse;
1110
use Illuminate\Http\Request;
1211

1312
class GetOrderActionPublic extends BaseAction
1413
{
1514
public function __construct(
16-
private readonly GetOrderPublicHandler $getOrderPublicHandler,
17-
private readonly CheckoutSessionManagementService $sessionService,
15+
private readonly GetOrderPublicHandler $getOrderPublicHandler
1816
)
1917
{
2018
}
@@ -27,17 +25,9 @@ public function __invoke(int $eventId, string $orderShortId, Request $request):
2725
includeEventInResponse: $this->isIncludeRequested($request, 'event'),
2826
));
2927

30-
$response = $this->resourceResponse(
28+
return $this->resourceResponse(
3129
resource: OrderResourcePublic::class,
3230
data: $order,
3331
);
34-
35-
if ($request->query->has('session_identifier')) {
36-
$response->headers->setCookie(
37-
$this->sessionService->getSessionCookie()
38-
);
39-
}
40-
41-
return $response;
4232
}
4333
}

backend/app/Resources/Order/OrderResourcePublic.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use HiEvents\Resources\Attendee\AttendeeResourcePublic;
99
use HiEvents\Resources\BaseResource;
1010
use HiEvents\Resources\Event\EventResourcePublic;
11+
use HiEvents\Resources\Order\Invoice\InvoiceResource;
1112
use HiEvents\Resources\Order\Invoice\InvoiceResourcePublic;
1213
use Illuminate\Http\Request;
1314

@@ -63,9 +64,6 @@ public function toArray(Request $request): array
6364
!is_null($this->getAttendees()),
6465
fn() => AttendeeResourcePublic::collection($this->getAttendees())
6566
),
66-
$this->mergeWhen($this->getSessionIdentifier() !== null, fn() => [
67-
'session_identifier' => $this->getSessionIdentifier(),
68-
]),
6967
];
7068
}
7169
}

backend/app/Services/Infrastructure/Session/CheckoutSessionManagementService.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,15 @@ public function __construct(
2222
}
2323

2424
/**
25-
* Get the session ID from query param, cookie, or generate a new one.
25+
* Get the session ID from the cookie, or generate a new one if it doesn't exist.
2626
*/
2727
public function getSessionId(): string
2828
{
2929
if ($this->sessionId) {
3030
return $this->sessionId;
3131
}
3232

33-
$this->sessionId = $this->request->query(self::SESSION_IDENTIFIER)
34-
?? $this->request->cookie(self::SESSION_IDENTIFIER)
35-
?? $this->createSessionId();
33+
$this->sessionId = $this->request->cookie(self::SESSION_IDENTIFIER) ?? $this->createSessionId();
3634

3735
return $this->sessionId;
3836
}

frontend/src/api/order.client.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,8 @@ export const orderClientPublic = {
116116
return response.data;
117117
},
118118

119-
findByShortId: async (
120-
eventId: number,
121-
orderShortId: string,
122-
includes: string[] = [],
123-
sessionIdentifier?: string
124-
) => {
125-
const query = new URLSearchParams();
126-
if (includes.length > 0) {
127-
query.append("include", includes.join(","));
128-
}
129-
if (sessionIdentifier) {
130-
query.append("session_identifier", sessionIdentifier);
131-
}
132-
133-
const response = await publicApi.get<GenericDataResponse<Order>>(
134-
`events/${eventId}/order/${orderShortId}?${query.toString()}`
135-
);
136-
119+
findByShortId: async (eventId: number, orderShortId: string, includes: string[] = []) => {
120+
const response = await publicApi.get<GenericDataResponse<Order>>(`events/${eventId}/order/${orderShortId}?include=${includes.join(',')}`);
137121
return response.data;
138122
},
139123

frontend/src/components/routes/product-widget/SelectProducts/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ const SelectProducts = (props: SelectProductsProps) => {
103103
.then(() => {
104104
const url = '/checkout/' + eventId + '/' + data.data.short_id + '/details';
105105
if (props.widgetMode === 'embedded') {
106-
window.open(
107-
url + '?session_identifier=' + data.data.session_identifier + '&utm_source=embedded_widget',
108-
'_blank'
109-
);
106+
window.open(url, '_blank');
110107
setOrderInProcessOverlayVisible(true);
111108
return;
112109
}
Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,25 @@
11
import {useQuery} from "@tanstack/react-query";
22
import {orderClientPublic} from "../api/order.client.ts";
33
import {IdParam, Order} from "../types.ts";
4-
import {useMemo} from "react";
5-
import {isSsr} from "../utilites/helpers.ts";
64

7-
export const GET_ORDER_PUBLIC_QUERY_KEY = "getOrderPublic";
8-
9-
const getSessionIdentifierFromUrl = (): string | null => {
10-
if (isSsr()) return null;
11-
12-
const url = new URL(window.location.href);
13-
return url.searchParams.get("session_identifier");
14-
};
15-
16-
export const useGetOrderPublic = (
17-
eventId: IdParam,
18-
orderShortId: IdParam,
19-
includes: string[] = []
20-
) => {
21-
const sessionIdentifier = useMemo(getSessionIdentifierFromUrl, []);
5+
export const GET_ORDER_PUBLIC_QUERY_KEY = 'getOrderPublic';
226

7+
export const useGetOrderPublic = (eventId: IdParam, orderShortId: IdParam, includes: string[] = []) => {
238
return useQuery<Order>({
24-
queryKey: [
25-
GET_ORDER_PUBLIC_QUERY_KEY,
26-
eventId,
27-
orderShortId,
28-
sessionIdentifier,
29-
],
9+
queryKey: [GET_ORDER_PUBLIC_QUERY_KEY, eventId, orderShortId],
10+
3011
queryFn: async () => {
3112
const {data} = await orderClientPublic.findByShortId(
3213
Number(eventId),
3314
String(orderShortId),
3415
includes,
35-
sessionIdentifier ?? undefined
3616
);
3717
return data;
3818
},
19+
3920
refetchOnWindowFocus: false,
4021
staleTime: 500,
4122
retryOnMount: false,
42-
retry: false,
23+
retry: false
4324
});
44-
};
25+
}

frontend/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ export interface Order {
475475
question_answers?: QuestionAnswer[];
476476
event?: Event;
477477
latest_invoice?: Invoice;
478-
session_identifier?: string;
479478
}
480479

481480
export interface Invoice {

0 commit comments

Comments
 (0)