Guides
The checkout recipe
Availability, hold, pay, order, with the price breakdown and the countdown.
You build the checkout page and take the money. RCMS Tickets keeps the stock honest and, once an order exists, owns the ticket. A checkout is four steps, in this order, and the order is the point:
- Availability. What can be bought right now.
- Hold. Reserve the tickets and get the one price you may show. The clock starts.
- Pay. Charge the card with your own processor, for exactly the hold's total.
- Order. Turn the hold into an order with the payment. The tickets are issued.
The samples on this page continue the quickstart: tickets, event, ga and parking are the ones it made.
1. Availability#
Call it when the page loads, so sold-out types show as sold out before anyone tries to buy them.
const availability = await tickets.events.availability(event);
for (const type of availability.ticket_types) {
// state is available, low or sold_out. remaining is given only when low or sold out.
console.log(type.name, type.state, type.price.amount);
}A type is low at 10 or fewer left, or 10% of its capacity, whichever is more. Hidden types and add-ons do not show here until a code that unlocks them is sent: GET /v1/events/{id}/availability with the code in a Tickets-Code header lists them (?code= is for older callers: a code in a URL is kept in request logs; an MCP agent passes code to get_availability). To check whether a code works use POST /v1/events/{id}/code_check, which takes it in the body.
2. Hold#
Send the items, the code if the buyer typed one, and the buyer's email if your checkout already has it. With the email, an expired hold tells you who walked away, so you can follow up.
const held = await tickets.holds.create({
event,
items: [{ ticket_type: ga, quantity: 2 }],
code: 'WELCOME10',
email: 'maria@example.com',
});
console.log(held.status, held.price.total.amount); // active 9000A hold lasts 10 minutes. Ask for longer with duration_minutes, up to 30. While it lives, the tickets cannot be sold to anyone else and a limited code's use is reserved for this buyer, so the order never fails on the code.
The price breakdown#
hold.price is what you show. Read it, never rebuild it.
| Field | What it is |
|---|---|
lines[] | One per ticket type or add-on: quantity, unit_price, amount (unit price times quantity), discount, fees[], tax and total. |
lines[].fees[] | A fee, with passed_on. true is added to what the buyer pays. false is absorbed by the organizer: it is shown in the breakdown and not charged. |
order_fees[] | Fees charged once per order, not per ticket. |
subtotal | The sum of the line amounts. |
discount | The sum of the line discounts. code says which code, and what it took off. |
fees | Every passed-on fee, line and order. fees_absorbed is the ones that are not charged. |
tax | The tax on the lines and on taxable fees. Percentages round half up, per line. |
total | subtotal − discount + fees + tax: what the buyer pays. This is the number you charge. |
All money is { amount, currency } with amount in whole minor units. Show it with your own formatting; do not divide and multiply it as a float.
for (const line of held.price.lines) {
console.log(`${line.quantity} × ${line.name}`, line.unit_price.amount, 'less', line.discount.amount, 'fees', line.fees.map((f) => f.amount.amount), 'tax', line.tax.amount);
}The countdown#
Show the buyer how long they have. hold.expires_at is the instant it ends. Count down to it, and compare it with the Date header of the answer that carried it rather than with the buyer's own clock, so a wrong clock on a phone does not cut a sale short. The checkout kit does this for you.
At two minutes left, offer "Need more time?", which extends the hold once. At zero, say so, and offer to hold the same tickets again.
const extended = await tickets.holds.extend(held.id, {});
console.log(extended.extended, extended.status); // true activeA hold can be extended once (hold_extension_used after that). An expired hold answers hold_expired and has given its tickets back: make a new hold, and show the price again, because it may have changed.
If the buyer leaves, release the hold so the tickets are free at once instead of when the clock ends:
await tickets.holds.release(held.id);3. Pay#
Charge the card with your processor for hold.price.total.amount, in the hold's currency. Give your processor an idempotency key made from the hold's id, so a double click is one charge.
Before you charge, you can ask for every check the order will make: the hold, the event, the buyer, the consent and the answers. A refusal comes back with the field's name and nothing has been charged, so a bad email never costs a charge and a refund.
const next = await tickets.holds.create({ event, items: [{ ticket_type: ga, quantity: 1 }], code: 'WELCOME10' });
const check = await tickets.orders.check({
hold: next.id,
buyer: { name: 'Maria Delgado', email: 'maria@example.com' },
});
console.log(check.valid); // true4. Order#
Send the hold, the buyer and the payment. With a processor of your own the payment is external: your processor's id for the charge and the amount you took.
const placed = await tickets.orders.create({
hold: next.id,
buyer: { name: 'Maria Delgado', email: 'maria@example.com', marketing: { email: true } },
payment: { provider: 'external', reference: `pi_docs_${next.id}`, amount: next.price.total.amount },
});
console.log(placed.status, placed.amount_paid.amount); // paid 4500- The
referenceis your processor's id, so it's unique in the org and mode (payment_reference_conflictotherwise; this sample makes one from the hold). Sending the same reference on the same hold again answers the order it already made, so a retry after a timeout is safe. The same reference on a different hold answerspayment_reference_conflict. - The amount must equal the hold's total (
amount_mismatch). The hold becomes one order, once. buyer.marketingrecords consent, with the time and the words shown. The event needs its words first:consent_textson the event, one per channel, each with aversionand thetextyou show beside the box. With no words for a channel, atrueisn't consent we can stand behind: the sale goes on, but the order answersgranted: falsewithunrecorded: "no_consent_text", and the person isn't in the contacts export, whoseleft_out_no_wordscounts them. Only ask for what you will use.- The confirmation email goes to the buyer unless you send
notify: { email: false }. In test mode it reaches only members of your organization. - In test mode the
testprovider stands in for a processor: test mode and test cards.
Set an event's words like this, and show them exactly beside the box, never ticked for the buyer. A changed wording gets a new version.
await tickets.events.update(event, {
consent_texts: { email: { version: '2027-03-01', text: 'Email me news and offers.' }, sms: null },
});A free order#
A hold whose total is 0, from a 100% code say, still needs its payment. Send { provider: 'external', reference: 'your-own-id', amount: 0 }: the reference is yours, and no money moves. An order you are giving away yourself is a comp instead (POST /v1/comps).
A Square order may answer pending#
With payment: { provider: 'square', source_id } the API holds the money on the card, makes the order, then takes the money. If that last step has no answer before the request ends, the order answers status: "pending" and tickets_status: "none". The sale is made and the money is not settled yet.
- Never charge again. The hold is used, and the order owns the payment. Sending the same request again answers the same order, and asks Square again.
- Wait for the
order.paidwebhook, or read the order again (GET /v1/orders/{id}). It is usually seconds. A sweep behind it asks Square about any order still pending after 2 minutes. - Tell the buyer it is still going through, and do not show tickets yet. The tickets and the confirmation email follow
order.paid. - If Square cancels or fails the payment, the order becomes
cancelled(order.cancelled) and its tickets go back on sale.
An external or test order is paid as soon as it exists, unless you send held: true on an external payment. That says your processor is holding the money (a card authorization) and you will take it after the order exists. The order is then pending with no tickets and no money counted. When your processor has taken it, call POST /v1/orders/{id}/external_payment with outcome: "captured" and reference, the reference the held payment was sent with (your processor's payment id): the order becomes paid and its tickets issue. If it can never take it, send outcome: "lost": the order is cancelled, its seats go back and the buyer is told the card was not charged. Before taking money from an order that has waited, send outcome: "may_capture": void_me means the event was cancelled or this buyer has bought again, so void it and send lost with why. A cancelled order's payment_end says what is known of the money: not_charged, not_confirmed or taken_after_end. A repeat changes nothing. This is your word, as the payment always was: RCMS Tickets cannot see your processor. The square provider is not proven against Square's sandbox yet.
If the order call fails after the charge#
This is the case to plan for, because the buyer's money has moved.
- A 400 or a 409 that names a field (a bad email, a missing answer): nothing was made. Fix the field and send the same payment again. It makes one order and needs no new charge.
- A timeout, a connection error, or 503
outcome_unknown: the order may exist. Send the same request again with the sameIdempotency-Key, or the same payment reference. You get the order that exists, or a new one, never two. hold_expiredafter the charge: the tickets went back on sale before the order was made. Refund the charge with your processor, and tell the buyer. Keep the hold alive until the charge is settled to make this rare.
Asking buyers things, and how a ticket looks#
All of these are set on the event, with PATCH /v1/events/{id}, in POST /v1/events, or by a whole setup. The kit and hosted links read them and ask for you. In your own checkout, read them from the event and show them.
- Questions.
questionson the event, or on a ticket type: a date of birth, a shirt size, an address. Each has akey, alabel, akind(date,textand so on) and whether it'srequired. Send what they answered asanswerson the order, by key.settings.answers_retention_dayssets when sensitive answers are erased. - Consent words.
consent_texts, one per channel, as above. Without them nothing a buyer ticks is on record. - The ticket's art.
POST /v1/events/{id}/imagesuploads an image, andticket_designon the event names it, with its colors. It reaches the ticket page, the email and Wallet passes, and passes already out update by themselves.
A whole question and a whole fee. Every field is required, so send them all, with null where one doesn't apply. fees go on the event (once per order), a ticket type (per ticket) or an add-on (per unit), and a fee has exactly one of amount (minor units) and rate_bps.
{ "key": "shirt_size", "label": "Shirt size", "kind": "select", "required": true, "scope": "ticket", "options": ["S", "M", "L"], "help": null, "sensitive": false }{ "name": "Service fee", "amount": 500, "rate_bps": null, "passed_on": true, "taxable": false }Tickets#
The answer carries tickets, each with its own private page url. For the Wallet links, read the tickets: GET /v1/tickets?order=ord_.... When tickets_status is pending, they are not issued yet: read the order again, or wait for the order.tickets_issued webhook.