Skip to content

Subscription Plans: Basic concept

Back to Subscription Plans.

Some things in a brezel system can be bought / unlocked with a subscription based paywall.

For that, there is the concept of “plans” which can be bought/activated via a subscription. These define prices and most importantly, “Features” that can be used to enable or disable things in the system.

  • A User entity with the “Billable” Capability can buy a plan for an Entity.
  • The User will be registered as a customer in stripe (identified by their email) and charged for the selected plan by stripe.
  • Only entities from Modules that use the Buyable Capability can be bought. In the options of that capability, the subscription_plans, which contain feature flags and prices, are defined. During bakery apply, configured plans will be created in Stripe as Products with their respective prices.
  • Any Entity from a Buyable Module will have the fields active_plans and active_features set, which can be used by workflows, policies, recipes etc. to enable or disable features.
    • You should only use the active_features field to check for features, as they are unique and derived from the active_plans field.
      • Tip: You can use entity.hasActiveFeature(<feature_identifier>) in both API and SPA recipes to check if an entity has a specific feature active.

  • To react on payment events, there are several workflow events that can be used to hook into.
  • Ability to build an overview that see all active plans via routes / SPA Api helpers
    • /modules/<module_identifier>/resources/<entity_id>/subscriptions via Api.getSubscriptionsForEntity(entity: Entity)
    • /modules/<module_identifier>/subscriptions via Api.getSubscriptionsForModule(module: Module)
    • These endpoints return a structure like this:
      [
      {
      "id": 1, // Unique identifier for the subscription
      "user_id": 1, // The ID of the user that bought the plan
      "type": "ultra", // The identifier of the plan that was bought
      "stripe_id": "sub_1RiuvmBFAS1bkUxqN0ae5IzV", // The ID of the subscription in Stripe
      "stripe_status": "active", // The status of the subscription in Stripe
      "module_id": 2, // The ID of the module if the entity that the subscription is for
      "resource_id": 1, // The ID of the entity that the subscription is for
      "stripe_price": "price_1RiXrVBFAS1bkUxqrYZ4fnXt", // The ID of the price in Stripe that was bought
      "quantity": 1, // Always 1, as we only support single subscriptions for now
      "trial_ends_at": null, // The date when the trial ends. Always null since we don't support trials via stripe.
      "ends_at": null, // When the subscription ends. Set to the date when the subscription will be deactivated, once the subscription was canceled
      "next_billing_at": "2026-07-09 10:08:50", // The date when the next payment will be charged. This is the date when the subscription will be renewed.
      "created_at": "2025-07-09T10:08:56.000000Z", // The date when the subscription was created / first activated
      "updated_at": "2025-07-09T10:08:56.000000Z", // The date when the subscription was last updated
      "items": [{}] // An array of the `subscription_items` of that subscription. Should always just contain one item. You can get the stripe id (e.g. `prod_xxxxxxx`) of the Stripe product via `items[0].stripe_product`
      }
      ]
  • Ability to manually activate/remove plans to an entity
    • active_plans is just a textarea with mode = tags. You can add (or remove) another identifier freely, and upon saving, the system will update the active_features field accordingly.
    • You can also activate subscriptions via the Stripe dashboard if you indeed want them to be payed for.
      • Prerequisites:
        • Have customers created in Stripe
        • Have at least one working payment method for that customer
        • Have the plans and prices your Brezel expects created in Stripe via bakery apply
      • How do do it:
        1. Navigate to https://dashboard.stripe.com/test/customers/{customer_id}
        2. Click on “Add subscription”
        3. Choose the right plan and price as product
        4. The subscription will start immediately, but if you want to bill the user later (e.g. useful when migrating from the old Stripe integration) set the “Ab abrechnen” field accordingly.
        5. Set the correct metadata. For a minimum you need these fields:
          • module_identifier: The identifier of the module that the entity is from (e.g. buyable_thingy)
          • resource_id: The ID of the entity that the subscription is for (e.g. 1234)
          • plan_identifier: The identifier of the plan that was bought (e.g. pro_monthly)
        6. Choose the right payment method
        7. Add a meaningful name (which will be shown in the billing portal) as a description. E.g. "Pro Plan - Buyable Thingy 1234"
        8. Click on “Create subscription”
          • Now Stripe will send a webhook to your Brezel which will act like a normal Subscription activation.
          • Afterward you should have the plan with features active on the desired entity, and the user should be able to open the billing portal.
  • Ability to start a Stripe customer billing portal session for a user to manage their subscriptions
    • All subscription cancellations / adjustments are handled via the stripe customer portal. A link to which can be generated for the current user via the endpoint /subscription-portal