Skip to content

Build a Ticket Shop for a Small Music Venue

Davor Minchorov•Intermediate•7 to 8 weekends•October 29, 2026

A small music venue sold 311 standing tickets for a floor that holds 300 when a gig went on presale at 10:00. You will build the replacement ticket shop, from publishing a gig through ticket holds and payment to admission at the door, and prove with a simulated presale that no ticket is sold twice and every payment ends in a ticket or a refund, even when the payment provider is late, repeats itself or sends messages out of order.

The brief

The client

I run a music venue with a 300-person standing floor and a 50-seat balcony, and we put on about 120 gigs a year. Tickets sell through a page on our own website that checks how many are left, saves the booking in a second step, and sends the buyer to a payment link. When a sold-out gig went on presale at 10:00, about 500 fans hit the page in the first minute, two of them were told at 10:00:04 that they had the last two standing tickets, and by lunchtime we had sold 311 standing tickets for a floor that holds 300. The page also gave a buyer's tickets back after 10 minutes, so nine people who were still approving the payment in their banking app paid for tickets we had already sold again.

I refunded all 11 by hand in the payment dashboard and phoned the ones I could not reach before doors. I need the last ticket to go to exactly one fan, a payment that finishes late to be settled by a written rule, and a way to check before doors that every payment ended in a ticket or a refund.

The problem

The booking page decides whether tickets are free in one step and records the booking in another, so two requests that arrive together can both pass the first step. A hold on tickets and the payment for them run on separate clocks. The hold lasts 10 minutes, and a payment can finish after it, because the buyer's bank approval takes an unpredictable time and the payment provider's confirmation message can arrive late, twice, or in a different order than the events happened. Nothing today says what should happen when a payment lands on tickets that were already resold, so the answer depends on which page code ran last.

The venue cannot see this before it costs money. Tickets, bookings and payments live in one spreadsheet-shaped table that the booking page, the payment link and the door staff all write to. After a cancelled gig the manager refunds each buyer by hand, and a refund that is clicked twice is a second refund. The sold-out gig cost 11 refunds, a morning of apology calls and a touring band that watched a full house turn people away.

The client's name and figures are invented for this brief; the rules and the failures are ones that real businesses of this kind work with.

The spec

Requirements

  • Let staff publish a gig with several ticket types, each with a capacity, prices that change on a date and a sales window, all given in the venue's local time and read correctly across a clock change.
  • Let the public list upcoming gigs by date and see how many tickets of each type are left.
  • Hold tickets for a buyer for 10 minutes, never sell more than a ticket type's capacity however many buyers ask at the same moment, and give back the tickets of an abandoned checkout.
  • Show the all-in price, including the booking fee of 150 cents a ticket, before the buyer pays, and charge exactly that amount, with a bank approval step when the bank requires it.
  • Settle a payment that finishes after its hold ended by a written rule: the buyer gets the tickets if enough are still free, and otherwise the whole amount goes back.
  • Handle a provider message that arrives twice, late or out of order without selling a ticket twice or keeping money for no ticket.
  • Issue ticket codes that cannot be forged, and admit each ticket once at the door, including when two scanners read it at the same moment.
  • Cancel a gig and refund every order for it exactly once, even when a refund fails or the process dies halfway.
  • Erase a buyer's name and email on request after the gig has happened, keeping orders, payments and tickets identified by ID.
  • Check with one command that no ticket type has sold more than its capacity and that every successful payment ended in tickets or a refund.

Deliverables

  • Your repository starts the product and the payment provider you build with one documented command.
  • A README that takes a reviewer from a fresh clone to a bought ticket admitted at the door in 20 minutes, and lists the command for each test.
  • API documentation for what staff and the public send and receive: publishing a gig, quotes, orders, order status and cancelling a gig.
  • A guide for the people who build the door scanners: what a scanner sends, what it gets back and every reason a scan is refused.
  • A description of how a payment provider reports a payment to the product and how the product answers it.
  • A test suite that includes tests which really run at the same moment, plus the results of the simulated presale from the final Phase committed to your repository.
  • A way to run the venue's presale faster than real time and to cause the outside failures the brief names: a payment that finishes late, a message sent twice or out of order, a refund that fails once, a killed process and two scanners reading one code. It works in local and test environments only.
  • An operations note: what an operator can do after a crash to finish anything left half done, how to retry a refund that failed, and how to read the check command.

Out of scope

  • A fair queue, presale codes and a metered admission rate. A 350-ticket gig does not need a waiting room, and queue design is the subject of Build an Event Ticketing Platform, the next step up.
  • A limit on how many tickets one buyer can take across orders. A cap of 4 tickets of one ticket type in a single order is enough here.
  • Numbered seats and seat maps. The floor is standing, and a seat choice adds geometry the race does not need.
  • Changing a ticket type's capacity after it is published. It would move a number that holds already depend on.
  • Dynamic pricing, resale and ticket transfer. Each needs a rule this brief does not fix, and none changes the race.
  • Payouts to touring bands, ledgers and disputes. The venue pays acts by hand from a report.
  • Real payments and card data. You build a payment provider of your own, and the product never stores or logs a card number.
  • Rotating ticket codes and door work without a network. A scanner that cannot reach the product admits nobody.
  • Buyer accounts and logins, a front end, tax and more than one currency. A buyer is an email address, the product has no front end, and every amount is in euros.

Architectural constraints

  • A ticket type never has more tickets held and sold than its capacity, however many buyers ask at the same moment.
  • A hold lasts 600 seconds and is live only strictly before its end. The answer for a late payment never depends on whether the tickets of an ended hold have shown as free yet.
  • A quote is valid for 600 seconds, and the amount charged is exactly the amount quoted. Amounts are whole cents in euros.
  • A payment that finishes after its hold ended gets the tickets if enough are still free at that moment, and otherwise the whole amount goes back, booking fee included. A refused payment stays refused.
  • Messages from the payment provider are judged by when the provider says things happened and never by when they arrived. A repeated message changes nothing, and an older message that arrives later changes nothing.
  • Every successful payment ends in tickets or one full refund. No buyer is repaid twice, whatever is retried or killed.
  • A process killed at any moment loses no paid order and doubles no ticket, email or refund.
  • No card number is ever stored or logged.
  • Staff enter times in the venue's local time, Europe/Amsterdam, and the product reads them correctly on every day of the year. A local time that does not exist or happens twice is refused.
  • The payment provider is sent an order reference and an amount, never a buyer's name or email.
  • A buyer's name and email are erased on request once the gig has happened, while orders, payments, refunds and tickets stay, identified by ID. Dutch tax rules oblige the venue to keep its business records for 7 years, so those records stay for 7 years, and that duty is the client's own.

Prerequisites

You have built one application with a database on your own, and you can write a test suite for it. Any language and framework works. You do not need payments knowledge, and you do not need to know how a music venue sells tickets to a gig; the first Phase explains the business and the words the brief uses, and each Checkpoint explains the problem it checks. The race tests send several requests at the same moment to your running product, so you need to run it on your own machine the way it really runs, not as a stand-in that handles one request at a time. The beginner project Build a Box Office for a Village Hall Show covers the same domain at a smaller size and is not required.

Create a free accountSign in

Free to start. An account is what keeps track of the checkpoints you finish.

Phase 1

Work out the rules by hand

Produces two worked documents: the sale times and prices of one gig across a clock change, and who keeps the tickets when a payment lands late. No product code yet.

Research

Research

Architectural walkthrough

How a music venue sells tickets to a gig

The client runs a music venue with a 300-person standing floor and a 50-seat balcony. It puts on about 120 gigs a year. A gig has several ticket types, such as standing and balcony, and each type has its own capacity, price and sales window. Tickets go on sale at a set time, called a presale, and a popular gig sells out within minutes. At the last sold-out gig, about 500 fans hit the page in the first minute.

A fan picks tickets and the page holds them for 10 minutes while the fan pays. The price shown includes a booking fee of 150 cents a ticket, since a seller has to include unavoidable costs in the displayed price (the Dutch consumer regulator ACM said so in 2017). The fan pays through a payment provider, and the bank may ask the fan to approve the payment in a banking app. That approval takes as long as the fan takes. The provider then sends the venue a message that the payment finished, which can arrive late, twice or out of order.

A paid order becomes tickets with codes. At the door, staff scan each ticket once. If a gig is cancelled, every buyer is refunded. The venue refunds by hand in the payment provider's dashboard today.

The words this brief uses:

  • Gig: one event at the venue.

  • Ticket type: a kind of ticket for a gig, such as standing or balcony, with its own capacity and price.

  • Capacity: the most tickets of a type the venue may sell.

  • Presale: the sales window that opens a gig for buyers, here at 10:00 local time.

  • Hold: tickets kept for a buyer for 10 minutes while the buyer pays.

  • Booking fee: the 150 cents a ticket added to the price.

  • Bank approval: the buyer's confirmation of a payment in their banking app.

  • Provider message: the payment provider's report that a payment finished.

  • Door scan: staff reading a ticket's code at entry.

Why the two questions come first

The old booking page had no written rule for two questions, so the answer to each depended on which code ran last.

The first question is what a time means. Presale opens at 10:00, and 10:00 is a different instant in winter and in summer. On Sunday 28 Mar 2027 the clocks go forward at 02:00, so a price change planned for 7 days after the opening arrives at 11:00 local if someone adds 168 hours, and at 10:00 if someone adds 7 calendar days. For that extra hour the venue sells at the old price to whoever is on the page, and nobody notices until a buyer quotes the difference.

The second question is who keeps the tickets when a payment finishes after the 10-minute hold has ended. The buyer's bank approval takes as long as the buyer takes. On the sold-out gig nine buyers approved a payment after their tickets had been sold again. The client refunded all 11 oversold buyers by hand and phoned the ones it could not reach before doors.

You work both out by hand first because every later Checkpoint takes a number or a rule from these two documents. A Checkpoint built against a rule nobody wrote down has an answer you cannot check.

Phase 2

Put gigs on sale

Produces gigs that staff publish with ticket types, prices that change on a date and sales windows read in the venue's local time, and a public listing that shows how many tickets are left. Holds and selling come in the next Phase.

Implementation

Implementation

Testing

Architectural walkthrough

Two things go wrong before a single ticket is sold. The first is time. Staff type local times, and the product has to read them the way staff meant them on every day of the year, including the day the clocks change. A sale that opens an hour early or a price that rises an hour late hits all 500 fans at once.

The second is a process that dies in the middle of publishing.

The Phase ends with a published gig that shows exactly its capacity on the public listing, however many times the process died and restarted on the way.

Phase 3

Hold and sell tickets

Produces holds that give a buyer 10 minutes with the tickets, tickets that return when a hold runs out, a rule for a payment that finishes after its hold, and tests that race buyers for the last ticket. Checkout and payment come in later Phases, so tests drive this Phase through ways you document.

Implementation

Implementation

Implementation

Testing

Architectural walkthrough

This Phase is the centre of the Project. It prevents the client's 311 tickets for a floor of 300. Two of those came from a check followed by a save: two requests both saw tickets left, and both were told yes. Nine came from tickets given back after 10 minutes while buyers were still approving the payment in their banking app.

A race has no cure that works most of the time. At 10:00 on a presale morning, requests for the last ticket arrive within milliseconds of each other, and a product that is right in a test that sends them one after another is wrong in front of 500 fans. The same goes for the same request sent twice at once, which a double click produces all the time.

A hold is a promise that lasts 600 seconds, and a payment finishes whenever the bank lets it. The two clocks disagree for any buyer whose approval takes longer than the hold. The client wants a written answer for that buyer, and the answer must come out the same whether or not the tickets of the ended hold had shown as free again when the payment arrived.

Checkout and payment do not exist yet. For this Phase you document a way for tests to ask the product to hold tickets for an order reference and to report that a payment for a hold finished. These ways stay for the tests and real traffic replaces them in Phases 4 and 5.

Phase 4

Take orders

Produces an all-in price quote, a checkout that takes the tickets for a buyer, and orders that end together with their tickets when nobody pays. No payment is taken yet, so an order only waits for one.

Implementation

Implementation

Testing

Architectural walkthrough

Three failures come back through a new door once buyers start checking out. The first is a price that changes after the buyer saw it. A checkout that adds the booking fee when the payment starts charges an amount the buyer never agreed to, and the client answers for it.

The second is a checkout that happens twice, from a double click or a request sent again after a timeout.

The third is an order that nobody pays for. Buyers close the tab, banks decline and processes die halfway through a checkout. An order that keeps its tickets forever sells out a gig to people who never pay, and an order that gives them back while the buyer is still paying is how the client ended up with nine refunds. The client wants both outcomes to be visible to the buyer in plain words: waiting for payment, or expired.

An expired order stays on record with its amount, because in Phase 5 a payment can still arrive for it.

Phase 5

Take payments

Produces a payment provider you control, the path from a started payment to a paid order or one full refund, and tests of every late, repeated and out-of-order case. Tickets do not exist yet, so the proof ends at a sale or a refund.

Implementation

Implementation

Implementation

Implementation

Testing

Architectural walkthrough

A payment provider tells the product about a payment by sending messages, and the messages have three habits. They arrive late, because a bank approval takes as long as the buyer takes. They arrive twice. They arrive in a different order than the events happened. Stripe's webhook documentation (https://docs.stripe.com/webhooks) says it does not guarantee delivery "in the order that they're generated" and that an endpoint "might occasionally receive the same event more than once".

Each habit costs the client money. A message that arrives twice can sell tickets twice or repay a buyer twice. A "failed" message that arrives after a "succeeded" message can cancel a sale the buyer already paid for. A "succeeded" message that arrives after the order expired puts the client where it was with the nine buyers: money taken for tickets that may belong to someone else.

A crash adds a fourth case. The process can die after the provider took the money and before the product wrote it down, or after it decided to refund and before it knew whether the refund went through. In both, the client finds out when a buyer phones.

You build the provider yourself so that every one of these happens on command. Tested only against a well-behaved provider, the rules are untested.

Phase 6

Issue tickets, cancel and prove

Produces ticket codes, admission at the door, gig cancellation with refunds, buyer erasure, and a simulated presale with a command that checks the whole product.

Implementation

Implementation

Implementation

Implementation

Testing

Architectural walkthrough

The failures in this Phase are the ones the client has not met yet: a ticket code read by two scanners at the same moment or invented by someone who never paid, a cancelled gig whose refunds stop halfway or repeat, and a buyer's name left behind in a copy nobody looks at.

The last Checkpoint is the proof. A simulator plays 800 buyers, late payments, repeated and reordered messages, a killed process and doubled scanners against the running product, and one command reports whether the numbers add up.

Architectural walkthrough

The last ticket

The old page checked how many tickets were left in one step and saved the booking in a second step. At 10:00 about 500 fans arrived in the first minute, and two of them were told at 10:00:04 that they had the last two standing tickets. Any product that looks first and saves afterwards sells the same ticket twice when two requests arrive close together. The sold-out gig cost 311 tickets for a floor of 300, 11 refunds by hand and a touring band that watched a full house turn people away.

Check this in your build by running your own race, and then break the product on purpose. If the race tests still pass on a version that looks first and saves afterwards, they are not racing anything.

A payment that finishes after the hold

The hold lasts 10 minutes and the buyer's bank approval takes as long as it takes. Nine buyers paid for tickets that had been sold again while they were approving. With no written rule, the answer depends on which code ran last, and the client learns it from a buyer at the door.

Check three payments for the same order: one at 4 minutes, one at 11 minutes with tickets free and one at 11 minutes with tickets gone. Each ends in tickets or a full refund, and the answer does not change with whether the tickets of the ended hold have shown as free yet.

Messages that arrive late, twice or out of order

The payment provider tells the product about a payment by sending messages. Stripe's webhook documentation (https://docs.stripe.com/webhooks) says it does not guarantee delivery "in the order that they're generated" and that an endpoint "might occasionally receive the same event more than once". A repeated "paid" message can sell tickets twice or repay a buyer twice. A "failed" message that happened first and arrived last can cancel a sale the buyer already paid for, and the client holds money for an order that says payment failed.

Check that every message your provider can send, in every order it can send them, ends in one outcome per order.

A crash between saving and what follows

A process can die after it saves a gig and before the tickets go on sale, after it takes the tickets and before it saves the order, after the provider took the money and before the product wrote it down, and after it decided to refund and before it knew whether the refund went through. Each leaves a loss the client finds out about from a buyer: a gig with no tickets, tickets nobody owns, a payment with no ticket, or a buyer repaid twice.

Check each by killing the process at that moment, restarting it and counting what exists. The count is the same as if nothing had happened.

Two scanners, one ticket

A photograph of a ticket code shown on two phones lets two people in on one ticket when two scanners read it at the same moment. The floor then holds one more person than the venue sold tickets for. A code that anyone can invent lets in people who never paid.

Cancelling a gig and erasing a buyer

A cancelled gig with many paid orders is refunded one order at a time. A request that stops at the first error leaves some buyers repaid and some not, and a retry can repay the same buyer again. An erasure request is only done when the name and email are gone from every copy, and the copies are in places nobody looks until a search for the name finds them, such as logs and anything else the product writes while it works.

Check both against the numbers: one refund per paid order and none for the rest, and a full search of everything the product keeps, its logs and the provider's records that finds no trace of the erased name.

Where it shows if you cut a corner

A race test that runs in one process passes on the broken version, and the simulated presale in the last Phase, with 800 buyers for 350 tickets, finds the oversold ticket the small tests missed. A provider you built to behave never exposes the late and reordered messages that real providers send. A refund you only tested once is repaid twice the first time the process dies mid-refund. The check command at the end names the order, the ticket type or the ticket that breaks a rule, and the committed results of three seeded runs show a reviewer that it can fail.