Skip to content

C4P voting system with quantity-aware Stripe ticket tiers#40

Open
Lojhan wants to merge 2 commits into
mainfrom
feat/c4p-voting-quantity-tiers
Open

C4P voting system with quantity-aware Stripe ticket tiers#40
Lojhan wants to merge 2 commits into
mainfrom
feat/c4p-voting-quantity-tiers

Conversation

@Lojhan
Copy link
Copy Markdown
Collaborator

@Lojhan Lojhan commented May 5, 2026

Summary

  • Date-based ticket tiers for C4P voting: early bird (≤ Dec 31, 2026) grants 3 votes per ticket, regular grants 1 vote per ticket
  • Quantity-aware purchases: ticket quantity read from Stripe checkout metadata, votes = quantity × tier weight
  • Accumulative repurchase: if a user buys again, quantity and votes are added to their existing totals
  • Full C4P voting system: auth (login/code), voting state endpoint, vote cast/retract, admin batch user creation
  • Voting UI: components, pages, modals, and i18n translations
  • Stripe fetch script: fetches customers, payment intents, and charges to transactions.json (gitignored)

Key changes

Area Files
Stripe webhook src/server/routes/stripe-webhook.ts — date-based tier detection, quantity support
User repository src/server/repositories/user.ts — quantity column, accumulative upsert
Database schema resources/schema.sqlquantity INTEGER NOT NULL DEFAULT 1
Auth system src/server/middleware/auth.ts, src/server/lib/tokens.ts, src/server/routes/auth/*
Voting routes src/server/routes/voting-state.ts, voting-vote.ts, users-batch.ts
Voting UI src/website/components/voting/*, src/website/pages/voting/*, src/website/hooks/voting/*
i18n i18n/*/code.json — voting translations
Tests 29 test files, all passing
Tooling scripts/fetch-stripe-data.ts, scripts/seed.ts

Security

  • src/server/routes/transactions.json added to .gitignore (contains Stripe data)
  • .dev.vars already gitignored (contains live keys)
  • Deleted stripe_key file from routes directory

Deployment note

Run DB migration on production D1 before deploying:

ALTER TABLE users ADD COLUMN quantity INTEGER NOT NULL DEFAULT 1;

Lojhan added 2 commits May 5, 2026 19:50
- Date-based ticket tiers: early bird (≤ Dec 31, 2026) = 3 votes/ticket, regular = 1 vote/ticket
- Quantity from Stripe checkout metadata (default 1), votes = quantity × weight
- Accumulative upsert on re-purchase (adds quantity and votes)
- Added quantity column to users schema
- Stripe fetch script for customers, payment intents, and charges
- Full C4P voting system: auth, voting state, cast/retract votes
- Voting UI components and pages
- i18n translations for voting flow
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