Sha256: 5771d94c859365c63794088af076779bbdc7c416ec6896c4c3baa0ae242c2147

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

module RefundMethods
  extend ActiveSupport::Concern
  included do
    class_attribute :eligible_refund_methods
    self.eligible_refund_methods = whitelisted_refund_methods || defined_refund_methods
  end

  class_methods do
    def whitelisted_refund_methods
      # Solidus 2.3.0 deprecates "Spree::Gateway::Bogus" and recommends using "Spree::PaymentMethod::BogusCreditCard" instead.
      %w[Spree::Gateway::Bogus Spree::PaymentMethod::SimpleBogusCreditCard Spree::PaymentMethod::BogusCreditCard Spree::PaymentMethod::Check Spree::PaymentMethod::StoreCredit].inject([]) do |methods, payment_method|
        methods << payment_method.constantize if Object.const_defined?(payment_method)
        methods
      end
    end

    def defined_refund_methods
      Spree::PaymentMethod.order('id DESC').pluck(:type).map(&:constantize)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus-returnly-0.6.2 app/services/refund_methods.rb