Sha256: a14843e3f64599e30cd4d8c56fcf2c43238a2eb2a13172fad8e19778f488369b

Contents?: true

Size: 974 Bytes

Versions: 47

Compression:

Stored size: 974 Bytes

Contents

class DiscoApp::SubscriptionsController < ApplicationController
  include DiscoApp::Concerns::AuthenticatedController

  skip_before_action :check_current_subscription

  def new
    @subscription = DiscoApp::Subscription.new
  end

  def create
    # Get the selected plan. If it's not available or couldn't be found,
    # redirect back to the plan selection page.
    if(plan = DiscoApp::Plan.available.find_by_id(subscription_params[:plan])).nil?
      redirect_to action: :new and return
    end

    # Subscribe the current shop to the selected plan. Pass along any cookied
    # plan code and source code.
    if(subscription = DiscoApp::SubscriptionService.subscribe(@shop, plan, cookies[DiscoApp::CODE_COOKIE_KEY], cookies[DiscoApp::SOURCE_COOKIE_KEY])).nil?
      redirect_to action: :new
    else
      redirect_to main_app.root_path
    end
  end

  private

    def subscription_params
      params.require(:subscription).permit(:plan, :plan_code)
    end

end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
disco_app-0.11.0 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.11.1 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.12.0 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.12.1 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.12.5 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.12.6 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.12.7 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.0 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.1 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.2 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.3 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.4 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.5 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.6 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.7 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.13.8 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.14.1 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.14.2 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.15.0 app/controllers/disco_app/subscriptions_controller.rb
disco_app-0.16.0 app/controllers/disco_app/subscriptions_controller.rb