Sha256: 72a150ef18f21f451e49057969adb6dc019e742b6d7b19f74552b3ac93766b0d

Contents?: true

Size: 927 Bytes

Versions: 47

Compression:

Stored size: 927 Bytes

Contents

# frozen_string_literal: true

module Spree
  module Admin
    class RefundsController < ResourceController
      belongs_to 'spree/payment'
      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 ||= Spree::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

47 entries across 47 versions & 2 rubygems

Version Path
solidus_backend-2.10.5 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.10.3 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.10.2 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.6 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.8.6 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.10.1 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.5 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.10.0 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.4 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.6.6 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.7.4 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.8.5 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.3 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.2 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.10.0.beta1 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.7.3 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.6.5 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.1 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.0 app/controllers/spree/admin/refunds_controller.rb
solidus_backend-2.9.0.rc.1 app/controllers/spree/admin/refunds_controller.rb