Class: Payola::SubscriptionsController

Inherits:
ApplicationController show all
Includes:
AffiliateBehavior, AsyncBehavior, StatusBehavior
Defined in:
app/controllers/payola/subscriptions_controller.rb

Instance Method Summary collapse

Methods included from AsyncBehavior

#create_object, #object_status, #show_object

Methods included from StatusBehavior

#render_payola_status

Methods included from AffiliateBehavior

#find_affiliate

Instance Method Details

#change_planObject



28
29
30
31
32
33
# File 'app/controllers/payola/subscriptions_controller.rb', line 28

def change_plan
  @subscription = Subscription.find_by!(guid: params[:guid])
  Payola::ChangeSubscriptionPlan.call(@subscription, @plan, @quantity, @coupon, @trial_end)

  confirm_with_message(t('payola.subscriptions.plan_updated'))
end

#change_quantityObject



35
36
37
38
39
40
41
# File 'app/controllers/payola/subscriptions_controller.rb', line 35

def change_quantity
  find_quantity
  @subscription = Subscription.find_by!(guid: params[:guid])
  Payola::ChangeSubscriptionQuantity.call(@subscription, @quantity)

  confirm_with_message(t('payola.subscriptions.quantity_updated'))
end

#createObject



18
19
20
# File 'app/controllers/payola/subscriptions_controller.rb', line 18

def create
  create_object(Subscription, CreateSubscription, nil, :plan, @plan)
end

#destroyObject



22
23
24
25
26
# File 'app/controllers/payola/subscriptions_controller.rb', line 22

def destroy
  subscription = Subscription.find_by!(guid: params[:guid])
  Payola::CancelSubscription.call(subscription, at_period_end: to_boolean(params[:at_period_end]))
  redirect_to confirm_subscription_path(subscription)
end

#showObject



10
11
12
# File 'app/controllers/payola/subscriptions_controller.rb', line 10

def show
  show_object(Subscription)
end

#statusObject



14
15
16
# File 'app/controllers/payola/subscriptions_controller.rb', line 14

def status
  object_status(Subscription)
end

#update_cardObject



43
44
45
46
47
48
# File 'app/controllers/payola/subscriptions_controller.rb', line 43

def update_card
  @subscription = Subscription.find_by!(guid: params[:guid])
  Payola::UpdateCard.call(@subscription, params[:stripeToken])

  confirm_with_message(t('payola.subscriptions.card_updated'))
end