refactor: Remove resolveStripeCustomerId and harden tier sync (#205) #209

Closed
opened 2026-02-16 14:53:09 +00:00 by egullickson · 0 comments
Owner

Relates to #205

Milestone 3: Service - admin override + sync hardening

Files

  • backend/src/features/subscriptions/domain/subscriptions.service.ts

Changes

  1. Delete resolveStripeCustomerId() (lines 173-198):

    • Remove the entire method
    • Lazy resolution replaced by direct creation in Milestone 4
  2. Update adminOverrideTier() (lines 899-960):

    • No logic changes needed - it delegates to createForAdminOverride() which now creates with NULL (Milestone 2)
  3. Make syncTierToUserProfile() blocking (lines 804-816):

    • Remove try-catch that swallows errors (line 814)
    • Let errors propagate to caller
    • Safe: single-row UPDATE on indexed column (<1ms)
    • All 4 callers now fail atomically if sync fails:
      • upgradeSubscription (line 253)
      • downgradeSubscription (line 453)
      • handleSubscriptionUpdated (line 607)
      • handleSubscriptionDeleted (line 642)

Acceptance Criteria

  • resolveStripeCustomerId() deleted
  • syncTierToUserProfile() throws on failure (no error swallowing)
  • Admin override flow works with NULL stripe_customer_id
  • Webhook handlers propagate sync failures
Relates to #205 ## Milestone 3: Service - admin override + sync hardening ### Files - `backend/src/features/subscriptions/domain/subscriptions.service.ts` ### Changes 1. **Delete `resolveStripeCustomerId()`** (lines 173-198): - Remove the entire method - Lazy resolution replaced by direct creation in Milestone 4 2. **Update `adminOverrideTier()`** (lines 899-960): - No logic changes needed - it delegates to createForAdminOverride() which now creates with NULL (Milestone 2) 3. **Make `syncTierToUserProfile()` blocking** (lines 804-816): - Remove try-catch that swallows errors (line 814) - Let errors propagate to caller - Safe: single-row UPDATE on indexed column (<1ms) - All 4 callers now fail atomically if sync fails: - upgradeSubscription (line 253) - downgradeSubscription (line 453) - handleSubscriptionUpdated (line 607) - handleSubscriptionDeleted (line 642) ### Acceptance Criteria - [ ] `resolveStripeCustomerId()` deleted - [ ] `syncTierToUserProfile()` throws on failure (no error swallowing) - [ ] Admin override flow works with NULL stripe_customer_id - [ ] Webhook handlers propagate sync failures
egullickson added the
status
backlog
type
feature
labels 2026-02-16 14:53:33 +00:00
egullickson added this to the Sprint 2026-02-02 milestone 2026-02-16 14:53:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: egullickson/motovaultpro#209