Fix: fresh-pending reuse shows stale Stripe amount when fee changed #479
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api#479
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Bug
Lineage
Regression from
forgejo_admin/basketball-api#473(first-payment 409 fix). The "reuse existing Stripe session for fresh pending orders" branch blindly reuses the old session amount, causing a bait-and-switch when the admin adjusts a player'smonthly_feebetween clicks.Repo
forgejo_admin/basketball-apiWhat Broke
Email shows one amount; Stripe checkout shows a different amount.
Reproduced end-to-end Apr 13:
monthly_fee=$200→ email sent showing "Pay $165 Now"Repro Steps
Player.monthly_fee = 200for any signed playerGET /checkout/first-payment?token={player.contract_token}→ creates pending order at $165UPDATE players SET monthly_fee = 4 WHERE id = ...via DB (simulates admin fee change)Expected Behavior
When the parent clicks and a fresh pending order exists but its amount no longer matches the currently-computed prorated amount, the old order/session is canceled and a new one is created at the correct amount. Email amount must always equal Stripe checkout amount.
Environment
basketball-api44aef6d(main)File Targets
Files to modify:
src/basketball_api/routes/checkout.py— lines 360-380 (first_payment_checkout). In the fresh-pending branch, add an amount comparison: ifexisting_order.amount_cents != amount_cents, cancel and fall through to create new.tests/test_first_payment.py— add a test asserting the fee-change-mid-flight case produces a new order at the new amount.Files to NOT touch:
src/basketball_api/services/email.py— email rendering is correct, uses fresh feeAcceptance Criteria
Test Expectations
test_first_payment_fresh_pending_amount_changed— pending at $165, fee drops to $4, new click creates new order at $5 and redirects to the new Stripe session (not the old $165 one)test_first_payment_fresh_pending_returns_redirectstill passes (same amount = reuse)test_first_payment_stale_pending_replacedstill passestest_first_payment_paid_still_blockedstill passespytest tests/test_first_payment.py -vRelated
westside-basketball— project this affectsforgejo_admin/basketball-api#473— the fix that introduced this regressionScope Review: READY
Review note:
review-1006-2026-04-13Scope is tight and verified against
origin/main. File targets exist, line references are close (actual fresh-pending branch is 358-374 vs ticket's 360-380 — same region). Existing tests referenced in AC all present. Pattern is isolated tofirst_payment_checkoutonly — no blast radius to jersey/tournament flows. Traceability: story:WS-S11 verified, arch:basketball-api labeled (arch note itself is missing as a pre-existing gap — tracked separately, does not block this fix). No decomposition needed (2 files, 1 repo, 5 AC, ~5 LOC + 1 test).Ready to move backlog → todo.