lib/active_merchant/billing/gateways/borgun.rb in activemerchant-1.114.0 vs lib/active_merchant/billing/gateways/borgun.rb in activemerchant-1.116.0

- old
+ new

@@ -14,48 +14,48 @@ self.money_format = :cents self.supported_cardtypes = %i[visa master american_express diners_club discover jcb] self.homepage_url = 'https://www.borgun.is/' - def initialize(options={}) + def initialize(options = {}) requires!(options, :processor, :merchant_id, :username, :password) super end - def purchase(money, payment, options={}) + def purchase(money, payment, options = {}) post = {} post[:TransType] = '1' add_invoice(post, money, options) add_payment_method(post, payment) commit('sale', post) end - def authorize(money, payment, options={}) + def authorize(money, payment, options = {}) post = {} post[:TransType] = '5' add_invoice(post, money, options) add_payment_method(post, payment) commit('authonly', post, options) end - def capture(money, authorization, options={}) + def capture(money, authorization, options = {}) post = {} post[:TransType] = '1' add_invoice(post, money, options) add_reference(post, authorization) commit('capture', post) end - def refund(money, authorization, options={}) + def refund(money, authorization, options = {}) post = {} post[:TransType] = '3' add_invoice(post, money, options) add_reference(post, authorization) commit('refund', post) end - def void(authorization, options={}) + def void(authorization, options = {}) post = {} # TransType, TrAmount, and currency must match original values from auth or purchase. _, _, _, _, _, transtype, tramount, currency = split_authorization(authorization) post[:TransType] = transtype options[:currency] = options[:currency] || CURRENCY_CODES.key(currency) @@ -74,11 +74,11 @@ gsub(%r(((?:\r\n)?Authorization: Basic )[^\r\n]+(\r\n)?), '\1[FILTERED]\2') end private - CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") } + CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") } CURRENCY_CODES['ISK'] = '352' CURRENCY_CODES['EUR'] = '978' CURRENCY_CODES['USD'] = '840' def add_invoice(post, money, options) @@ -123,11 +123,11 @@ end response end - def commit(action, post, options={}) + def commit(action, post, options = {}) post[:Version] = '1000' post[:Processor] = @options[:processor] post[:MerchantID] = @options[:merchant_id] request = build_request(action, post, options) @@ -178,11 +178,11 @@ { 'Authorization' => 'Basic ' + Base64.strict_encode64(@options[:username].to_s + ':' + @options[:password].to_s) } end - def build_request(action, post, options={}) + def build_request(action, post, options = {}) mode = action == 'void' ? 'cancel' : 'get' xml = Builder::XmlMarkup.new indent: 18 xml.instruct!(:xml, version: '1.0', encoding: 'utf-8') xml.tag!("#{mode}Authorization") do post.each do |field, value| @@ -203,21 +203,21 @@ end end end def envelope(mode) - <<-EOS + <<-XML <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aut="http://Borgun/Heimir/pub/ws/Authorization"> <soapenv:Header/> <soapenv:Body> <aut:#{mode}AuthorizationInput> <#{mode}AuthReqXml> {{ :body }} </#{mode}AuthReqXml> </aut:#{mode}AuthorizationInput> </soapenv:Body> </soapenv:Envelope> - EOS + XML end def url(action) (test? ? test_url : live_url) end