class AuthorizeNet::XmlResponse
The core, xml response class. You shouldn’t instantiate this one. Instead you should use AuthorizeNet::ARB::Response.
Attributes
Returns the messageCode from the XML response. This is a code indicating the details of an error or success.
Returns the messageText from the XML response. This is a text description of the message_code.
Returns the refId from the response if there is one. Otherwise returns nil.
Returns the resultCode from the XML response. resultCode will be either ‘Ok’ or ‘Error’.
Public Class Methods
DO NOT USE. Instantiate AuthorizeNet::ARB::Response or AuthorizeNet::CIM::Response instead.
# File lib/authorize_net/xml_response.rb, line 6 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 StandardError @raw_response = $ERROR_INFO end end end
Public Instance Methods
Returns true if we failed to open a connection to the gateway or got back a non-200 OK HTTP response.
# File lib/authorize_net/xml_response.rb, line 33 def connection_failure? !@raw_response.is_a?(Net::HTTPOK) end
Returns the underlying Net::HTTPResponse object. This has the original response body along with headers and such. Note that if an exception is generated while making the request (which happens if there is no internet connection for example), you will get the exception object here instead of a Net::HTTPResponse object.
# File lib/authorize_net/xml_response.rb, line 41 def raw @raw_response end
Alias for result_code.
# File lib/authorize_net/xml_response.rb, line 61 def response_code result_code end
Alias for message_code.
# File lib/authorize_net/xml_response.rb, line 66 def response_reason_code message_code end
Alias for message_text.
# File lib/authorize_net/xml_response.rb, line 71 def response_reason_text message_text end
Check to see if the response indicated success. Success is defined as a 200 OK response with a resultCode of ‘Ok’.
# File lib/authorize_net/xml_response.rb, line 28 def success? !connection_failure? && @result_code == 'Ok' end
Returns a deep-copy of the XML object received from the payment gateway. Or nil if there was no XML payload.
# File lib/authorize_net/xml_response.rb, line 46 def xml @root.dup unless @root.nil? end