Skip to content

Commit 89bd2c0

Browse files
committed
Enhance ticketing configuration and URL handling
- Added `customDomain` flag to the ticketing configuration to manage URL construction for Pretix-managed custom event domains. - Introduced `pretixEventUrl` function to generate user-facing URLs that respect the custom domain setting, ensuring correct URL paths for both custom and legacy instances. - Updated references in the status and checkout components to utilize the new `pretixEventUrl` function for improved URL handling.
1 parent 0488886 commit 89bd2c0

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

devcon/src/config/ticketing.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const ENV_CONFIG = {
88
baseUrl: 'https://dcdev2.ticketh.xyz',
99
organizer: 'org',
1010
event: '8',
11+
// True when `baseUrl` is a Pretix-managed custom event domain (Pretix's
12+
// multidomain feature serves the event at root — `/order/...`, not
13+
// `/{organizer}/{event}/order/...`). Drives URL construction in
14+
// status.ts and the checkout fallback redirect. Legacy slug-based
15+
// Pretix instances (e.g. dcdev2.ticketh.xyz) leave this `false`.
16+
customDomain: false,
1117
ticketDiscountId: '6',
1218
defaultQuotaId: 116,
1319
testmode: true,
@@ -60,6 +66,11 @@ const ENV_CONFIG = {
6066
baseUrl: 'https://tickets.devcon.org',
6167
organizer: 'devcon',
6268
event: '8',
69+
// tickets.devcon.org is a Pretix-managed custom event domain — the
70+
// event is mounted at root, so user-facing URLs are /order/CODE/...
71+
// (not /devcon/8/order/CODE/...). See development.pretix.customDomain
72+
// for details.
73+
customDomain: true,
6374
ticketDiscountId: '2',
6475
defaultQuotaId: 116,
6576
testmode: false,
@@ -110,6 +121,19 @@ const ENV_CONFIG = {
110121

111122
export const TICKETING = ENV_CONFIG[TICKETING_ENV]
112123

124+
/** Build a user-facing Pretix URL that respects the event's custom-domain
125+
* setting. On a custom event domain (`tickets.devcon.org`) the event lives at
126+
* root: `/order/CODE/...`. On a legacy slug-based instance, the path needs the
127+
* `/{organizer}/{event}/` prefix. Pass the path INCLUDING leading slash, e.g.
128+
* `'/order/ABCDE/secret/'`. Returns an absolute URL. */
129+
export function pretixEventUrl(path: string): string {
130+
const base = TICKETING.pretix.baseUrl.replace(/\/$/, '')
131+
const eventPrefix = TICKETING.pretix.customDomain
132+
? ''
133+
: `/${TICKETING.pretix.organizer}/${TICKETING.pretix.event}`
134+
return `${base}${eventPrefix}${path}`
135+
}
136+
113137
/** Whether the chain environment is testnet (derived from config) */
114138
export const isTestnet = TICKETING.chainEnv !== 'mainnet'
115139

devcon/src/pages/api/x402/tickets/status.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import {
99
getPendingOrder,
1010
getCompletedOrder,
1111
} from 'services/ticketStore'
12-
import { TICKETING } from 'config/ticketing'
12+
import { pretixEventUrl } from 'config/ticketing'
1313

1414
function getTicketUrl(orderCode: string): string {
15-
const baseUrl = TICKETING.pretix.baseUrl.replace(/\/api\/v1\/?$/, '').replace(/\/$/, '')
16-
return `${baseUrl}/${TICKETING.pretix.organizer}/${TICKETING.pretix.event}/order/${orderCode}/`
15+
// `pretixEventUrl` respects the `customDomain` config flag — on Pretix
16+
// custom event domains the event lives at root (`/order/CODE/`), on legacy
17+
// slug-based instances it's under `/{organizer}/{event}/order/CODE/`.
18+
return pretixEventUrl(`/order/${orderCode}/`)
1719
}
1820

1921
interface StatusResponse {

devcon/src/pages/tickets/store/checkout.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Link } from 'components/common/link'
66
import { Wallet, CheckCircle, Lock, ChevronUp, ChevronDown, ArrowLeft, Check, Loader2, Minus, Plus, Tag, Monitor, Smartphone, Shield } from 'lucide-react'
77
import themes from '../../themes.module.scss'
88
import css from './checkout.module.scss'
9-
import { TICKETING } from 'config/ticketing'
9+
import { TICKETING, pretixEventUrl } from 'config/ticketing'
1010
import { isEmail } from 'utils/validators'
1111
import { COUNTRIES } from 'utils/countries'
1212
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
@@ -379,13 +379,14 @@ function CheckoutContent() {
379379
// from the plugin, redirect the buyer to Pretix's hosted shop where they
380380
// can use whatever payment Pretix has wired up (via wc_inject for crypto +
381381
// Stripe / SEPA for fiat). Honor the explicit `pretixRedirectUrl` admin
382-
// override if set; otherwise build the canonical shop URL from base + org +
383-
// event slugs. Trailing slash matters — Pretix's shop is a slash route.
382+
// override if set; otherwise build the canonical shop URL via
383+
// `pretixEventUrl` — drops the `/{org}/{event}/` path prefix on custom
384+
// domains (`tickets.devcon.org`) and keeps it for legacy slug-based
385+
// Pretix instances. Trailing slash matters — Pretix's shop is a slash route.
384386
const pretixShopUrl = (() => {
385387
const override = (TICKETING.checkout as { pretixRedirectUrl?: string }).pretixRedirectUrl
386388
if (override && override.trim()) return override.trim()
387-
const base = TICKETING.pretix.baseUrl.replace(/\/$/, '')
388-
return `${base}/${TICKETING.pretix.organizer}/${TICKETING.pretix.event}/`
389+
return pretixEventUrl('/')
389390
})()
390391
const { address, isConnected, chain, connector } = useAccount()
391392
// Reown AppKit hook — exposes the *actual* wallet on the other side of a

0 commit comments

Comments
 (0)