feat: payment_links table + outstanding balance emails + monthly billing cleanup #523

Closed
opened 2026-05-18 12:32:33 +00:00 by ldraney · 0 comments
Owner

Type

Feature

Lineage

  • Project: project-westside-basketball
  • Phase: Billing Tiers & Contracts (Phase 14)

Repo

ldraney/basketball-api

User Story

As an admin, I want to send outstanding balance emails to parents with unpaid payment links so they can pay individual items directly.

Context

This work was deployed to prod via hotfix on 2026-05-18 to recover from a 37-day outage. Migration 048 was applied to the DB on ~May 7 but never committed. This issue tracks bringing main up to date with what's running.

File Targets

  • alembic/versions/048_add_payment_links_table.py — new migration
  • src/basketball_api/models.py — PaymentLink model + PaymentLinkStatus enum
  • src/basketball_api/routes/admin.py — outstanding balance endpoint + subscription filter
  • src/basketball_api/routes/checkout.py — remove proration
  • src/basketball_api/services/email.py — outstanding balance email + cleanup first-payment copy
  • src/basketball_api/services/email_queries.py — outstanding_balances query
  • scripts/backfill_payment_links.py — backfill script

Test Expectations

  • Migration 048 applies cleanly
  • Outstanding balance endpoint sends grouped emails per parent
  • Monthly checkout charges flat monthly_fee (no proration)

Acceptance Criteria

  • payment_links table exists with correct schema (migration 048)
  • PaymentLink model matches migration
  • POST /email/outstanding-balance endpoint works
  • outstanding_balances query registered in blast system
  • Monthly checkout charges flat fee (no proration)
  • Backfill script included

Constraints

  • Migration 048 already applied to prod DB (98 rows in payment_links)
  • Cannot downgrade without data loss

Checklist

  • Migration written and applied
  • Model matches migration schema
  • Admin endpoint functional
  • Backfill script run in prod
  • Deployed via hotfix image
  • project-westside-basketball — parent project
### Type Feature ### Lineage - Project: `project-westside-basketball` - Phase: Billing Tiers & Contracts (Phase 14) ### Repo `ldraney/basketball-api` ### User Story As an admin, I want to send outstanding balance emails to parents with unpaid payment links so they can pay individual items directly. ### Context This work was deployed to prod via hotfix on 2026-05-18 to recover from a 37-day outage. Migration 048 was applied to the DB on ~May 7 but never committed. This issue tracks bringing main up to date with what's running. ### File Targets - `alembic/versions/048_add_payment_links_table.py` — new migration - `src/basketball_api/models.py` — PaymentLink model + PaymentLinkStatus enum - `src/basketball_api/routes/admin.py` — outstanding balance endpoint + subscription filter - `src/basketball_api/routes/checkout.py` — remove proration - `src/basketball_api/services/email.py` — outstanding balance email + cleanup first-payment copy - `src/basketball_api/services/email_queries.py` — outstanding_balances query - `scripts/backfill_payment_links.py` — backfill script ### Test Expectations - Migration 048 applies cleanly - Outstanding balance endpoint sends grouped emails per parent - Monthly checkout charges flat monthly_fee (no proration) ### Acceptance Criteria - [x] `payment_links` table exists with correct schema (migration 048) - [x] `PaymentLink` model matches migration - [x] `POST /email/outstanding-balance` endpoint works - [x] `outstanding_balances` query registered in blast system - [x] Monthly checkout charges flat fee (no proration) - [x] Backfill script included ### Constraints - Migration 048 already applied to prod DB (98 rows in payment_links) - Cannot downgrade without data loss ### Checklist - [x] Migration written and applied - [x] Model matches migration schema - [x] Admin endpoint functional - [x] Backfill script run in prod - [x] Deployed via hotfix image ### Related - `project-westside-basketball` — parent project
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#523
No description provided.