Skip to content

Commit 18c19a6

Browse files
authored
Merge pull request #20 from HiEventsDev/develop
Fix ability to select tickets unrelated to your order
2 parents 7517091 + 51d17c4 commit 18c19a6

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ For any questions or clarifications, feel free to reach out to us at [security@h
4242

4343
## Hi.Events Public Key
4444

45-
if you need to send us encrypted information, you can use our public key below:
45+
If you need to send us encrypted information, you can use our public key below:
4646

4747
```plaintext
4848
@@ -101,4 +101,4 @@ URSFSI5iNr0JSvCYNmzsDB6zSSlR/UvgRFM1SRUoG3sygmV32Onh0EzU
101101

102102
---
103103

104-
Hi.Events Team
104+
Hi.Events Team

backend/app/Services/Handlers/Order/CompleteOrderHandler.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ private function createAttendees(Collection $attendees, OrderDomainObject $order
9696
values: $attendees->pluck('ticket_price_id')->toArray(),
9797
);
9898

99+
$this->validateTicketPriceIdsMatchOrder($order, $ticketsPrices);
100+
99101
foreach ($attendees as $attendee) {
100102
$ticketId = $ticketsPrices->first(
101103
fn(TicketPriceDomainObject $ticketPrice) => $ticketPrice->getId() === $attendee->ticket_price_id)
@@ -238,4 +240,21 @@ private function updateOrder(OrderDomainObject $order, CompleteOrderOrderDTO $or
238240
]
239241
);
240242
}
243+
244+
/**
245+
* Check if the passed ticket price IDs match what exist in the order_items table
246+
*
247+
* @throws ResourceConflictException
248+
*/
249+
private function validateTicketPriceIdsMatchOrder(OrderDomainObject $order, Collection $ticketsPrices): void
250+
{
251+
$orderTicketPriceIds = $order->getOrderItems()
252+
?->map(fn(OrderItemDomainObject $orderItem) => $orderItem->getTicketPriceId())->toArray();
253+
254+
$ticketsPricesIds = $ticketsPrices->map(fn(TicketPriceDomainObject $ticketPrice) => $ticketPrice->getId());
255+
256+
if ($ticketsPricesIds->diff($orderTicketPriceIds)->isNotEmpty()) {
257+
throw new ResourceConflictException(__('There is an unexpected ticket price ID in the order'));
258+
}
259+
}
241260
}

0 commit comments

Comments
 (0)