lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.103.0 vs lib/active_merchant/billing/gateways/authorize_net.rb in activemerchant-1.104.0

- old
+ new

@@ -6,11 +6,11 @@ include Empty self.test_url = 'https://apitest.authorize.net/xml/v1/request.api' self.live_url = 'https://api2.authorize.net/xml/v1/request.api' - self.supported_countries = %w(AD AT AU BE BG CA CH CY CZ DE DK EE ES FI FR GB GI GR HU IE IL IS IT LI LT LU LV MC MT NL NO PL PT RO SE SI SK SM TR US VA) + self.supported_countries = %w(AU CA US) self.default_currency = 'USD' self.money_format = :dollars self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro] self.homepage_url = 'http://www.authorize.net/' @@ -388,10 +388,11 @@ end end def add_payment_source(xml, source, options, action = nil) return unless source + if source.is_a?(String) add_token_payment_method(xml, source, options) elsif card_brand(source) == 'check' add_check(xml, source) elsif card_brand(source) == 'apple_pay' @@ -515,10 +516,11 @@ end end def add_market_type_device_type(xml, payment, options) return if payment.is_a?(String) || card_brand(payment) == 'check' || card_brand(payment) == 'apple_pay' + if valid_track_data xml.retail do xml.marketType(options[:market_type] || MARKET_TYPE[:retail]) xml.deviceType(options[:device_type] || DEVICE_TYPE[:wireless_pos]) end @@ -839,30 +841,30 @@ doc = Nokogiri::XML(body) doc.remove_namespaces! response = {action: action} - response[:response_code] = if(element = doc.at_xpath('//transactionResponse/responseCode')) + response[:response_code] = if (element = doc.at_xpath('//transactionResponse/responseCode')) empty?(element.content) ? nil : element.content.to_i end - if(element = doc.at_xpath('//errors/error')) + if (element = doc.at_xpath('//errors/error')) response[:response_reason_code] = element.at_xpath('errorCode').content[/0*(\d+)$/, 1] response[:response_reason_text] = element.at_xpath('errorText').content.chomp('.') - elsif(element = doc.at_xpath('//transactionResponse/messages/message')) + elsif (element = doc.at_xpath('//transactionResponse/messages/message')) response[:response_reason_code] = element.at_xpath('code').content[/0*(\d+)$/, 1] response[:response_reason_text] = element.at_xpath('description').content.chomp('.') - elsif(element = doc.at_xpath('//messages/message')) + elsif (element = doc.at_xpath('//messages/message')) response[:response_reason_code] = element.at_xpath('code').content[/0*(\d+)$/, 1] response[:response_reason_text] = element.at_xpath('text').content.chomp('.') else response[:response_reason_code] = nil response[:response_reason_text] = '' end response[:avs_result_code] = - if(element = doc.at_xpath('//avsResultCode')) + if (element = doc.at_xpath('//avsResultCode')) empty?(element.content) ? nil : element.content end response[:transaction_id] = if element = doc.at_xpath('//transId') @@ -958,11 +960,11 @@ def message_from(action, response, avs_result, cvv_result) if response[:response_code] == DECLINED if CARD_CODE_ERRORS.include?(cvv_result.code) return cvv_result.message - elsif(AVS_REASON_CODES.include?(response[:response_reason_code]) && AVS_ERRORS.include?(avs_result.code)) + elsif AVS_REASON_CODES.include?(response[:response_reason_code]) && AVS_ERRORS.include?(avs_result.code) return avs_result.message end end response[:response_reason_text] || response[:message_text] @@ -1005,11 +1007,11 @@ _, _, action = split_authorization(authorization) action && is_cim_action?(action) end def parse_direct_response_elements(response, options) - params = response[:direct_response] + params = response[:direct_response]&.tr('"', '') return {} unless params parts = params.split(options[:delimiter] || ',') { response_code: parts[0].to_i, @@ -1057,9 +1059,8 @@ split_tender_id: parts[52] || '', requested_amount: parts[53] || '', balance_on_card: parts[54] || '', } end - end end end