Module: Pay::Attributes::MerchantExtension

Extended by:
ActiveSupport::Concern
Defined in:
lib/pay/attributes.rb

Instance Method Summary collapse

Instance Method Details

#set_merchant_processor(processor_name, **attributes) ⇒ Object


73
74
75
76
77
78
79
80
81
82
# File 'lib/pay/attributes.rb', line 73

def set_merchant_processor(processor_name, **attributes)
  ActiveRecord::Base.transaction do
    pay_merchants.update_all(default: false)
    pay_merchant = pay_merchants.where(processor: processor_name).first_or_initialize
    pay_merchant.update!(attributes.merge(default: true))
  end

  # Return new payment processor
  reload_merchant_processor
end