Method: AuthorizeNet::XmlResponse#initialize

Defined in:
lib/authorize_net/xml_response.rb

#initialize(raw_response, transaction) ⇒ XmlResponse

DO NOT USE. Instantiate AuthorizeNet::ARB::Response or AuthorizeNet::CIM::Response instead.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/authorize_net/xml_response.rb', line 8

def initialize(raw_response, transaction)
  @raw_response = raw_response
  @transaction = transaction
  unless connection_failure?
    begin
      xml = Nokogiri::XML(@raw_response.body) do |config|
        # confirm noent is the right flag
        config.recover.noent.nonet
      end
      @root = xml.children[0]
      @result_code = node_content_unless_nil(@root.at_css('messages resultCode'))
      @message_code = node_content_unless_nil(@root.at_css('messages message code'))
      @message_text = node_content_unless_nil(@root.at_css('messages message text'))
      @reference_id = node_content_unless_nil(@root.at_css('refId'))
    rescue
      @raw_response = $!
    end
  end
end