Sha256: fae0c4748480dc2dbfc0c09a27a5698911f4a13bdfccb4567fd5856c152f5ce7
Contents?: true
Size: 1.66 KB
Versions: 5
Compression:
Stored size: 1.66 KB
Contents
class Kaui::PaymentMethod < KillBillClient::Model::PaymentMethod def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) if search_key.present? find_in_batches_by_search_key(search_key, offset, limit, options) else find_in_batches(offset, limit, options) end end def self.find_all_safely_by_account_id(account_id, options = {}) begin Kaui::PaymentMethod.find_all_by_account_id(account_id, true, options) rescue KillBillClient::API::BadRequest # Maybe the plugin(s) are not registered? Kaui::PaymentMethod.find_all_by_account_id(account_id, false, options) end end def self.find_non_external_by_account_id(account_id, with_plugin_info = false, options = {}) payment_methods = find_all_by_account_id(account_id, with_plugin_info, options) payment_methods.reject { |x| x.plugin_name == '__EXTERNAL_PAYMENT__' } end def self.payment_methods_for_payments(payments = [], options = {}) payment_method_per_payment = {} payment_methods_cache = {} deleted_payment_methods = Set.new payments.each do |payment| next if deleted_payment_methods.include?(payment.payment_method_id) # The payment method may have been deleted payment_methods_cache[payment.payment_method_id] ||= Kaui::PaymentMethod.find_by_id(payment.payment_method_id, true, options) rescue nil if payment_methods_cache[payment.payment_method_id].nil? deleted_payment_methods.add(payment.payment_method_id) else payment_method_per_payment[payment.payment_id] = payment_methods_cache[payment.payment_method_id] end end payment_method_per_payment end end
Version data entries
5 entries across 5 versions & 1 rubygems