Subscriptions in Jumpstart Pro are billed against a Account, not a User. This allows you to handle various different billing situations.
Account billing allows you to share resources and billing functionality with the entire account and allows any member to manage the subscription. It's much easier to start with account billing support than adding it later, so we've got you covered even if you don't need it right away.
For more information on how accounts work in Jumpstart Pro, check out the Accounts documentation.
Plans can be defined in the Admin. Each plan should be defined with the price amount in cents.
You can provide free subscriptions to friends and beta testers by using the Pay gem's fake payment processor.
# Ensure Jumpstart Pro free plan exists for admin users
Plan.where(name: "Free").first_or_create(hidden: true, amount: 0, currency: :usd, interval: :month, trial_period_days: 0, fake_processor_id: :free)
# Create a fake subscription for the admin user so they have access to everything by default
account = user.accounts.first
account.set_payment_processor :fake_processor, allow_fake: true
Plans have a
trial_period_days:integer attribute to define a trial period. This may also be required on the Price in your payment processor.
Depending on the payment processor, trials may require a payment method or can be configured to capture a payment method later.
It's common practice to require subscriptions to access certain parts of your application. You can use
before_action :require_subscription! in your Rails controllers to ensure that only subscribed users can access certain actions.
For example, the
premium_features action can only be accessed by users who are subscribed. If a user who is not subscribed tries to access this action, they will be redirected to the pricing page.
class ProductsController < ApplicationController
before_action :require_subscription!, only: [:premium_features]
# Only accessible by subscribed users