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