Sha256: 3e9531ee55452ded610ddf1cb63d7cdf2e4c10940c2b6f574e0ef472070bd5f6

Contents?: true

Size: 948 Bytes

Versions: 4

Compression:

Stored size: 948 Bytes

Contents

module SolidusPaypalBraintree
  class ConfigurationsController < Spree::Admin::BaseController
    helper Spree::Core::Engine.routes.url_helpers

    def list
      authorize! :list, SolidusPaypalBraintree::Configuration

      @configurations = Spree::Store.all.map(&:braintree_configuration)
    end

    def update
      authorize! :update, SolidusPaypalBraintree::Configuration

      params = configurations_params[:configuration_fields]
      if SolidusPaypalBraintree::Configuration.update(params.keys, params.values)
        flash[:success] = t('update_success', scope: 'solidus_paypal_braintree.configurations')
      else
        flash[:error] = t('update_error', scope: 'solidus_paypal_braintree.configurations')
      end
      redirect_to action: :list
    end

    private

    def configurations_params
      params.require(:configurations).
        permit(configuration_fields: [:paypal, :apple_pay, :credit_card])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_paypal_braintree-0.4.0 lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb
solidus_paypal_braintree-0.3.0 lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb
solidus_paypal_braintree-0.2.0 lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb
solidus_paypal_braintree-0.1.0 lib/controllers/backend/solidus_paypal_braintree/configurations_controller.rb