module RefundMethods extend ActiveSupport::Concern included do class_attribute :eligible_refund_methods self.eligible_refund_methods = whitelisted_refund_methods.empty? ? defined_refund_methods : whitelisted_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| begin methods << payment_method.constantize methods rescue methods end end end def defined_refund_methods Spree::PaymentMethod.order('id DESC').pluck(:type).map(&:constantize) end end end