Repository navigation
feat(payments): pay-at-finalize frontend (itemized cost, payment dialogs, return page) - #1794
Draft
ArendPeter wants to merge 3 commits into
Draft
ArendPeter wants to merge 3 commits into
ArendPeter wants to merge 3 commits into
Conversation
Itemized cost on Publish & Share (#finalize-cost) and in the over-limit upload dialog, a Finalize dialog that proceeds to payment when something is owed, Stripe Checkout via POST /Election/:id/CheckoutSession, and a return page that waits for the entitlement grant before finalizing or reopening Add Voters. With the flag off the UI is unchanged. Shared: formatCount/formatCents, cartTotal, entitlementsAfter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Split payment components into default-exported files; hooks are named exports; URL/storage constants move to Payments/paymentsUtils. - Finalize dialog can't be dismissed by clicking outside, like today's confirm. - Finalize stays disabled until the roll is priced, so an owed election never gets the free confirm. - Returning from an upload checkout without the saved expectation shows the pending message instead of claiming the payment landed. - The upload dialog says how many voters were already added when the server's 402 backstop stopped an upload part-way. - "Proceed to payment" stays disabled while the browser leaves for Stripe. - Comma-format the voter-limit error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for bettervoting ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human Summary
This primarily adds an itemized quote above the finalize button for elections that require it. It also adds some copy in the add voter flow to clarify the process, and adjusts the confirmation popups after finalizing.
To account for additional voters after finalizing, this PR includes the quote in a popup once the voter limit is exceeded
This gives a frontend entry point to the stripe features that were added to the backend
Summary
Closes #1793. Stacked on #1792. Everything is behind a new frontend-only
FF_PAYMENTSflag; with it off the UI is unchanged (the stop-gap override message and today's confirm stay).Also: the "N voters, see the cost of finalizing" link on Manage Voters (drafts with a closed list), the two-line tier copy at the bottom of Add Voters (quote link in drafts only), and the removal of the old "approved for N" / "Free tier elections are limited to…" lines.
Evidence
Before: with
FF_PAYMENTSforced off, the newtesting/tests/payments.spec.tsfails 3/3.After: with it on, it passes 3/3:
#finalize-cost, the table ("Based on 150 voters", "From 100 to 200 · $6 per 100", Total $6), the dialog's "Proceed to payment ($6)" posts{ line_items: [{ voter_limit, quantity: 1, unit_entitlement: 100, unit_amount: 600 }] }, and the cancel return lands back on Publish & Share as a draft;Full Chromium Playwright suite: 15/15. Backend jest: 324/324 (new
numberFormatandcartTotal/entitlementsAftertests).Manual end-to-end against Stripe test checkout with
stripe listenforwarding to the webhook:This ran before the review-fix commit, which changed the return page's "no saved expectation" path and split the components into files.
Merge Danger
Door: two-way
Flag-gated and frontend-only, apart from the shared helpers.
Blast Radius: small
With the flag off, the visible changes are none, but Publish & Share's finalize now goes through the extracted
useFinalizeAndInvite(same calls), and/:id/adminrenders the return page if Stripe's query params are present. Note for whoever turns the flag on: the backend builds the checkout return URL frommainUrl(ALLOWED_URLS, defaulthttps://bettervoting.com), so a local or staging setup without it set returns to production.🤖 Generated with Claude Code