Skip to content

Fix ticket capacity oversell during pending checkouts - #2

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-861e
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-861e

Conversation

@cursor

@cursor cursor Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

Ticket capacity was checked only when a pending checkout row was created, while tickets_sold was incremented later when Paystack confirmed payment. Multiple customers could start checkout for the last available ticket before either paid; once both payments succeeded, both tickets were marked paid and tickets_sold could exceed total_tickets, causing oversold events and invalid door capacity.

Root cause

Pending ticket payment references did not reserve capacity, stale pending rows were hard-deleted, and payment completion unconditionally incremented tickets_sold.

Fix

  • Add per-ticket capacity_reserved tracking and migrate existing pending tickets into active reservations.
  • Count active reservations during web and USSD ticket checkout capacity checks.
  • Convert reserved capacity into tickets_sold only when payment completes.
  • Expire stale pending reservations without deleting payment references, allowing late Paystack reconciliation.
  • Release reservations when Paystack initialization/direct charge fails.
  • Update public event availability to include active reservations.

Validation

  • Ran npm test in backend (30 tests passed).
  • Added focused tests for reserved ticket completion, capacity exhaustion with active reservations, and reservation release on initialization failure.
Open in Web View Automation 

Co-authored-by: Richard Kwaku Opoku <iamroidev@users.noreply.github.com>
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
voteeq Ready Ready Preview, Comment Jul 8, 2026 11:11am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant