Auto registration email with token link after Stripe payment #35

Closed
opened 2026-03-10 04:40:54 +00:00 by forgejo_admin · 0 comments

Lineage

plan-2026-03-08-tryout-prep → Phase 3b → auto-email on payment

Repo

forgejo_admin/basketball-api

User Story

As a parent who just paid via Stripe
I want to receive an email with a link to complete my child's registration profile
So that I can fill out player info and sign the waiver before tryout day

Context

The Stripe webhook (process_checkout_completed) already creates parent/player/registration records and calls send_confirmation_email(). But the current email is a generic "payment received" confirmation with old blue/gold branding. It does NOT include a registration token link.

Need to:

  1. Generate a registration_token for the parent after Stripe payment (in process_checkout_completed)
  2. Update the email template to include a personalized registration link ({base_url}/register?token={token})
  3. Update email branding to Westside red/black (#d42026, #0a0a0a) — import from brand.py
  4. Email sends from draneylucas@gmail.com (tenant gmail_account already set to draneylucas)

The email subject should be something like: "Complete [Player Name]'s Tryout Registration — Westside Kings & Queens"

File Targets

Files to modify:

  • src/basketball_api/services/registration.py — after creating parent record, generate registration_token (use secrets.token_urlsafe(32)) and save to parent
  • src/basketball_api/services/email.py — update send_confirmation_email() to include registration token link + Westside red/black branding. Use config.base_url for the link. Import brand colors from brand.py.

Files NOT to touch:

  • src/basketball_api/routes/webhooks.py — webhook handler is fine
  • src/basketball_api/routes/register.py — registration form already handles ?token=xxx
  • src/basketball_api/brand.py — use existing colors, don't modify

Acceptance Criteria

  • process_checkout_completed() generates a registration_token for the parent if they don't have one
  • send_confirmation_email() includes a clickable link: {base_url}/register?token={token}
  • Email uses Westside red/black branding (#d42026 red, #0a0a0a black, #f0f0f0 text)
  • Email subject: "Complete [Player Name]'s Tryout Registration — Westside Kings & Queens"
  • All existing tests pass

Test Expectations

  • Unit test: process_checkout_completed generates registration_token for parent
  • Unit test: send_confirmation_email includes token link in email body
  • Run command: pytest tests/ -v

Constraints

  • Use from basketball_api.config import settings for settings.base_url
  • Use secrets.token_urlsafe(32) for token generation (same as existing pattern)
  • Keep email template mobile-friendly (inline styles, max-width 600px)
  • The confirmation email function signature can change if needed — add base_url param or pull from settings

Checklist

  • PR opened
  • Tests pass
  • No unrelated changes
  • project-westside-basketball
  • Phase 3b (email blast, Issue #20)
  • send_confirmation_email() in services/email.py
### Lineage `plan-2026-03-08-tryout-prep` → Phase 3b → auto-email on payment ### Repo `forgejo_admin/basketball-api` ### User Story As a parent who just paid via Stripe I want to receive an email with a link to complete my child's registration profile So that I can fill out player info and sign the waiver before tryout day ### Context The Stripe webhook (`process_checkout_completed`) already creates parent/player/registration records and calls `send_confirmation_email()`. But the current email is a generic "payment received" confirmation with old blue/gold branding. It does NOT include a registration token link. Need to: 1. Generate a `registration_token` for the parent after Stripe payment (in `process_checkout_completed`) 2. Update the email template to include a personalized registration link (`{base_url}/register?token={token}`) 3. Update email branding to Westside red/black (`#d42026`, `#0a0a0a`) — import from `brand.py` 4. Email sends from `draneylucas@gmail.com` (tenant `gmail_account` already set to `draneylucas`) The email subject should be something like: "Complete [Player Name]'s Tryout Registration — Westside Kings & Queens" ### File Targets Files to modify: - `src/basketball_api/services/registration.py` — after creating parent record, generate `registration_token` (use `secrets.token_urlsafe(32)`) and save to parent - `src/basketball_api/services/email.py` — update `send_confirmation_email()` to include registration token link + Westside red/black branding. Use `config.base_url` for the link. Import brand colors from `brand.py`. Files NOT to touch: - `src/basketball_api/routes/webhooks.py` — webhook handler is fine - `src/basketball_api/routes/register.py` — registration form already handles `?token=xxx` - `src/basketball_api/brand.py` — use existing colors, don't modify ### Acceptance Criteria - [ ] `process_checkout_completed()` generates a `registration_token` for the parent if they don't have one - [ ] `send_confirmation_email()` includes a clickable link: `{base_url}/register?token={token}` - [ ] Email uses Westside red/black branding (`#d42026` red, `#0a0a0a` black, `#f0f0f0` text) - [ ] Email subject: "Complete [Player Name]'s Tryout Registration — Westside Kings & Queens" - [ ] All existing tests pass ### Test Expectations - [ ] Unit test: `process_checkout_completed` generates registration_token for parent - [ ] Unit test: `send_confirmation_email` includes token link in email body - Run command: `pytest tests/ -v` ### Constraints - Use `from basketball_api.config import settings` for `settings.base_url` - Use `secrets.token_urlsafe(32)` for token generation (same as existing pattern) - Keep email template mobile-friendly (inline styles, max-width 600px) - The confirmation email function signature can change if needed — add `base_url` param or pull from settings ### Checklist - [ ] PR opened - [ ] Tests pass - [ ] No unrelated changes ### Related - `project-westside-basketball` - Phase 3b (email blast, Issue #20) - `send_confirmation_email()` in `services/email.py`
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
forgejo_admin/basketball-api#35
No description provided.