Paid event bookings — recoverable by design, and a safer repair
22-07-2026What's new
Fixes — a successful payment always completes its booking
- A rotated booking link can no longer strand a paid booking. Reconciliation used to start
by looking the invitation up by its link token. If that link was regenerated between starting a payment and the payment settling, reconciliation gave up — and Stripe could report the payment as done while the booking never completed. Payments now carry the invitation's permanent identity, and every path (the browser confirmation and the background safety net) completes the booking by that identity, not the link. As a side benefit, the one-time booking link is no longer stored at the payment provider at all.
- A transient database hiccup mid-settle is now retried, not treated as final. A momentary
database error while confirming a booking used to be collapsed into "invalid link" or "event not found" — reasons the payment processor treats as permanent, so it never tried again. Those transient faults are now clearly separated from genuinely-missing records: a real hiccup is retried automatically (the processor redelivers and it self-heals), while a genuinely invalid link or missing event is still handled once and not looped. No customer-facing detail, link or payment reference is ever exposed in logs.
- Marking the invitation "used" can no longer silently fail. If the final step that marks an
invitation used doesn't confirm, that is now a retryable outcome that heals on the next attempt — the booking confirmation email still fires exactly once and is never lost or duplicated on the retry. In the rare case where the invitation record has genuinely been deleted after the payment, the system records an operator-visible reconciliation note (in the existing payments health surface) rather than retrying forever. Throughout, no money, booking, invoice line or email is ever duplicated by a retry.
Behind the scenes — a safer historical repair and a stricter check
- The one-off repair for any historical bookings left in the old state was **rewritten to be
safer**: it targets exactly the affected invitations (by permanent identity, one row each even where old data is messy), runs entirely as a single self-checking transaction that rolls itself back on any integrity problem, uses a throwaway in-transaction working set instead of leaving a copy of member data behind, and only ever touches the "used" flag — never a price, booking, status or waitlist. A read-only diagnostic remains the required first step. Authored and rehearsed against a local copy of the platform only; nothing has been run against live data.
- The Phase 2C database-permission postflight (the after-apply verification for the proposed
service-role-only tightening) is now signature-exact: it checks each of the six functions by its precise definition, so a missing function shows up as a visible failure and an unexpected duplicate can never be mistaken for the real one. No permission change; nothing applied to live.
Final closure — the same path, made retry-proof end to end
- Starting a booking payment twice can no longer create two payment attempts. The booking's
payment is keyed on the invitation's permanent identity, so a double-tap, a refresh, or an automatic retry while starting checkout resolves to the *same* payment instead of opening a second one.
- **If your booking link changes while you're answering its questions, you're asked to refresh
rather than paying against a stale link.** The answers you give to a booking's requirements are saved against the invitation's permanent identity; if that link is regenerated at the same moment, checkout now stops and asks you to reopen the up-to-date link instead of quietly losing your answers or taking a payment that can't be matched to your booking.
- A failed invoice write during settlement is now retried, not reported as done. Completing a
paid booking writes an invoice; if that write doesn't confirm, the booking is no longer marked settled — the payment processor redelivers and it heals, and the retry never duplicates the invoice, the money or the booking.
- The payments health page names each reconciliation note for what it is. Operator notes used
to all read as "a provider payment missing from the ledger". They're now labelled honestly by kind — a provider payment awaiting its ledger entry, an invoice still queued for automatic line-item repair, an invoice the automatic repair has given up on (flagged for a person to fix by hand), or a paid booking whose invitation record was removed — each with a plain recommended action. Notes that need a person are now visually distinct from the ones that will heal on their own, and any unrecognised note shows as "manual review required". No member personal details are shown.
- A paid booking payment can only be started by the club the booking belongs to. As a
defence-in-depth tightening, starting a paid event-booking payment now confirms the booking invitation belongs to the club making the request before any card payment is set up, so a payment can never be taken into one club's account for a booking that belongs to another. Free open-to-group bookings are unaffected.
Faster, risk-based development checks
- Reorganised the permanent developer instructions into a short always-on
contract plus focused frontend, server, money, database, testing and release guides. The underlying tenant, money, database-authority and delivery protections remain in place, while ordinary UI and copy work no longer carries the same process burden as a payment or database-authority change.
- Added
verify:quick,verify:server,verify:criticalandverify:release
commands so checks scale with the risk of a change. The full test, lint and production-build battery remains mandatory at phase and release boundaries.
Paid event bookings — final correctness pass
A closing pass over the paid event-booking path to remove the last silent-failure and duplicate-payment gaps.
- A free event can no longer be paid for by accident. Starting a card payment for an event
that doesn't require payment is now refused outright — no charge, no half-made booking. Free bookings continue to use the normal (no-payment) booking flow.
- A booking link that isn't yours is rejected the same as an invalid one. A booking link is
checked against the club making the request before anything else, and a link belonging to another club is refused with the exact same message as a bad link — it never reveals whether the place is used, booked or paid.
- **A momentary database error while starting a booking is treated as an error, not as "no
booking".** Every check made before a card payment is set up now stops safely on a real database fault instead of mistaking it for "link invalid" or "nothing booked" and letting a charge through.
- A duplicate or mismatched payment is now surfaced for review, never silently accepted. If a
booking that's already paid receives a second, different payment — or its invoice was settled by a different payment, or is in a state that can't be settled, or has gone missing — the system records a clear note on the payments health page for an operator to review and refund by hand. It never auto-refunds and never quietly acknowledges a second charge, and a retry never creates duplicates.
- An invoice that can't be settled is flagged, not reported as done. Completing a booking only
accepts an invoice actually settled under that payment; a voided, cancelled or wrong-payment invoice is recorded for review rather than treated as complete.
- A booking's invoice is never left half-made by a database hiccup. If looking up who to bill
fails, the booking is retried later rather than an invoice being created without a billing household.
Paid event bookings — final edge-case closure
- An incomplete event-payment request can no longer create an untraceable charge. Event
payments now require both the event and its booking-link credential before Stripe is contacted, including when a signed-in staff member makes the request. A malformed request is refused rather than creating a payment that the background confirmation path cannot match back to a booking.
- A paid event must have a real server-side price. If an event is marked as requiring payment but
its stored price is zero or missing, checkout stops before Stripe and asks the member to contact the club. The browser can never choose an arbitrary amount for a misconfigured event.
- Two confirmation requests racing each other preserve the winning booking's payment truth. The
losing request now rereads the booking's paid state, invoice and payment reference under the same club before doing anything else. The same payment remains an idempotent retry; a different payment becomes an operator-visible conflict; a cancelled row is never treated as a successful claim.
- Members are no longer promised an automatic fix when a payment needs human review. Retryable
database interruptions still show "Payment received" and continue automatically. A terminal payment conflict instead shows a separate, calm review message with the payment reference and a clear instruction not to pay again. No provider, invoice or database migration is required for this pass.
Paid event bookings — payment identity closure
- A cancelled booking with previous payment history can no longer be charged again automatically.
Cancelled rows deliberately retain their invoice, payment reference and paid amount for accounting. Checkout now recognises that history and asks the member to contact the club instead of creating a new charge that could overwrite the earlier payment trail. A clean cancelled attempt that never reached payment can still be retried normally.
- A pending booking's payment reference can no longer be overwritten by a competing payment. The
final paid transition is conditional on both the booking state and PaymentIntent identity. If two confirmations race, the loser rereads the winner and succeeds only when it proves the same payment; a different payment or changed booking state is recorded for operator review.
- **Legacy paid bookings without a stored payment identity are no longer silently matched to whichever
payment arrives next.** They are surfaced as a manual reconciliation item so the provider and invoice records can be compared safely. Transient read/write uncertainty remains retryable, and no automatic refund is attempted.
- Cancelled-row reuse now has the same guard inside the database lock. A proposed, owner-apply
claim_event_slot corrective refuses to reactivate a cancelled row carrying an old invoice, payment reference, paid amount or unknown payment state. It preserves every accounting field, returns a stable refusal code, and has been applied/reapplied and rehearsed on local Docker only. No remote SQL was run.
Register coach selection
- Selecting a coach or volunteer now responds immediately and survives a response retry. The core
register assignment is returned before the best-effort activity log runs, and an exact duplicate insert is reread as the already-saved assignment instead of being shown as a false error. Coach, volunteer and attendance-state controls now show their own busy state and keep a full mobile tap target, preventing uncertain double taps while the request is in flight.
- A coach or volunteer can only be added if they really belong to this club and this register.
Adding someone to a class now checks the person against the club before anything is saved, and accepts exactly one person per assignment. A member who has left, or who isn't marked as a coach (or volunteer) for the register, is refused with a clear message instead of being written to the class. A person from another club is refused with exactly the same message as an unknown one, so nothing can be learned by guessing. If the check itself can't complete, the assignment is refused rather than saved on an unverified person, and the class date must be a real calendar date — "31 February", a date with a time stuck on the end, or anything else malformed is rejected. Removing or restatusing an existing entry is unchanged, so historical records stay editable.
Grading-day save feedback
- Short connection blips no longer flash a worrying pending-save warning at examiners. Notes are
still stored safely and retried immediately, but the warning now waits ten seconds before appearing. If the retry succeeds during that grace period, no banner is shown; a genuinely unsent note remains visible with its existing retry control until the server confirms it.
Member portal Pulse
- Class feedback now follows the member selected in the household switcher. Pulse prompts are
loaded only for that active member, so changing between siblings cannot show another member's sessions or leave the previous member's prompt on screen. When the selected member has more than one request waiting, a small count badge shows how many there are.
Register — the right people, and only this club's people
- A class register can no longer show a name from another club. The links between a class and
the coach, volunteer or member assigned to it record only who they point at, not which club they belong to. Adding someone is now checked (see above), but an assignment written before that check existed could still name a person from a different club — and the register would have displayed their name and email. Both ways the register is read now prove every person against the club that owns the class before showing anything: a member must belong to that club, and a coach or volunteer must genuinely have access to it. Anything that cannot be proven is simply left off the register — the record itself is untouched — and a coach who legitimately works across two clubs still appears in both. If the check itself cannot complete, the register refuses to load rather than showing an unverified name.
- Operator note. A read-only count of any affected historical rows is available at
scripts/check-lesson-staff-person-integrity.sql (counts only — it deliberately returns no names or email addresses), and two reviewed database files are prepared and locally rehearsed: one stops malformed assignments being written by anything at all, the other applies the same club check inside the register's own database routine. Neither is applied and neither changes live behaviour until the owner runs them; the register is already protected without them. Nothing existing is deleted or rewritten by either file.
Member portal Pulse
- The "waiting" count on the feedback card now stays accurate after a refresh. The badge showing
how many class feedback requests are still outstanding could drop to zero — or hide itself — once the page quietly refreshed its data in the background, because the requests just answered were taken off the total twice. The count now falls as each card is answered and holds steady across the refresh, so it always matches what is genuinely still waiting for the next visit. The three-cards-per-visit limit is unchanged.