lib/tasks/billing_plans.rake
# Set up all the available billing plans. Requires a server restart to take effect.
# BillingPlan Fields:
# - name: The name we show to users when viewing their current plan or choosing a new one
# - stripe_plan_id: Must match the corresponding Subscription plan on Stripe
# - monthly_cents: The price of the plan, charged monthly (e.g. $9/month is 900 cents)
# - available: Whether or not this plan is available for users to choose on their own (from the subscription UI)
# Limitations:
# - universe_limit: Number of universes that can be created while on this plan. Existing ones can always be edited.
# - allows_core_content: Whether or not to allow creating new core content. Existing ones can always be edited.
# - allows_extended_content: Whether or not to allow creating new extended content. Existing ones can always be edited.
# - allows_collective_content: Whether or not to allow creating new collective content. Existing ones can always be edited.
# - allows_collaboration: Whether or not this user can invite other users to contribute to their universe (TBD)
namespace :billing_plans do
desc "Initialize all default billing plans"
task initialize_defaults: :environment do
puts "Initializing all default billing plans. Starting with #{BillingPlan.count} plans."
# Free tier
BillingPlan.find_or_create_by(
name: 'Starter',
stripe_plan_id: 'starter',
monthly_cents: 0, # $0.00/mo
available: true,
# Content creation and other permissions:
universe_limit: 5,
allows_core_content: true,
allows_extended_content: false,
allows_collective_content: false,
allows_collaboration: false
)
# Free-for-life plan for beta testers
BillingPlan.find_or_create_by(
name: 'Beta Testers - Free For Life (thank you!)',
stripe_plan_id: 'free-for-life',
monthly_cents: 0, # $0.00/mo
available: false,
# Content creation and other permissions:
universe_limit: 1000,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: true
)
# Temporary $6/month paid tier for users that sign up before February 14
BillingPlan.find_or_create_by(
name: 'Early Adopters (thank you!)',
stripe_plan_id: 'early-adopters',
monthly_cents: 600, # $6.00/mo
available: false,
# Content creation and other permissions:
universe_limit: 1000,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: false
)
# Standard $9/month paid tier (to be available after signup promo)
BillingPlan.find_or_create_by(
name: 'Premium',
stripe_plan_id: 'premium',
monthly_cents: 900, # $9.00/mo
available: true,
# Content creation and other permissions:
universe_limit: 1000,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: false
)
# Premium paid three months at a time
BillingPlan.find_or_create_by(
name: 'Premium (3-month bundle)',
stripe_plan_id: 'premium-trio',
monthly_cents: 800, # $8.00/mo -- $24/3mo
available: true,
# Content creation and other permissions:
universe_limit: 1000,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: false
)
# Premium paid annually
BillingPlan.find_or_create_by(
name: 'Premium (annual)',
stripe_plan_id: 'premium-annual',
monthly_cents: 700, # $7.00/mo -- $84/year
available: true,
# Content creation and other permissions:
universe_limit: 1000,
allows_core_content: true,
allows_extended_content: true,
allows_collective_content: true,
allows_collaboration: false
)
puts "Done. There are #{BillingPlan.count} billing plans now."
end
end