module Pay::Attributes::MerchantExtension

Public Instance Methods

set_merchant_processor(processor_name, **attributes) click to toggle source
# File lib/pay/attributes.rb, line 51
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