Skip to content

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 ⭐️

Fix server error when checking in multiple offline payment attendees (#442)

Dave Earley691a1f8e88e4
diff --git a/backend/app/DomainObjects/Generated/AttendeeCheckInDomainObjectAbstract.php b/backend/app/DomainObjects/Generated/AttendeeCheckInDomainObjectAbstract.php
index 1249d2714..5afbf8ab7 100644
--- a/backend/app/DomainObjects/Generated/AttendeeCheckInDomainObjectAbstract.php
+++ b/backend/app/DomainObjects/Generated/AttendeeCheckInDomainObjectAbstract.php
@@ -15,6 +15,7 @@ abstract class AttendeeCheckInDomainObjectAbstract extends \HiEvents\DomainObjec
final public const PRODUCT_ID = 'product_id';
final public const ATTENDEE_ID = 'attendee_id';
final public const EVENT_ID = 'event_id';
+ final public const ORDER_ID = 'order_id';
final public const SHORT_ID = 'short_id';
final public const IP_ADDRESS = 'ip_address';
final public const DELETED_AT = 'deleted_at';
@@ -26,6 +27,7 @@ abstract class AttendeeCheckInDomainObjectAbstract extends \HiEvents\DomainObjec
protected int $product_id;
protected int $attendee_id;
protected int $event_id;
+ protected ?int $order_id = null;
protected string $short_id;
protected string $ip_address;
protected ?string $deleted_at = null;
@@ -40,6 +42,7 @@ abstract class AttendeeCheckInDomainObjectAbstract extends \HiEvents\DomainObjec
'product_id' => $this->product_id ?? null,
'attendee_id' => $this->attendee_id ?? null,
'event_id' => $this->event_id ?? null,
+ 'order_id' => $this->order_id ?? null,
'short_id' => $this->short_id ?? null,
'ip_address' => $this->ip_address ?? null,
'deleted_at' => $this->deleted_at ?? null,
@@ -103,6 +106,17 @@ abstract class AttendeeCheckInDomainObjectAbstract extends \HiEvents\DomainObjec
return $this->event_id;
}
+ public function setOrderId(?int $order_id): self
+ {
+ $this->order_id = $order_id;
+ return $this;
+ }
+
+ public function getOrderId(): ?int
+ {
+ return $this->order_id;
+ }
+
public function setShortId(string $short_id): self
{
$this->short_id = $short_id;
diff --git a/backend/app/DomainObjects/Generated/PersonalAccessTokenDomainObjectAbstract.php b/backend/app/DomainObjects/Generated/PersonalAccessTokenDomainObjectAbstract.php
index 25b819189..4a5897072 100644
--- a/backend/app/DomainObjects/Generated/PersonalAccessTokenDomainObjectAbstract.php
+++ b/backend/app/DomainObjects/Generated/PersonalAccessTokenDomainObjectAbstract.php
@@ -11,7 +11,6 @@ abstract class PersonalAccessTokenDomainObjectAbstract extends \HiEvents\DomainO
final public const SINGULAR_NAME = 'personal_access_token';
final public const PLURAL_NAME = 'personal_access_tokens';
final public const ID = 'id';
- final public const ACCOUNT_ID = 'account_id';
final public const TOKENABLE_TYPE = 'tokenable_type';
final public const TOKENABLE_ID = 'tokenable_id';
final public const NAME = 'name';
@@ -23,7 +22,6 @@ abstract class PersonalAccessTokenDomainObjectAbstract extends \HiEvents\DomainO
final public const UPDATED_AT = 'updated_at';
protected int $id;
- protected int $account_id;
protected string $tokenable_type;
protected int $tokenable_id;
protected string $name;
@@ -38,7 +36,6 @@ abstract class PersonalAccessTokenDomainObjectAbstract extends \HiEvents\DomainO
{
return [
'id' => $this->id ?? null,
- 'account_id' => $this->account_id ?? null,
'tokenable_type' => $this->tokenable_type ?? null,
'tokenable_id' => $this->tokenable_id ?? null,
'name' => $this->name ?? null,
@@ -62,17 +59,6 @@ abstract class PersonalAccessTokenDomainObjectAbstract extends \HiEvents\DomainO
return $this->id;
}
- public function setAccountId(int $account_id): self
- {
- $this->account_id = $account_id;
- return $this;
- }
-
- public function getAccountId(): int
- {
- return $this->account_id;
- }
-
public function setTokenableType(string $tokenable_type): self
{
$this->tokenable_type = $tokenable_type;
diff --git a/backend/app/Resources/Attendee/AttendeeWithCheckInPublicResource.php b/backend/app/Resources/Attendee/AttendeeWithCheckInPublicResource.php
index 82eb7a70e..198bf3f1f 100644
--- a/backend/app/Resources/Attendee/AttendeeWithCheckInPublicResource.php
+++ b/backend/app/Resources/Attendee/AttendeeWithCheckInPublicResource.php
@@ -24,6 +24,7 @@ class AttendeeWithCheckInPublicResource extends JsonResource
'product_price_id' => $this->getProductPriceId(),
'status' => $this->getStatus(),
'locale' => $this->getLocale(),
+ 'order_id' => $this->getOrderId(),
$this->mergeWhen($this->getCheckIn() !== null, [
'check_in' => new AttendeeCheckInPublicResource($this->getCheckIn()),
]),
diff --git a/backend/app/Resources/CheckInList/AttendeeCheckInPublicResource.php b/backend/app/Resources/CheckInList/AttendeeCheckInPublicResource.php
index d12b3013a..8ae9dba8b 100644
--- a/backend/app/Resources/CheckInList/AttendeeCheckInPublicResource.php
+++ b/backend/app/Resources/CheckInList/AttendeeCheckInPublicResource.php
@@ -18,6 +18,7 @@ class AttendeeCheckInPublicResource extends JsonResource
'check_in_list_id' => $this->getCheckInListId(),
'attendee_id' => $this->getAttendeeId(),
'checked_in_at' => $this->getCreatedAt(),
+ 'order_id' => $this->getOrderId(),
];
}
}
diff --git a/backend/app/Services/Domain/CheckInList/CreateAttendeeCheckInService.php b/backend/app/Services/Domain/CheckInList/CreateAttendeeCheckInService.php
index 33ec004c9..e081ea495 100644
--- a/backend/app/Services/Domain/CheckInList/CreateAttendeeCheckInService.php
+++ b/backend/app/Services/Domain/CheckInList/CreateAttendeeCheckInService.php
@@ -4,6 +4,7 @@ namespace HiEvents\Services\Domain\CheckInList;
use Exception;
use HiEvents\DataTransferObjects\ErrorBagDTO;
+use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
use HiEvents\DomainObjects\AttendeeDomainObject;
use HiEvents\DomainObjects\CheckInListDomainObject;
use HiEvents\DomainObjects\Enums\AttendeeCheckInActionType;
@@ -250,9 +251,10 @@ class CreateAttendeeCheckInService
AttendeeDomainObject $attendee,
CheckInListDomainObject $checkInList,
string $checkInUserIpAddress
- ): object
+ ): AttendeeCheckInDomainObject
{
return $this->attendeeCheckInRepository->create([
+ AttendeeCheckInDomainObjectAbstract::ORDER_ID => $attendee->getOrderId(),
AttendeeCheckInDomainObjectAbstract::ATTENDEE_ID => $attendee->getId(),
AttendeeCheckInDomainObjectAbstract::CHECK_IN_LIST_ID => $checkInList->getId(),
AttendeeCheckInDomainObjectAbstract::IP_ADDRESS => $checkInUserIpAddress,
diff --git a/backend/app/Services/Infrastructure/DomainObjectGenerator/ClassGenerator.php b/backend/app/Services/Infrastructure/DomainObjectGenerator/ClassGenerator.php
index df42f104a..7c25a07d8 100644
--- a/backend/app/Services/Infrastructure/DomainObjectGenerator/ClassGenerator.php
+++ b/backend/app/Services/Infrastructure/DomainObjectGenerator/ClassGenerator.php
@@ -40,7 +40,9 @@ class ClassGenerator
private array $defaultIgnoreProperties = [];
private array $ignoredTables = [
- 'migrations'
+ 'migrations',
+ 'job_batches',
+ 'failed_jobs',
];
private AbstractSchemaManager $schemaManager;
diff --git a/backend/database/migrations/2025_03_16_143442_add_order_id_to_attendee_check_ins.php b/backend/database/migrations/2025_03_16_143442_add_order_id_to_attendee_check_ins.php
new file mode 100644
index 000000000..b66c42983
--- /dev/null
+++ b/backend/database/migrations/2025_03_16_143442_add_order_id_to_attendee_check_ins.php
@@ -0,0 +1,21 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ public function up(): void
+ {
+ Schema::table('attendee_check_ins', function (Blueprint $table) {
+ $table->foreignId('order_id')->nullable()->constrained('orders');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('attendee_check_ins', function (Blueprint $table) {
+ $table->dropColumn('order_id');
+ });
+ }
+};
diff --git a/frontend/src/mutations/useCreateCheckInPublic.ts b/frontend/src/mutations/useCreateCheckInPublic.ts
index c9a1f0843..90388fa26 100644
--- a/frontend/src/mutations/useCreateCheckInPublic.ts
+++ b/frontend/src/mutations/useCreateCheckInPublic.ts
@@ -20,22 +20,38 @@ export const useCreateCheckInPublic = (pagination: QueryFilters) => {
queryClient.setQueryData(
[GET_CHECK_IN_LIST_ATTENDEES_PUBLIC_QUERY_KEY, checkInListShortId, pagination],
(oldData: any) => {
+ if (!oldData?.data) return oldData;
+
+ const updatedAttendee = data?.data?.find((checkIn: any) => checkIn.attendee_id);
+
+ if (!updatedAttendee) return oldData;
+
+ const updatedOrderId = updatedAttendee.order_id;
+
const newAttendees = oldData.data.map((attendee: any) => {
const attendeeCheckIn = data?.data?.find(
(checkIn: any) => checkIn.attendee_id === attendee.id
);
- if (attendeeCheckIn) {
- const hasError = data.errors && Object.keys(data.errors).some(
- (key) => key === attendee.public_id
- );
+ const hasError = data.errors && Object.keys(data.errors).some(
+ (key) => key === attendee.public_id
+ );
+ if (attendeeCheckIn) {
return {
...attendee,
check_in: attendeeCheckIn,
status: markedAsPaid && !hasError ? 'ACTIVE' : attendee.status,
};
}
+
+ // Mark all attendees with the same order_id as ACTIVE if markedAsPaid
+ if (markedAsPaid && attendee.order_id === updatedOrderId) {
+ return {
+ ...attendee,
+ status: 'ACTIVE',
+ };
+ }
return attendee;
});
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index b8372e983..779e6027d 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -407,7 +407,7 @@ export interface Attendee {
check_in?: AttendeeCheckIn;
}
-export type PublicCheckIn = Pick<AttendeeCheckIn, 'id' | 'attendee_id' | 'check_in_list_id' | 'product_id' | 'event_id'>;
+export type PublicCheckIn = Pick<AttendeeCheckIn, 'id' | 'order_id' | 'attendee_id' | 'check_in_list_id' | 'product_id' | 'event_id'>;
export interface AttendeeCheckIn {
id: IdParam;
@@ -416,6 +416,7 @@ export interface AttendeeCheckIn {
product_id: IdParam;
event_id: IdParam;
short_id: IdParam;
+ order_id: IdParam;
created_at: string;
}