diff --git a/docs/superpowers/specs/2026-12-04-event-ticketing-design.md b/docs/superpowers/specs/2026-12-04-event-ticketing-design.md new file mode 100644 index 0000000..aca432a --- /dev/null +++ b/docs/superpowers/specs/2026-12-04-event-ticketing-design.md @@ -0,0 +1,233 @@ +# Event Ticketing: Design + +Date: 2026-12-04. Status: draft for owner review. + +## Intent + +Co-Lite is growing from an event lead-capture tool into an event hosting platform. The owner's roadmap (2026-12-04) is: + +1. Ticketing (this design). +2. Merch collected at events. +3. Merch sold as a standalone shop, with manual shipping. +4. Membership, with member prices, points and a member portal. +5. Self-serve SaaS sign-up with Free and Premium plans. + +Some events are free and some are paid. Free events keep today's lead flow unchanged. Paid events sell tickets. **Leads stay the core.** Every ticket buyer, and every attendee they name, becomes a lead on the event, so sales can follow up after a paid event as well as a free one. + +There is no payment gateway yet. Buyers pay outside Co-Lite, by bank transfer or the company's own payment link. Staff mark an order paid when the money arrives. + +## Goals + +- An organiser turns tickets on for an event. The organiser defines ticket types, each with a name, price, quantity and sales end date, and writes the payment instructions. +- A visitor requests tickets on a landing page through a new **Tickets** block. A request can hold up to 10 tickets across one or more types. The visitor gets an order with a private link. +- The order holds the seats for a set number of days (default 3, set per event) while it awaits payment, then expires on its own. +- Staff see each event's orders. They can mark an order paid, cancel an order, or cancel a single ticket. +- When an order is paid, each ticket gets its own QR code. + - The buyer can name an attendee for each ticket through the order link, and swap attendees until a ticket is checked in. + - Each named attendee gets their ticket by email. + - Tickets that are not named go to the buyer. +- At the door, staff open the ticket QR and check it in. An unpaid or cancelled ticket is clearly refused. For a ticket with no name, staff enter the attendee's name and contact details at check-in. +- The buyer becomes an event lead. Each named attendee also becomes an event lead. + +## Non-goals (this build) + +- **Payment gateway, online payment and refunds in Co-Lite.** Money moves outside. Only the order's status changes. +- **Receipts, invoices and SST.** The company issues these outside Co-Lite. +- **Merch products, stock and shipping.** The order model is shaped for them (see Data), but none is built. +- **Member accounts.** A buyer needs no login. Tickets belong to the person's mobile or email, so a future member account can claim them. +- **Seat maps, discount codes, waiting lists and ticket transfer between buyers.** +- **Currencies other than MYR.** + +## Anti-goals (a failure even if it works) + +- **Free events behave differently.** Events without tickets must keep every current registration, invite and check-in path unchanged. +- **Overselling.** More seats are held than a ticket type's quantity allows. +- **The order link leaks.** It shows the buyer's or attendees' details to anyone except the holder of that link. +- **Someone walks into a paid event without a paid ticket** through the self check-in walk-in form. + +## Constraints + +- **Stack and layering:** + - Events, leads, check-in and pages live in `solvway-services-counter`. + - Admin and public JSON endpoints go through `solvway-mobile-api`. + - Screens and public pages are in `solvway-admin-portal`. + - Emails go through `solvway-services-email`. +- **Company scoping:** every new table carries `company_id`, and all reads and writes are scoped as in `company-scoping`. +- **Rules shared with QR registration:** lead matching, normalisation, consent and the privacy notice follow the `qr-registration` rules. +- **Abuse limits:** public endpoints reuse the QR page's abuse limits. +- **Translations:** labels are in English and zh-CN, as in `ui-translations`. +- **Database changes:** DDL goes in the OpenSpec change folder. + +## Approaches + +1. **Built into Co-Lite (chosen).** Ticket tables sit on the event, a new Tickets block sits in the page builder, and the event gets a Tickets tab. Leads, check-in, capacity, emails and company scoping are all reused. A gateway later adds "pay now" to the same order. +2. **A separate ticketing service.** It would be cleaner to split out for SaaS, but it duplicates events, leads and check-in, and wiring it in costs much more before it brings any benefit. +3. **An outside platform** such as Eventbrite or Ticket2u. It's fastest, and payment is included. But the buyer data lives elsewhere, which works against becoming an event platform. + +The owner chose approach 1. + +## Decisions (owner) + +- Payment happens outside Co-Lite for now, and staff mark orders paid. +- Visitors request tickets on the event page. Staff do not issue them. +- One request can hold several tickets. The buyer names the attendees later. +- The order can hold any kind of item, ready for merch. Merch will be both collected at events and shipped (shipping is manual, with no courier integration), in later builds. +- Ticket buyers become leads. + +## Design + +### Turning tickets on + +- An event gets a **Tickets** switch, which is off by default. While it is off, the event behaves exactly as today. +- While it is on, the event has: + - **Ticket types.** Each has a name (up to 80 characters), a price in MYR (0 or more, stored in sen), a quantity (at least 1), an optional sales end date (default: the event's end date), a sort order and an enabled flag. + - **Payment instructions.** Free text up to 1,000 characters, shown on the thank-you page, the order page and the order email. Phone numbers, emails and links in it work, as in landing-page contact links. + - **Hold days.** 1 to 14, default 3. +- **Changing ticket types:** + - A ticket type with any orders cannot be deleted, only disabled. + - Its quantity cannot drop below the seats already held. + - A price change applies only to new orders, because each order line keeps its own price. + +### Seats + +- Seats are held by tickets in orders that are **Awaiting payment** or **Paid**, unless that ticket was cancelled. +- A type's seats left = its quantity minus its held seats. +- A request is refused if any type would go below 0. The check and the insert run in one transaction, with the event's ticket types locked, so two requests cannot take the last seat. +- **Event capacity:** when set, held tickets count toward it together with today's registered guests and walk-ins. Before the event days, a request that would go over capacity is refused, matching "Capacity before the event". Ticket types still cap sales at all times. + +### Tickets block (page builder) + +- **New block type TICKETS:** + - Its fields are the event, an optional heading and text, plus the standard Look, anchor and eyebrow. + - Only enabled, not-ended events of the page's company with Tickets on can be picked, matching the FORM block's event rules. +- **What the block shows:** + - Each enabled type, with its name, price as `RM 150.00` or `Free`, and either seats left or "Sold out" / "Sales ended". + - Next to each type, a quantity picker from 0 to 10. The total across types is at most 10. + - The buyer's fields: + - name (required); + - email (required, because the order link and tickets go there); + - mobile (optional); + - company (optional); + - the privacy notice consent (required). +- **Closed state:** the block shows that ticket sales are closed when: + - the event is disabled or has ended; + - Tickets is off; + - the company has no privacy notice. +- **Submit:** + 1. Create the order. + 2. Show the thank-you page: the order reference, the lines and total, the payment instructions, the hold expiry date and time, and a "View your order" link. + 3. Email the same content to the buyer. + +**Free orders:** if every line is free (order total RM 0), the order is **Paid** at once and tickets are issued straight away. This gives organisers free events with tickets, for example to control entry. + +### Orders and order page + +- **Order states:** + - Awaiting payment; + - Paid; + - Cancelled (by staff); + - Expired (hold ran out). +- **Order reference:** a short one, such as `T-7K3M9Q`, for bank transfer references. It is separate from the unguessable link token. +- **Order page** `/o/`: + - It is public, open to anyone with the link. + - It shows the event, lines, total, status, the payment instructions while awaiting payment, and the hold expiry. + - **Once paid:** it lists the tickets with each attendee's name, a ticket link per ticket, and a form to name or rename each attendee (name, plus mobile or email). Each ticket and each attendee save stands alone. + - **Naming or renaming an attendee:** + - It issues a **new ticket code**, so the old QR stops working. + - It emails the new attendee their ticket. + - It is refused once that ticket is checked in. + - **What it never shows:** any details beyond what the buyer entered, and nothing about other orders. +- **Expiry:** a scheduled job in services-counter expires Awaiting-payment orders past their hold time and emails the buyer. Staff may mark an expired order paid only if its seats are still available, in which case it becomes Paid. + +### Tickets and the door + +- Each ticket has an unguessable code with the link `/t/`. The ticket email holds the QR image of that link. +- **Ticket page, public view:** + - It shows the event name, dates, location, ticket type, the attendee's first name and the QR image. + - It shows the ticket's state, but for an unpaid, cancelled or expired ticket it shows "This ticket is not valid" instead of the QR. +- **Ticket page, staff view:** + - Who gets it: someone signed in to the admin portal on the same site, with `BO_EVENTS` for that event's company. + - For a valid ticket on an event day, it adds a large state banner and a **Check in** button. + - For an unnamed ticket, it shows name and mobile-or-email fields first. + - **Checking in:** + - It marks the ticket checked in. + - It captures or links the attendee as an event lead, using the QR registration matching. + - It marks that event lead attended. + - **Refusals:** a second check-in shows "Already checked in at