Sha256: 0263e376a445603fe71486d5f0c7194c8d0b6d101c63c5f032d14e66b96fdf2b

Contents?: true

Size: 922 Bytes

Versions: 31

Compression:

Stored size: 922 Bytes

Contents

module Spree
  module Admin
    class RefundsController < ResourceController
      belongs_to 'spree/payment', find_by: :number
      before_action :load_order

      helper_method :refund_reasons

      rescue_from Spree::Core::GatewayError, with: :spree_core_gateway_error, only: :create

      private

      def location_after_save
        admin_order_payments_path(@payment.order)
      end

      def load_order
        # the spree/admin/shared/order_tabs partial expects the @order instance variable to be set
        @order = @payment.order if @payment
      end

      def refund_reasons
        @refund_reasons ||= RefundReason.active.all
      end

      def build_resource
        super.tap do |refund|
          refund.amount = refund.payment.credit_allowed
        end
      end

      def spree_core_gateway_error(error)
        flash[:error] = error.message
        render :new
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
spree_backend-3.1.14 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.13 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.12 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.11 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.10 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.9 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.8 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.7 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.6 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.5 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.4 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.3 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.2 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.0.10 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.1 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.0 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.0.rc4 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.0.9 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.0.rc3 app/controllers/spree/admin/refunds_controller.rb
spree_backend-3.1.0.rc2 app/controllers/spree/admin/refunds_controller.rb