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 # Override this methods to whitelist payment methods [] end def defined_refund_methods payment_methods = Spree::PaymentMethod.pluck(:type) sorted_payment_methods = payment_methods.reject { |payment_method| payment_method =~ /StoreCredit/ } (sorted_payment_methods | payment_methods).map(&:constantize) end end end