Class: PaidUp::SubscriptionsController

Inherits:
PaidUpController show all
Defined in:
app/controllers/paid_up/subscriptions_controller.rb

Overview

Subscriptions Controller

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/paid_up/subscriptions_controller.rb', line 25

def create
  # @plan load by #load_plan
  result = current_user.subscribe_to_plan(
    @plan,
    params[:stripeToken],
    params[:coupon_code]
  )
  if result
    create_success
  else
    create_error
  end
end

#indexObject



16
17
18
# File 'app/controllers/paid_up/subscriptions_controller.rb', line 16

def index
  # nothing to do, everything we need is in current_user
end

#newObject



20
21
22
23
# File 'app/controllers/paid_up/subscriptions_controller.rb', line 20

def new
  # nothing to do, @plan load by #load_plan
  (current_user.can_downgrade_to?(@plan) || @plan.amount.zero?) && create
end