View Source Plausible.Billing.Plans (Plausible v0.0.1)

Summary

Functions

Returns a list of plans available for the user to choose.

Returns the most appropriate plan for a user based on their usage during a given cycle.

List yearly plans product IDs.

Functions

Link to this function

find(product_id_or_subscription, scope \\ all())

View Source
@spec find(String.t() | Plausible.Billing.Subscription.t(), [
  Plausible.Billing.Plan.t()
]) ::
  Plausible.Billing.Plan.t() | nil
@spec find(nil, any()) :: nil

Finds a plan by product ID.

Returns nil when plan can't be found.

@spec for_user(Plausible.Auth.User.t()) :: [Plausible.Billing.Plan.t()]

Returns a list of plans available for the user to choose.

As new versions of plans are introduced, users who were on old plans can still choose from old plans.

Link to this function

subscription_interval(subscription)

View Source
Link to this function

suggest(user, usage_during_cycle)

View Source
@spec suggest(Plausible.Auth.User.t(), non_neg_integer()) ::
  Plausible.Billing.Plan.t()

Returns the most appropriate plan for a user based on their usage during a given cycle.

If the usage during the cycle exceeds the enterprise-level threshold, or if the user already belongs to an enterprise plan, it suggests the :enterprise plan.

Otherwise, it recommends the plan where the cycle usage falls just under the plan's limit from the available options for the user.

@spec yearly_product_ids() :: [String.t()]

List yearly plans product IDs.