Skip to content

Subscription implementation history 2

This is the historical implementation checklist, not a statement of current feature availability. For registered events and capabilities use the generated reference.

  • Handle feature flags / subscription events
    • Every time a subscription is activated/deactivated
      • set active_features on the right entity (based on the metadata of the subscription)
      • set active_plans on the right entity (based on the metadata of the subscription)
    • When the features of a plan changed, update active_features for all entities that have that plan active
      • We sync! I.e. if a feature was added, give it to everyone that has that plan, if a feature was removed, remove it from everyone that has that plan.
    • Handle removing plans form the config
      • Keep the plan identifier in active_plans, but remove the features since we don’t know them anymore.
      • We do not delete plan (products) or prices in stripe
    • Handle manually activated plans
      • If a defined plan has no prices, don’t return it when fetching available plans
      • update active_features when manually changing active_plans
      • Make sure that when rebuilding the active_plans field on a subscription change, only add / remove the plan that this subscription was for. Leave the others untouched.
        • I.e. when I have plan_a, plan_b and I buy plan_c, the new value of active_plans should be plan_a, plan_b, plan_c
        • Now I manually add plan_d to the active_plans field, the new value should be plan_a, plan_b, plan_c, plan_d
        • When plan_a is deactivated, the new value should be plan_b, plan_c, plan_d, even though plan_d was not bought via a subscription.
  • Build migration
    • Maybe migrate over old data from entity_subscription table to the new way of storing / registering subscriptions
    • Remove old tables and columns
      • license stuff
        • license_plan_module table
        • license_plans table
        • licenses table
        • All fields, need to find them
      • old subscription stuff
        • module_subscription table
        • module_subscription_prices table
        • entity_subscription table
        • All fields, need to find them
    • Dump old tables and data
  • Build some default SPA handling for all of this
    • Widget / Modal for each entity from a Buyable module that
      • Shows the active plans and features
      • Allows to buy a plan
      • Allows to manage the subscription (redirect to stripe customer portal)
    • Api class helper functions to
      • Get all buyable plans for a module
      • initiate a subscription for a plan on an entity with a specified price
      • get all plans, not just the ones with prices
    • Rebuild how translations are handled for the plans.
      • Remove the name or description fields of plans, features and prices. They should be translated via their identifier.
        • Translation paths are
          • modules.<module_identifier>.subscription_plans.<plan_identifier>.title,
          • modules.<module_identifier>.subscription_plans.<plan_identifier>.description
          • modules.<module_identifier>.subscription_plans.features.<feature_identifier>
          • modules.<module_identifier>.subscription_plans.prices.<price_identifier>
  • entity.hasActiveFeature(<slug>)
    • Api recipes
    • SPA recipes

Subscription plans.