Class: AccountSubscriptionsController

Inherits:
ApplicationController show all
Includes:
Payola::StatusBehavior
Defined in:
app/controllers/account_subscriptions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/account_subscriptions_controller.rb', line 16

def create
  # do any required setup here, including finding or creating the owner object
  owner = current_user # this is just an example for Devise

  # set your plan in the params hash
  params[:plan] = SubscriptionPlan.find_by(id: params[:plan_id])

  # call Payola::CreateSubscription
  subscription = Payola::CreateSubscription.call(params, owner)

  # Render the status json that Payola's javascript expects
  render_payola_status(subscription)
end

#newObject



12
13
14
# File 'app/controllers/account_subscriptions_controller.rb', line 12

def new
  @plan = SubscriptionPlan.first
end

#plansObject



6
7
8
9
10
# File 'app/controllers/account_subscriptions_controller.rb', line 6

def plans
  default_interval = current_user.try(:current_plan).try(:interval) || 'month'
  @interval = params[:interval] == 'year' ? 'year' : default_interval
  @plans = SubscriptionPlan.visible.interval(@interval)
end