Sha256: fbf3264a15acad5a4177cc82b458f42f08dd273f45cd3095226b6bbf384dd8b4

Contents?: true

Size: 907 Bytes

Versions: 136

Compression:

Stored size: 907 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

      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

136 entries across 136 versions & 1 rubygems

Version Path
spree_backend-4.8.4 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.8.3 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.8.2 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.8.1 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.0.9 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.1.15 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.2.7 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.3.3 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.7.2 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.6.2 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.7.1 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.7.0 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.6.1 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.6.0 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.5.1 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.5.0 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.2.6 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.3.2 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.4.1 app/controllers/spree/admin/refunds_controller.rb
spree_backend-4.4.0 app/controllers/spree/admin/refunds_controller.rb