Subscription Platform Architecture
The components that most subscription builds get wrong are mid-cycle change proration, dunning sequence calibration, and entitlement consistency across billing and product layers.
Subscription Lifecycle State Machine
Subscriptions are modelled as a state machine with defined valid transitions: Trial, Active, Past Due, Paused, Cancelled, Reactivated. Invalid transitions (e.g. reactivating a subscription that requires payment method re-entry without triggering SCA) are rejected at the API layer. Every state change is recorded with timestamp, actor, trigger event, and previous state, creating an immutable audit trail that supports revenue recognition calculations and customer support review.
Pricing Model Engine
Pricing models are stored as configuration data, not code: flat monthly/annual, per-seat (licensed user count), tiered (first N units at rate A, next M units at rate B), volume (all units priced at the tier rate for the total quantity), metered (rate applied to usage aggregated from the metering layer), and hybrid combinations. Plan changes are evaluated against the pricing engine at the time of the change, not at renewal, so proration calculations are deterministic and auditable. The engine supports promotional pricing, coupons (percentage, fixed, duration-limited), and free trial periods with configurable trial-to-paid conversion logic.
Dunning and Payment Recovery
Dunning sequences are calibrated by payment method type (card vs direct debit have different retry windows), failure code (hard decline vs insufficient funds vs expired card require different responses), and customer segment (enterprise customers on manual outreach paths, SME/consumer on automated sequences). Card expiry is handled proactively via Account Updater (Visa, Mastercard) and Stripe Card Updates before the renewal date, not reactively after a failed charge. Permanent failure codes trigger immediate cancellation; soft failures trigger the retry sequence with adjustable cadence.
Entitlement Management
Entitlements define what features and usage limits apply to a subscription at a given point in time. The entitlement service evaluates the current subscription state, plan configuration, and any active add-ons to produce a feature access decision. Plan changes take effect immediately or at next renewal period depending on the change type (upgrades are typically immediate, downgrades at period end), and the entitlement service reflects this without a polling delay. Entitlement decisions are cached per session with a short TTL and invalidated on subscription state change events published to Kafka.