Schema for subscription types (pricing tiers).
Subscription types define the pricing, billing interval, and features available at each tier. Types are managed internally and used to create subscriptions.
Fields
name- Display name (e.g., "Basic", "Pro", "Enterprise")slug- Unique identifier (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 typeactive- Whether this type is available for new subscriptionssort_order- Display order in type listings
Examples
%SubscriptionType{
name: "Professional",
slug: "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 subscription type.
Creates a changeset for a subscription type.
Returns the formatted price string with currency.
Gets a subscription type by its slug.
Returns the billing interval description (e.g., "monthly", "every 3 months").
Lists all active subscription types ordered by sort_order.
Calculates the next billing date from a given start date.
Functions
Returns the billing period in days for this subscription type.
Creates a changeset for a subscription type.
Required fields
name- Display nameslug- Unique 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 subscription type by its slug.
Returns the billing interval description (e.g., "monthly", "every 3 months").
Lists all active subscription types ordered by sort_order.
Calculates the next billing date from a given start date.