feat: Stripe card payment saves registration before redirect + webhook matching #110

Closed
opened 2026-03-19 01:22:31 +00:00 by forgejo_admin · 0 comments
Contributor

Type

Feature

Lineage

plan-wkq → Phase 1 (Commit Uncommitted Work)

Repo

forgejo_admin/basketball-api

User Story

As a parent registering for tryouts
I want my card payment to be linked to my registration
So that the system knows who paid and can auto-create my account

Context

Card payment flow previously redirected to a static Stripe Payment Link with no database connection. Stripe didn't know which player paid. This commit captures work done during the registration session: card payments now save the registration as pending/stripe before redirecting, and the webhook handler matches completed payments to pending registrations by parent email.

File Targets

Files modified:

  • src/basketball_api/routes/register.py — card payment saves registration before redirect
  • src/basketball_api/routes/webhooks.py — checkout.session.completed webhook matches by parent email
  • tests/test_promo_registration.py — updated test for new card payment behavior

Acceptance Criteria

  • Card registration creates DB record with status pending and signup_method stripe before Stripe redirect
  • Webhook updates registration status to paid on checkout.session.completed
  • Stripe session ID and payment intent stored on registration
  • Tests pass

Test Expectations

  • Unit test: card registration creates pending record and returns redirect URL
  • Unit test: webhook matches pending registration by email and updates to paid
  • Run command: pytest tests/test_promo_registration.py -v

Constraints

  • Follow existing route patterns in routes/register.py
  • Webhook handler must be idempotent (re-processing same event = no error)

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • westside-basketball — project
  • plan-wkq Phase 4 will replace email-matching with metadata-based matching
### Type Feature ### Lineage `plan-wkq` → Phase 1 (Commit Uncommitted Work) ### Repo `forgejo_admin/basketball-api` ### User Story As a parent registering for tryouts I want my card payment to be linked to my registration So that the system knows who paid and can auto-create my account ### Context Card payment flow previously redirected to a static Stripe Payment Link with no database connection. Stripe didn't know which player paid. This commit captures work done during the registration session: card payments now save the registration as `pending/stripe` before redirecting, and the webhook handler matches completed payments to pending registrations by parent email. ### File Targets Files modified: - `src/basketball_api/routes/register.py` — card payment saves registration before redirect - `src/basketball_api/routes/webhooks.py` — checkout.session.completed webhook matches by parent email - `tests/test_promo_registration.py` — updated test for new card payment behavior ### Acceptance Criteria - [ ] Card registration creates DB record with status `pending` and signup_method `stripe` before Stripe redirect - [ ] Webhook updates registration status to `paid` on checkout.session.completed - [ ] Stripe session ID and payment intent stored on registration - [ ] Tests pass ### Test Expectations - [ ] Unit test: card registration creates pending record and returns redirect URL - [ ] Unit test: webhook matches pending registration by email and updates to paid - Run command: `pytest tests/test_promo_registration.py -v` ### Constraints - Follow existing route patterns in `routes/register.py` - Webhook handler must be idempotent (re-processing same event = no error) ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `westside-basketball` — project - plan-wkq Phase 4 will replace email-matching with metadata-based matching
forgejo_admin 2026-03-19 01:37:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/basketball-api#110
No description provided.