Sha256: 443da737979921a671df5d8ebbcd21c8b5702f0d1cf18042f65b96e7d7a4ca95

Contents?: true

Size: 1.09 KB

Versions: 32

Compression:

Stored size: 1.09 KB

Contents

module DiscoApp
  class ChargesController < ApplicationController
    include DiscoApp::AuthenticatedController

    skip_before_action :verify_status, only: [:create, :activate]

    # Display a "pre-charge" page, giving the opportunity to explain why a charge needs to be made.
    def new
    end

    # Create a new charge for the currently logged in shop, then redirect to the charge's confirmation URL.
    def create
      if (shopify_charge = DiscoApp::ChargesService.create(@shop)).nil?
        redirect_to action: :new and return
      end
      redirect_to shopify_charge.confirmation_url
    end

    # Attempt to activate a charge after a user has accepted or declined it. Redirect to the main application's root URL
    # immediately afterwards - if the charge wasn't accepted, the flow will start again.
    def activate
      if (shopify_charge = DiscoApp::ChargesService.get_accepted_charge(@shop, params[:charge_id])).nil?
        redirect_to action: :new and return
      end
      DiscoApp::ChargesService.activate(@shop, shopify_charge)
      redirect_to main_app.root_url
    end

  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
disco_app-0.3.0 app/controllers/disco_app/charges_controller.rb
disco_app-0.4.0 app/controllers/disco_app/charges_controller.rb
disco_app-0.4.1 app/controllers/disco_app/charges_controller.rb
disco_app-0.4.2 app/controllers/disco_app/charges_controller.rb
disco_app-0.4.3 app/controllers/disco_app/charges_controller.rb
disco_app-0.4.4 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.0 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.1 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.2 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.3 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.4 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.5 app/controllers/disco_app/charges_controller.rb
disco_app-0.5.6 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.0 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.1 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.2 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.3 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.4 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.5 app/controllers/disco_app/charges_controller.rb
disco_app-0.6.6 app/controllers/disco_app/charges_controller.rb