Class: PaidUp::SubscriptionsController
- Inherits:
-
PaidUpController
- Object
- ApplicationController
- PaidUpController
- PaidUp::SubscriptionsController
- Defined in:
- app/controllers/paid_up/subscriptions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/paid_up/subscriptions_controller.rb', line 17 def create # @plan set by #set_plan if current_user.subscribe_to_plan(@plan, params[:stripeToken]) redirect_to subscriptions_path, flash: { notice: :you_are_now_subscribed_to_the_plan.l(plan_name: current_user.plan.title) } else redirect_to new_plan_subscription_path @plan, flash: { error: current_user.errors. || :could_not_subscribe_to_plan.l(plan: @plan.title) } end rescue Stripe::InvalidRequestError => e flash[:error] = e. redirect_to plans_path rescue Stripe::CardError => e flash[:error] = e. redirect_to new_plan_subscription_path end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/paid_up/subscriptions_controller.rb', line 6 def index # nothing to do, everything we need is in current_user end |
#new ⇒ Object
10 11 12 13 14 15 |
# File 'app/controllers/paid_up/subscriptions_controller.rb', line 10 def new # nothing to do, @plan set by #set_plan if current_user.can_downgrade_to? @plan || @plan.amount == 0 create end end |