lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.66.0 vs lib/active_merchant/billing/gateways/cyber_source.rb in activemerchant-1.67.0

- old
+ new

@@ -689,11 +689,12 @@ rescue REXML::ParseException => e response = { message: e.to_s } end success = response[:decision] == "ACCEPT" - message = @@response_codes[('r' + response[:reasonCode]).to_sym] rescue response[:message] + message = response[:message] + authorization = success ? [ options[:order_id], response[:requestID], response[:requestToken], action, amount, options[:currency]].compact.join(";") : nil Response.new(success, message, response, :test => test?, :authorization => authorization, @@ -707,13 +708,14 @@ def parse(xml) reply = {} xml = REXML::Document.new(xml) if root = REXML::XPath.first(xml, "//c:replyMessage") root.elements.to_a.each do |node| - case node.name + case node.expanded_name when 'c:reasonCode' - reply[:message] = reply(node.text) + reply[:reasonCode] = node.text + reply[:message] = reason_message(node.text) else parse_element(reply, node) end end elsif root = REXML::XPath.first(xml, "//soap:Fault") @@ -726,16 +728,21 @@ def parse_element(reply, node) if node.has_elements? node.elements.each{|e| parse_element(reply, e) } else if node.parent.name =~ /item/ - parent = node.parent.name + (node.parent.attributes["id"] ? "_" + node.parent.attributes["id"] : '') - reply[(parent + '_' + node.name).to_sym] = node.text - else - reply[node.name.to_sym] = node.text + parent = node.parent.name + parent += '_' + node.parent.attributes["id"] if node.parent.attributes["id"] + parent += '_' end + reply["#{parent}#{node.name}".to_sym] ||= node.text end return reply + end + + def reason_message(reason_code) + return if reason_code.blank? + @@response_codes[:"r#{reason_code}"] end end end end