Skip to content

Subscription Plans: Use cases

Back to Subscription Plans.

A User can buy a plan on an Entity.

Your business logic can then enable or disable functionality for things concerning that Entity based on that features are unlocked by the bought and activated plan.

Examples:

  • Unlocking “premium” features for a website in KAB.page
    • A user buys the “premium” plan for a website.
    • The system enables the “premium” feature for that website.
    • The KAB.page business logic looks at the active features for that website, sees that the “premium” feature is active and enables / unlocks e.g. deployment, custom CSS and other things.
  • Unlocking “shop” features for a website in KAB.page
    • A user buys the “shop” plan for a website.
    • The system enables the “shop” features for that website.

A User can buy a plan for a Client (which is just the same as any entity).

Your business logic can then enable or disable functionality for things concerning all Entities from that client based on that features are unlocked by the bought and activated plan.

That could include all Users and Entities of that Client.

Remember, this has to be handled by custom business logic, the system itself only activates feature flags!

Examples:

  • Enabling client wide features
    • The user buys the plan to use feature X for his client
    • The system enables feature X for all Users and Entities of that Client.
      • e.g. allowing access to a new module / feature-set
  • SAAS style plans
    • A user buys a “business” plan for a Client.
    • The system enables the “business” features for that Client.
      • That allows X users to be created for that client
      • Enables X feature (e.g. DATEV export) for bills of that client
    • The system disables the “business” features for all Users and Entities of that Client when the plan expires.
      • All users except the main user that bought the plan (hopefully the boss) are disabled and cannot log in anymore.
      • Or just disable the creation of any new entities for that client.
  • Unlocking the ability to use KAB.instructions for a specific amount of usages
    • A user buys the “instructions_100” plan on the client
      • The plan is activated on the client, because the custom business logic is not exclusively happening on the “bought” entity, but multiple entities from that client are relevant to how the feature works.
    • The system enables the “instructions_100” feature for that client.
      • This allows the client handle up to 100 instruction uses per month.
    • Custom business logic would create and maintain a counter on the client object wich resets to 100 at the beginning of each month.
      • Every time an instruction is used, the counter is decremented.
      • If the counter reaches 0, custom business logic would not allow new instruction usages until the reset next month.

There are several workflow events that can be used to react to payment events.

Some are to be used for feature management and day-to-day operations. These all return the Entity in question and either the identifier of the plan or the list of NOW active_features.

  • event/subscriptionActivated: Fires when a plan was activated for an entity of the specified module.
  • event/subscriptionDeactivated: Fires when a plan was deactivated (e.g. when a subscription runs out) for an entity of the specified module.
  • event/subscriptionPaymentFailed: Fires when a payment for a plan failed for an entity of the specified module.
  • event/subscriptionFeaturesChanged: Fires when the active_features field on an entity of the specified module was updated.
    • This is useful to
      • react to a newly activated plan, e.g. when a user buys a plan for an entity.
      • react to a deactivated plan, e.g. when a user cancels a plan for an entity.
      • react to changes in the features of a plan, e.g. when a feature was added or removed from a plan via the config.
  • event/subscriptionInvoicePaid: Fires when a payment for a plan was successful. Includes the Entity and the relevant Plan / Price definitions

Remember: Stripe already sends out emails to the user! Only send additional emails if you want to notify the user about something that is not covered by the stripe emails.