refactor: Clean up subscription admin override and Stripe integration (#205) #218
Reference in New Issue
Block a user
Delete Branch "issue-205-clean-subscription-admin-override"
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?
Summary
Refactors the subscription system to cleanly separate admin-managed tier overrides from Stripe-managed billing.
stripe_customer_idNULLABLE (replacesadmin_override_*sentinel values with NULL)resolveStripeCustomerId()withensureStripeCustomer()(includes orphaned customer cleanup)syncTierToUserProfile()blocking (prevents tier drift in all code paths)getInvoices()null checkChanges
Migration
002_nullable_stripe_customer_id.sql- DROP NOT NULL, cleanup sentinel valuesBackend Types
Subscription.stripeCustomerId: string | nullSubscriptionResponse.stripeCustomerId: string | nullUpdateSubscriptionData.stripeCustomerId?: string | nullRepository
createForAdminOverride()inserts NULL instead ofadmin_override_*placeholdermapSubscriptionRow()uses?? null(nullish coalescing)create()accepts optionalstripeCustomerIdService
resolveStripeCustomerId()(30 lines removed)ensureStripeCustomer()with orphaned Stripe customer cleanup on DB failuresyncTierToUserProfile()made blocking (error swallowing removed)cancelSubscription()/reactivateSubscription()- null guard for stripeCustomerIdgetInvoices()simplified from prefix check to null checkStripe Client
deleteCustomer()for cleanup logicController
admin_override_Frontend Types
Subscription.stripeCustomerId: string | nullTest Plan
Fixes #205
Fixes #207
Fixes #208
Fixes #209
Fixes #210