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
Render offline payment instruction tokens (#1235)
Ridwan Aguda6eb1709360b0
diff --git a/backend/app/Services/Application/Handlers/Order/GetOrderPublicHandler.php b/backend/app/Services/Application/Handlers/Order/GetOrderPublicHandler.phpindex 0672a0e99..d6eecedef 100644--- a/backend/app/Services/Application/Handlers/Order/GetOrderPublicHandler.php+++ b/backend/app/Services/Application/Handlers/Order/GetOrderPublicHandler.php@@ -20,14 +20,16 @@ use HiEvents\Exceptions\UnauthorizedException;use HiEvents\Repository\Eloquent\Value\Relationship;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Services\Application\Handlers\Order\DTO\GetOrderPublicDTO;+use HiEvents\Services\Domain\Order\OfflinePaymentInstructionsRenderService;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+ private readonly OrderRepositoryInterface $orderRepository,+ private readonly CheckoutSessionManagementService $sessionIdentifierService,+ private readonly OfflinePaymentInstructionsRenderService $offlinePaymentInstructionsRenderService,){}@@ -49,6 +51,8 @@ class GetOrderPublicHandler$this->verifySessionId($order->getSessionId());}+ $this->offlinePaymentInstructionsRenderService->renderForOrder($order);+return $order;}diff --git a/backend/app/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandler.php b/backend/app/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandler.phpindex 0030f48c6..5e7aa59b4 100644--- a/backend/app/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandler.php+++ b/backend/app/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandler.php@@ -23,6 +23,7 @@ use HiEvents\Repository\Eloquent\Value\Relationship;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Repository\Interfaces\TicketLookupTokenRepositoryInterface;use HiEvents\Services\Application\Handlers\TicketLookup\DTO\GetOrdersByLookupTokenDTO;+use HiEvents\Services\Domain\Order\OfflinePaymentInstructionsRenderService;use Illuminate\Support\Collection;class GetOrdersByLookupTokenHandler@@ -30,6 +31,7 @@ class GetOrdersByLookupTokenHandlerpublic function __construct(private readonly TicketLookupTokenRepositoryInterface $ticketLookupTokenRepository,private readonly OrderRepositoryInterface $orderRepository,+ private readonly OfflinePaymentInstructionsRenderService $offlinePaymentInstructionsRenderService,) {}@@ -41,7 +43,8 @@ class GetOrdersByLookupTokenHandler{$tokenRecord = $this->validateAndFetchToken($dto->token);- return $this->getOrdersForEmail($tokenRecord->getEmail());+ return $this->getOrdersForEmail($tokenRecord->getEmail())+ ->each(fn(OrderDomainObject $order) => $this->offlinePaymentInstructionsRenderService->renderForOrder($order));}/**diff --git a/backend/app/Services/Domain/Email/EmailTokenContextBuilder.php b/backend/app/Services/Domain/Email/EmailTokenContextBuilder.phpindex c0f71aa1a..b5e33ae20 100644--- a/backend/app/Services/Domain/Email/EmailTokenContextBuilder.php+++ b/backend/app/Services/Domain/Email/EmailTokenContextBuilder.php@@ -16,9 +16,19 @@ use HiEvents\Helper\DateHelper;use HiEvents\Helper\IdHelper;use HiEvents\Helper\Url;use HiEvents\Locale;+use HiEvents\Services\Infrastructure\Email\LiquidTemplateRenderer;+use HiEvents\Services\Infrastructure\HtmlPurifier\HtmlPurifierService;+use Throwable;class EmailTokenContextBuilder{+ public function __construct(+ private readonly LiquidTemplateRenderer $liquidTemplateRenderer,+ private readonly HtmlPurifierService $htmlPurifierService,+ )+ {+ }+public function buildOrderConfirmationContext(OrderDomainObject $order,EventDomainObject $event,@@ -29,7 +39,7 @@ class EmailTokenContextBuilder$eventStartDate = new Carbon(DateHelper::convertFromUTC($event->getStartDate(), $event->getTimezone()));$eventEndDate = $event->getEndDate() ? new Carbon(DateHelper::convertFromUTC($event->getEndDate(), $event->getTimezone())) : null;- return [+ $context = [// Event object'event' => ['title' => $event->getTitle(),@@ -75,6 +85,27 @@ class EmailTokenContextBuilder'post_checkout_message' => $eventSettings->getPostCheckoutMessage() ?? '',],];++ $context['settings']['offline_payment_instructions'] = $this->renderOfflinePaymentInstructions($context);++ return $context;+ }++ private function renderOfflinePaymentInstructions(array $context): string+ {+ $instructions = $context['settings']['offline_payment_instructions'];++ if ($instructions === '') {+ return $instructions;+ }++ try {+ $rendered = $this->liquidTemplateRenderer->render($instructions, $context);++ return $this->htmlPurifierService->purify($rendered) ?? $instructions;+ } catch (Throwable) {+ return $instructions;+ }}public function buildAttendeeTicketContext(diff --git a/backend/app/Services/Domain/Email/MailBuilderService.php b/backend/app/Services/Domain/Email/MailBuilderService.phpindex 59ef8806b..5cea766a8 100644--- a/backend/app/Services/Domain/Email/MailBuilderService.php+++ b/backend/app/Services/Domain/Email/MailBuilderService.php@@ -12,12 +12,14 @@ use HiEvents\DomainObjects\OrganizerDomainObject;use HiEvents\Mail\Attendee\AttendeeTicketMail;use HiEvents\Mail\Order\OrderSummary;use HiEvents\Services\Domain\Email\DTO\RenderedEmailTemplateDTO;+use HiEvents\Services\Domain\Order\OfflinePaymentInstructionsRenderService;class MailBuilderService{public function __construct(private readonly EmailTemplateService $emailTemplateService,private readonly EmailTokenContextBuilder $tokenContextBuilder,+ private readonly OfflinePaymentInstructionsRenderService $offlinePaymentInstructionsRenderService,) {}@@ -60,6 +62,10 @@ class MailBuilderService$organizer);+ if (!$renderedTemplate) {+ $this->offlinePaymentInstructionsRenderService->render($order, $event, $organizer, $eventSettings);+ }+return new OrderSummary(order: $order,event: $event,diff --git a/backend/app/Services/Domain/Order/OfflinePaymentInstructionsRenderService.php b/backend/app/Services/Domain/Order/OfflinePaymentInstructionsRenderService.phpnew file mode 100644index 000000000..33cea1191--- /dev/null+++ b/backend/app/Services/Domain/Order/OfflinePaymentInstructionsRenderService.php@@ -0,0 +1,61 @@+<?php++declare(strict_types=1);++namespace HiEvents\Services\Domain\Order;++use HiEvents\DomainObjects\EventDomainObject;+use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\OrderDomainObject;+use HiEvents\DomainObjects\OrganizerDomainObject;+use HiEvents\Services\Domain\Email\EmailTokenContextBuilder;+use Throwable;++class OfflinePaymentInstructionsRenderService+{+ public function __construct(+ private readonly EmailTokenContextBuilder $tokenContextBuilder,+ )+ {+ }++ public function renderForOrder(OrderDomainObject $order): void+ {+ $event = $order->getEvent();+ $eventSettings = $event?->getEventSettings();+ $organizer = $event?->getOrganizer();++ if (!$event || !$eventSettings || !$organizer) {+ return;+ }++ $this->render($order, $event, $organizer, $eventSettings);+ }++ public function render(+ OrderDomainObject $order,+ EventDomainObject $event,+ OrganizerDomainObject $organizer,+ EventSettingDomainObject $eventSettings,+ ): void+ {+ if (!$eventSettings->getOfflinePaymentInstructions()) {+ return;+ }++ try {+ $context = $this->tokenContextBuilder->buildOrderConfirmationContext(+ order: $order,+ event: $event,+ organizer: $organizer,+ eventSettings: $eventSettings,+ );++ $eventSettings->setOfflinePaymentInstructions(+ $context['settings']['offline_payment_instructions']+ );+ } catch (Throwable) {+ return;+ }+ }+}diff --git a/backend/tests/Unit/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandlerTest.php b/backend/tests/Unit/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandlerTest.phpindex a738bc682..79909fbda 100644--- a/backend/tests/Unit/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandlerTest.php+++ b/backend/tests/Unit/Services/Application/Handlers/TicketLookup/GetOrdersByLookupTokenHandlerTest.php@@ -10,6 +10,7 @@ use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Repository\Interfaces\TicketLookupTokenRepositoryInterface;use HiEvents\Services\Application\Handlers\TicketLookup\DTO\GetOrdersByLookupTokenDTO;use HiEvents\Services\Application\Handlers\TicketLookup\GetOrdersByLookupTokenHandler;+use HiEvents\Services\Domain\Order\OfflinePaymentInstructionsRenderService;use Illuminate\Support\Collection;use Mockery as m;use Tests\TestCase;@@ -30,6 +31,7 @@ class GetOrdersByLookupTokenHandlerTest extends TestCase$this->handler = new GetOrdersByLookupTokenHandler($this->ticketLookupTokenRepository,$this->orderRepository,+ app(OfflinePaymentInstructionsRenderService::class),);}@@ -46,6 +48,7 @@ class GetOrdersByLookupTokenHandlerTest extends TestCase->andReturn($email);$order = m::mock(OrderDomainObject::class);+ $order->shouldReceive('getEvent')->andReturn(null);$orders = new Collection([$order]);$this->ticketLookupTokenRepositorydiff --git a/backend/tests/Unit/Services/Domain/Email/EmailTokenContextBuilderTest.php b/backend/tests/Unit/Services/Domain/Email/EmailTokenContextBuilderTest.phpindex 37ff777ca..1ff9ced8a 100644--- a/backend/tests/Unit/Services/Domain/Email/EmailTokenContextBuilderTest.php+++ b/backend/tests/Unit/Services/Domain/Email/EmailTokenContextBuilderTest.php@@ -21,7 +21,7 @@ class EmailTokenContextBuilderTest extends TestCaseprotected function setUp(): void{parent::setUp();- $this->contextBuilder = new EmailTokenContextBuilder();+ $this->contextBuilder = app(EmailTokenContextBuilder::class);}public function test_builds_order_confirmation_context(): void@@ -101,6 +101,70 @@ class EmailTokenContextBuilderTest extends TestCase$this->assertEquals('Great Organizer', $context['organizer']['name']);}+ public function test_offline_payment_instructions_tokens_are_rendered_into_context(): void+ {+ $order = $this->createMockOrder();+ $event = $this->createMockEvent();+ $organizer = $this->createMockOrganizer();+ $eventSettings = $this->createMockEventSettings(+ offlinePaymentInstructions: '<p>Use {{ order.number }} for {{ event.title }}</p>',+ );++ $context = $this->contextBuilder->buildOrderConfirmationContext(+ $order,+ $event,+ $organizer,+ $eventSettings+ );++ $this->assertSame(+ '<p>Use ORD-123456 for Amazing Event</p>',+ $context['settings']['offline_payment_instructions'],+ );+ }++ public function test_rendered_offline_payment_instructions_are_purified(): void+ {+ $order = $this->createMockOrder(firstName: '<script>alert("xss")</script>John');+ $event = $this->createMockEvent();+ $organizer = $this->createMockOrganizer();+ $eventSettings = $this->createMockEventSettings(+ offlinePaymentInstructions: '<p>Reference {{ order.first_name }}</p>',+ );++ $context = $this->contextBuilder->buildOrderConfirmationContext(+ $order,+ $event,+ $organizer,+ $eventSettings+ );++ $this->assertStringNotContainsString('<script>', $context['settings']['offline_payment_instructions']);+ $this->assertStringContainsString('John', $context['settings']['offline_payment_instructions']);+ }++ public function test_unrenderable_offline_payment_instructions_fall_back_to_raw_value(): void+ {+ $order = $this->createMockOrder();+ $event = $this->createMockEvent();+ $organizer = $this->createMockOrganizer();+ $eventSettings = $this->createMockEventSettings(+ offlinePaymentInstructions: '<p>{% unknown_tag %}</p>',+ );++ $context = $this->contextBuilder->buildOrderConfirmationContext(+ $order,+ $event,+ $organizer,+ $eventSettings+ );++ $this->assertSame(+ '<p>{% unknown_tag %}</p>',+ $context['settings']['offline_payment_instructions'],+ );+ }+public function test_whitelists_only_allowed_tokens_for_order_confirmation(): void{$order = $this->createMockOrder();@@ -155,7 +219,7 @@ class EmailTokenContextBuilderTest extends TestCase$this->assertArrayHasKey('title', $context['event']);}- private function createMockOrder(): OrderDomainObject+ private function createMockOrder(string $firstName = 'John'): OrderDomainObject{$orderItem = Mockery::mock(OrderItemDomainObject::class, ['getProductPriceId' => 123,@@ -168,7 +232,7 @@ class EmailTokenContextBuilderTest extends TestCasereturn Mockery::mock(OrderDomainObject::class, ['getPublicId' => 'ORD-123456','getTotalGross' => 9999,- 'getFirstName' => 'John',+ 'getFirstName' => $firstName,'getLastName' => 'Doe','getEmail' => '[email protected]','getCreatedAt' => '2024-01-15 10:30:00',@@ -202,11 +266,11 @@ class EmailTokenContextBuilderTest extends TestCase]);}- private function createMockEventSettings(): EventSettingDomainObject+ private function createMockEventSettings(string $offlinePaymentInstructions = 'Pay by bank transfer'): EventSettingDomainObject{return Mockery::mock(EventSettingDomainObject::class, ['getSupportEmail' => '[email protected]',- 'getOfflinePaymentInstructions' => 'Pay by bank transfer',+ 'getOfflinePaymentInstructions' => $offlinePaymentInstructions,'getPostCheckoutMessage' => 'Thank you for your purchase!','getLocationDetails' => null,]);diff --git a/backend/tests/Unit/Services/Domain/Email/MailBuilderServiceTest.php b/backend/tests/Unit/Services/Domain/Email/MailBuilderServiceTest.phpnew file mode 100644index 000000000..a77324245--- /dev/null+++ b/backend/tests/Unit/Services/Domain/Email/MailBuilderServiceTest.php@@ -0,0 +1,81 @@+<?php++namespace Tests\Unit\Services\Domain\Email;++use HiEvents\DomainObjects\Enums\PaymentProviders;+use HiEvents\DomainObjects\EventDomainObject;+use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\OrderDomainObject;+use HiEvents\DomainObjects\OrganizerDomainObject;+use HiEvents\DomainObjects\Status\OrderPaymentStatus;+use HiEvents\DomainObjects\Status\OrderStatus;+use HiEvents\Services\Domain\Email\EmailTemplateService;+use HiEvents\Services\Domain\Email\EmailTokenContextBuilder;+use HiEvents\Services\Domain\Email\MailBuilderService;+use HiEvents\Services\Domain\Order\OfflinePaymentInstructionsRenderService;+use Mockery as m;+use Tests\TestCase;++class MailBuilderServiceTest extends TestCase+{+ public function test_order_summary_blade_fallback_receives_rendered_instructions(): void+ {+ $emailTemplateService = m::mock(EmailTemplateService::class);+ $emailTemplateService->shouldReceive('getTemplateByType')->andReturn(null);++ $service = new MailBuilderService(+ $emailTemplateService,+ app(EmailTokenContextBuilder::class),+ app(OfflinePaymentInstructionsRenderService::class),+ );++ $organizer = (new OrganizerDomainObject())+ ->setId(1)+ ->setName('Example Organizer')+ ->setEmail('[email protected]');++ $settings = (new EventSettingDomainObject())+ ->setId(20)+ ->setEventId(10)+ ->setSupportEmail('[email protected]')+ ->setOfflinePaymentInstructions('<p>Use {{ order.number }} as your reference</p>');++ $event = (new EventDomainObject())+ ->setId(10)+ ->setAccountId(1)+ ->setTitle('Summer Session')+ ->setStartDate('2026-08-15 18:00:00')+ ->setCurrency('GBP')+ ->setTimezone('UTC')+ ->setOrganizer($organizer)+ ->setEventSettings($settings);++ $order = (new OrderDomainObject())+ ->setId(30)+ ->setEventId(10)+ ->setShortId('order-short-id')+ ->setPublicId('ORD-12345')+ ->setFirstName('Jane')+ ->setLastName('Buyer')+ ->setEmail('[email protected]')+ ->setTotalGross(125.50)+ ->setCurrency('GBP')+ ->setCreatedAt('2026-08-01 12:00:00')+ ->setStatus(OrderStatus::AWAITING_OFFLINE_PAYMENT->name)+ ->setPaymentStatus(OrderPaymentStatus::AWAITING_OFFLINE_PAYMENT->name)+ ->setPaymentProvider(PaymentProviders::OFFLINE->value);++ $service->buildOrderSummaryMail($order, $event, $settings, $organizer);++ $this->assertSame(+ '<p>Use ORD-12345 as your reference</p>',+ $settings->getOfflinePaymentInstructions(),+ );+ }++ protected function tearDown(): void+ {+ m::close();+ parent::tearDown();+ }+}diff --git a/backend/tests/Unit/Services/Domain/Order/OfflinePaymentInstructionsRenderServiceTest.php b/backend/tests/Unit/Services/Domain/Order/OfflinePaymentInstructionsRenderServiceTest.phpnew file mode 100644index 000000000..9d6296dee--- /dev/null+++ b/backend/tests/Unit/Services/Domain/Order/OfflinePaymentInstructionsRenderServiceTest.php@@ -0,0 +1,123 @@+<?php++namespace Tests\Unit\Services\Domain\Order;++use HiEvents\DomainObjects\Enums\PaymentProviders;+use HiEvents\DomainObjects\EventDomainObject;+use HiEvents\DomainObjects\EventSettingDomainObject;+use HiEvents\DomainObjects\OrderDomainObject;+use HiEvents\DomainObjects\OrganizerDomainObject;+use HiEvents\DomainObjects\Status\OrderPaymentStatus;+use HiEvents\DomainObjects\Status\OrderStatus;+use HiEvents\Services\Domain\Order\OfflinePaymentInstructionsRenderService;+use Tests\TestCase;++class OfflinePaymentInstructionsRenderServiceTest extends TestCase+{+ public function test_order_tokens_are_rendered_into_instructions(): void+ {+ $order = $this->makeOrder('<p>Use {{ order.number }} for {{ event.title }}</p>');++ $this->service()->renderForOrder($order);++ $this->assertSame(+ '<p>Use ORD-12345 for Summer Session</p>',+ $order->getEvent()->getEventSettings()->getOfflinePaymentInstructions(),+ );+ }++ public function test_rendered_instructions_are_purified(): void+ {+ $order = $this->makeOrder(+ '<p>Reference {{ order.first_name }}</p>',+ orderFirstName: '<script>alert("xss")</script>Jane',+ );++ $this->service()->renderForOrder($order);++ $instructions = $order->getEvent()->getEventSettings()->getOfflinePaymentInstructions();++ $this->assertStringNotContainsString('<script>', $instructions);+ $this->assertStringContainsString('Jane', $instructions);+ }++ public function test_order_without_event_is_left_untouched(): void+ {+ $order = (new OrderDomainObject())->setId(30);++ $this->service()->renderForOrder($order);++ $this->assertNull($order->getEvent());+ }++ public function test_empty_instructions_are_left_untouched(): void+ {+ $order = $this->makeOrder(null);++ $this->service()->renderForOrder($order);++ $this->assertNull($order->getEvent()->getEventSettings()->getOfflinePaymentInstructions());+ }++ public function test_render_failure_leaves_original_instructions(): void+ {+ $order = $this->makeOrder('<p>Use {{ order.number }}</p>');+ $order->getEvent()->setStartDate('not-a-valid-date');++ $this->service()->renderForOrder($order);++ $this->assertSame(+ '<p>Use {{ order.number }}</p>',+ $order->getEvent()->getEventSettings()->getOfflinePaymentInstructions(),+ );+ }++ private function service(): OfflinePaymentInstructionsRenderService+ {+ return app(OfflinePaymentInstructionsRenderService::class);+ }++ private function makeOrder(+ ?string $offlinePaymentInstructions,+ string $orderFirstName = 'Jane',+ ): OrderDomainObject+ {+ $organizer = (new OrganizerDomainObject())+ ->setId(1)+ ->setName('Example Organizer')+ ->setEmail('[email protected]');++ $settings = (new EventSettingDomainObject())+ ->setId(20)+ ->setEventId(10)+ ->setPaymentProviders([PaymentProviders::OFFLINE->value])+ ->setSupportEmail('[email protected]')+ ->setOfflinePaymentInstructions($offlinePaymentInstructions);++ $event = (new EventDomainObject())+ ->setId(10)+ ->setTitle('Summer Session')+ ->setDescription('An evening event')+ ->setStartDate('2026-08-15 18:00:00')+ ->setCurrency('GBP')+ ->setTimezone('UTC')+ ->setOrganizer($organizer)+ ->setEventSettings($settings);++ return (new OrderDomainObject())+ ->setId(30)+ ->setEventId(10)+ ->setShortId('order-short-id')+ ->setPublicId('ORD-12345')+ ->setFirstName($orderFirstName)+ ->setLastName('Buyer')+ ->setEmail('[email protected]')+ ->setTotalGross(125.50)+ ->setCurrency('GBP')+ ->setCreatedAt('2026-08-01 12:00:00')+ ->setStatus(OrderStatus::AWAITING_OFFLINE_PAYMENT->name)+ ->setPaymentStatus(OrderPaymentStatus::AWAITING_OFFLINE_PAYMENT->name)+ ->setPaymentProvider(PaymentProviders::OFFLINE->value)+ ->setEvent($event);+ }+}diff --git a/frontend/src/components/common/Editor/Controls/InsertLiquidVariableControl.tsx b/frontend/src/components/common/Editor/Controls/InsertLiquidVariableControl.tsxdeleted file mode 100644index 411e23dd4..000000000--- a/frontend/src/components/common/Editor/Controls/InsertLiquidVariableControl.tsx+++ /dev/null@@ -1,160 +0,0 @@-import {RichTextEditor, useRichTextEditorContext} from '@mantine/tiptap';-import {IconBraces} from '@tabler/icons-react';-import {Menu, ScrollArea, Stack, Text} from '@mantine/core';-import {EmailTemplateType} from '../../../../types';-import {t} from '@lingui/macro';--interface InsertLiquidVariableControlProps {- templateType?: EmailTemplateType;-}--interface TemplateVariable {- label: string;- value: string;- description?: string;- category?: string;-}--const TEMPLATE_VARIABLES: Record<EmailTemplateType, TemplateVariable[]> = {- order_confirmation: [- // Order Information- {label: t`Order Number`, value: 'order.number', description: t`Unique order reference`, category: t`Order`},- {label: t`Order Total`, value: 'order.total', description: t`Total amount paid`, category: t`Order`},- {label: t`Order Date`, value: 'order.date', description: t`Date order was placed`, category: t`Order`},- {label: t`Order First Name`, value: 'order.first_name', description: t`Customer's first name`, category: t`Order`},- {label: t`Order Last Name`, value: 'order.last_name', description: t`Customer's last name`, category: t`Order`},- {label: t`Order Email`, value: 'order.email', description: t`Customer's email address`, category: t`Order`},- {label: t`Order URL`, value: 'order.url', description: t`Link to order details`, category: t`Order`},- {label: t`Order Is Awaiting Offline Payment`, value: 'order.is_awaiting_offline_payment', description: t`True if payment pending`, category: t`Order`},- {label: t`Order Locale`, value: 'order.locale', description: t`The locale of the customer`, category: t`Order`},- {label: t`Order Currency`, value: 'order.currency', description: t`The currency of the order`, category: t`Order`},- {label: t`Offline Payment`, value: 'order.is_offline_payment', description: t`True if offline payment`, category: t`Order`},-- // Event Information- {label: t`Event Title`, value: 'event.title', description: t`Name of the event`, category: t`Event`},- {label: t`Event Date`, value: 'event.date', description: t`Date of the event`, category: t`Event`},- {label: t`Event Time`, value: 'event.time', description: t`Start time of the event`, category: t`Event`},- {label: t`Event Full Address`, value: 'event.full_address', description: t`The full event address`, category: t`Event`},- {label: t`Event Description`, value: 'event.description', description: t`Event details`, category: t`Event`},- {label: t`Event Timezone`, value: 'event.timezone', description: t`Event timezone`, category: t`Event`},- {label: t`Event Venue`, value: 'event.location_details.venue_name', description: t`The event venue`, category: t`Event`},--- // Organization- {label: t`Organizer Name`, value: 'organizer.name', description: t`Event organizer name`, category: t`Organization`},- {label: t`Organizer Email`, value: 'organizer.email', description: t`Organizer email address`, category: t`Organization`},-- // Settings- {label: t`Support Email`, value: 'settings.support_email', description: t`Contact email for support`, category: t`Settings`},- {label: t`Offline Payment Instructions`, value: 'settings.offline_payment_instructions', description: t`How to pay offline`, category: t`Settings`},- {label: t`Post Checkout Message`, value: 'settings.post_checkout_message', description: t`Custom message after checkout`, category: t`Settings`},- ],- attendee_ticket: [- // Attendee Information- {label: t`Attendee Name`, value: 'attendee.name', description: t`Ticket holder's name`, category: t`Attendee`},- {label: t`Attendee Email`, value: 'attendee.email', description: t`Ticket holder's email`, category: t`Attendee`},-- // Ticket Information- {label: t`Ticket Name`, value: 'ticket.name', description: t`Type of ticket`, category: t`Ticket`},- {label: t`Ticket Price`, value: 'ticket.price', description: t`Price of the ticket`, category: t`Ticket`},- {label: t`Ticket URL`, value: 'ticket.url', description: t`Link to ticket`, category: t`Ticket`},-- // Order Information- {label: t`Order Payment Pending`, value: 'order.is_awaiting_offline_payment', description: t`True if payment pending`, category: t`Order`},- {label: t`Order Status`, value: 'order.status', description: t`Order Status`, category: t`Order`},- {label: t`Offline Payment`, value: 'is_offline_payment', description: t`True if offline payment`, category: t`Order`},-- // Event Information- {label: t`Event Title`, value: 'event.title', description: t`Name of the event`, category: t`Event`},- {label: t`Event Date`, value: 'event.date', description: t`Date of the event`, category: t`Event`},- {label: t`Event Time`, value: 'event.time', description: t`Start time of the event`, category: t`Event`},- {label: t`Event Location`, value: 'event.full_address', description: t`The full event address`, category: t`Event`},- {label: t`Event Description`, value: 'event.description', description: t`Event details`, category: t`Event`},- {label: t`Event Timezone`, value: 'event.timezone', description: t`Event timezone`, category: t`Event`},- {label: t`Event Venue`, value: 'event.location_details.venue_name', description: t`The event venue`, category: t`Event`},-- // Organization- {label: t`Organizer Name`, value: 'organizer.name', description: t`Event organizer name`, category: t`Organization`},- {label: t`Organizer Email`, value: 'organizer.email', description: t`Organizer email address`, category: t`Organization`},-- // Settings- {label: t`Support Email`, value: 'settings.support_email', description: t`Contact email for support`, category: t`Settings`},- {label: t`Offline Payment Instructions`, value: 'settings.offline_payment_instructions', description: t`How to pay offline`, category: t`Settings`},- {label: t`Post Checkout Message`, value: 'settings.post_checkout_message', description: t`Custom message after checkout`, category: t`Settings`},- ],-};--export function InsertLiquidVariableControl({templateType = 'order_confirmation'}: InsertLiquidVariableControlProps) {- const {editor} = useRichTextEditorContext();- const variables = TEMPLATE_VARIABLES[templateType] || [];-- const handleInsertVariable = (variable: string) => {- // Insert as plain text with Liquid syntax- editor?.chain().focus().insertContent(`{{ ${variable} }}`).run();- };-- // Group variables by category- const groupedVariables = variables.reduce((acc, variable) => {- const category = variable.category || t`Other`;- if (!acc[category]) {- acc[category] = [];- }- acc[category].push(variable);- return acc;- }, {} as Record<string, TemplateVariable[]>);-- return (- <Menu shadow="md" width={380}>- <Menu.Target>- <RichTextEditor.Control- title={t`Insert Variable`}- aria-label={t`Insert Variable`}- >- <IconBraces size={16}/>- </RichTextEditor.Control>- </Menu.Target>-- <Menu.Dropdown>- <ScrollArea h={400}>- {Object.entries(groupedVariables).map(([category, categoryVariables]) => (- <div key={category}>- <Menu.Label>{category}</Menu.Label>- {categoryVariables.map((variable) => (- <Menu.Item- key={variable.value}- onClick={() => handleInsertVariable(variable.value)}- p="sm"- >- <Stack gap={4}>- <Text size="sm" fw={500}>- {variable.label}- </Text>- <Text- size="xs"- c="blue"- ff="monospace"- style={{- backgroundColor: 'var(--mantine-color-gray-0)',- padding: '2px 6px',- borderRadius: '4px',- display: 'inline-block',- width: 'fit-content'- }}- >- {`{{ ${variable.value} }}`}- </Text>- {variable.description && (- <Text size="xs" c="dimmed">- {variable.description}- </Text>- )}- </Stack>- </Menu.Item>- ))}- </div>- ))}- </ScrollArea>- </Menu.Dropdown>- </Menu>- );-}diff --git a/frontend/src/components/common/Editor/Controls/LiquidTokenControl.tsx b/frontend/src/components/common/Editor/Controls/LiquidTokenControl.tsxindex 86d6cf369..d1641c466 100644--- a/frontend/src/components/common/Editor/Controls/LiquidTokenControl.tsx+++ b/frontend/src/components/common/Editor/Controls/LiquidTokenControl.tsx@@ -7,9 +7,10 @@ import {t, Trans} from '@lingui/macro';interface LiquidTokenControlProps {templateType: EmailTemplateType;+ excludeTokens?: string[];}-export const LiquidTokenControl = ({templateType}: LiquidTokenControlProps) => {+export const LiquidTokenControl = ({templateType, excludeTokens = []}: LiquidTokenControlProps) => {const {editor} = useRichTextEditorContext();const {data: tokensData, isLoading} = useGetEmailTemplateTokens(templateType);@@ -31,7 +32,9 @@ export const LiquidTokenControl = ({templateType}: LiquidTokenControlProps) => {);}- const tokens = tokensData.tokens.filter(token => !token.token.startsWith('{% if'));+ const tokens = tokensData.tokens.filter(token =>+ !token.token.startsWith('{% if') && !excludeTokens.includes(token.token)+ );return (<Menu shadow="md" width={380} position="bottom-start" withinPortal>diff --git a/frontend/src/components/routes/event/Settings/Sections/PaymentSettings/index.tsx b/frontend/src/components/routes/event/Settings/Sections/PaymentSettings/index.tsxindex 98bd27bab..5af59b328 100644--- a/frontend/src/components/routes/event/Settings/Sections/PaymentSettings/index.tsx+++ b/frontend/src/components/routes/event/Settings/Sections/PaymentSettings/index.tsx@@ -11,6 +11,7 @@ import {useUpdateEventSettings} from "../../../../../../mutations/useUpdateEventimport {useGetEventSettings} from "../../../../../../queries/useGetEventSettings.ts";import {HeadingWithDescription} from "../../../../../common/Card/CardHeading";import {Editor} from "../../../../../common/Editor";+import {LiquidTokenControl} from "../../../../../common/Editor/Controls/LiquidTokenControl";import {InputLabelWithHelp} from "../../../../../common/InputLabelWithHelp";import {isEmptyHtml} from "../../../../../../utilites/helpers.ts";@@ -152,6 +153,15 @@ export const PaymentAndInvoicingSettings = () => {helpText={t`This information will be shown on the payment page, order summary page, and order confirmation email.`}/>}description={t`Add instructions for offline payments (e.g., bank transfer details, where to send checks, payment deadlines)`}onChange={(value) => form.setFieldValue('offline_payment_instructions', value)}+ additionalToolbarControls={+ <LiquidTokenControl+ templateType={'order_confirmation'}+ excludeTokens={[+ '{{ settings.offline_payment_instructions }}',+ '{{ settings.post_checkout_message }}',+ ]}+ />+ }/><Switchlabel={t`Allow attendees associated with unpaid orders to check in`}diff --git a/frontend/src/components/routes/product-widget/Payment/index.tsx b/frontend/src/components/routes/product-widget/Payment/index.tsxindex a5fe67c28..b270406d8 100644--- a/frontend/src/components/routes/product-widget/Payment/index.tsx+++ b/frontend/src/components/routes/product-widget/Payment/index.tsx@@ -26,6 +26,7 @@ const Payment = () => {const {data: event, isFetched: isEventFetched} = useGetEventPublic(eventId);const {data: order, isFetched: isOrderFetched} = useGetOrderPublic(eventId, orderShortId, ['event']);const isLoading = !isOrderFetched;+ const checkoutEvent = order?.event || event;const [isPaymentLoading, setIsPaymentLoading] = useState(false);const [activePaymentMethod, setActivePaymentMethod] = useState<'STRIPE' | 'OFFLINE' | null>(null);const [submitHandler, setSubmitHandler] = useState<(() => Promise<void>) | null>(null);@@ -93,8 +94,8 @@ const Payment = () => {return (<><CheckoutContent>- {(event && order) && (- <InlineOrderSummary event={event} order={order} defaultExpanded={false}/>+ {(checkoutEvent && order) && (+ <InlineOrderSummary event={checkoutEvent} order={order} defaultExpanded={false}/>)}{isStripeEnabled && (<div style={{display: activePaymentMethod === 'STRIPE' ? 'block' : 'none'}}>@@ -104,7 +105,7 @@ const Payment = () => {{isOfflineEnabled && (<div style={{display: activePaymentMethod === 'OFFLINE' ? 'block' : 'none'}}>- <OfflinePaymentMethod event={event as Event}/>+ <OfflinePaymentMethod event={checkoutEvent as Event}/></div>)}