Schema for subscription plans (pricing tiers).
Subscription plans define the pricing, billing interval, and features available at each tier. Plans are managed internally and used to create subscriptions.
Fields
name- Display name (e.g., "Basic", "Pro", "Enterprise")code- Unique identifier code (e.g., "basic", "pro")description- Marketing descriptionprice- Price per billing period (Decimal)currency- Three-letter currency code (default: "EUR")interval- Billing interval: "day", "week", "month", "year"interval_count- Number of intervals (e.g., 3 months)trial_days- Free trial period in days (default: 0)features- JSON map of features included in this planactive- Whether this plan is available for new subscriptionssort_order- Display order in plan listings
Examples
%SubscriptionPlan{
name: "Professional",
code: "pro",
price: Decimal.new("29.99"),
currency: "EUR",
interval: "month",
interval_count: 1,
trial_days: 14,
features: %{"api_calls" => 10000, "storage_gb" => 50},
active: true
}
Summary
Functions
Returns the billing period in days for this plan.
Creates a changeset for a subscription plan.
Returns the formatted price string with currency.
Gets a plan by its code.
Returns the billing interval description (e.g., "monthly", "every 3 months").
Lists all active subscription plans ordered by sort_order.
Calculates the next billing date from a given start date.
Functions
Returns the billing period in days for this plan.
Creates a changeset for a subscription plan.
Required fields
name- Plan display nameslug- Unique plan identifier (URL-friendly)price- Price per period
Optional fields
description,currency,interval,interval_counttrial_days,features,active,sort_order,metadata
Returns the formatted price string with currency.
Gets a plan by its code.
Returns the billing interval description (e.g., "monthly", "every 3 months").
Lists all active subscription plans ordered by sort_order.
Calculates the next billing date from a given start date.