feat: dynamic Stripe Checkout Sessions for tryout registration #112
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
ldraney/basketball-api#112
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
Feature
Lineage
plan-wkq→ Phase 4 (Dynamic Stripe Checkout Sessions)Repo
forgejo_admin/basketball-apiUser Story
As a parent paying for tryout registration online
I want my payment to be reliably linked to my registration
So that my account is auto-created and I get login credentials
Context
PR #111 introduced card payment save-before-redirect with email-based webhook matching. This is fragile — email matching can fail if the parent uses a different email at checkout. The jersey flow (
routes/jersey.py:147-166) already uses dynamicstripe.checkout.Session.create()with metadata for deterministic matching. This issue replaces the static Payment Link redirect with the same Checkout Session pattern, usingregistration_idin metadata.Jersey Checkout Session pattern to follow (jersey.py:147-166):
File Targets
Files to modify:
src/basketball_api/routes/register.py— Replacesettings.stripe_tryout_linkredirect withstripe.checkout.Session.create(). Add metadata:registration_id,player_id,player_name,type: "tryout_registration". Usesettings.frontend_urlfor success/cancel URLs.src/basketball_api/routes/webhooks.py— Replace email-based pending registration matching (lines ~198-237) with metadata-based matching: checkmetadata.type == "tryout_registration"and look up bymetadata.registration_id. After marking paid, trigger Keycloak auto-account creation.tests/test_promo_registration.py— Update card test to mockstripe.checkout.Session.create. Add webhook test with metadata-based matching.Files NOT to touch:
routes/jersey.py— reference only, don't modifyconfig.py—stripe_tryout_linksetting can stay (backward compat), just stop using itservices/registration.py— old Payment Link flow, not part of this changeAcceptance Criteria
stripe.checkout.Sessionwithregistration_idandtype: "tryout_registration"in metadata$30.00(3000 cents) as amount{frontend_url}/register?payment=success{frontend_url}/register?payment=cancelled{"redirect_url": session.url}to frontendmetadata.type == "tryout_registration"+metadata.registration_idpaidwith Stripe IDsTest Expectations
stripe.checkout.Session.create, asserts metadata and amounttype: tryout_registrationmetadata marks registration paidpytest tests/test_promo_registration.py -vConstraints
customer_emailparam on Session: use parent email (Stripe pre-fills checkout form)signup_method="stripe"andpayment_status="pending"flowChecklist
Related
westside-basketball— project