Class: AuthorizeNet::CIM::Response

Inherits:
XmlResponse show all
Includes:
Fields
Defined in:
lib/authorize_net/cim/response.rb

Overview

The CIM response class.

Constant Summary

Constants included from Fields

Fields::ADDRESS_ENTITY_DESCRIPTION, Fields::ADDRESS_FIELDS, Fields::BILL_TO_FIELDS, Fields::CREATE_ADDRESS_FIELDS, Fields::CREATE_PAYMENT_FIELDS, Fields::CREATE_PROFILE_FIELDS, Fields::CREATE_TRANSACTION_FIELDS, Fields::CREDIT_CARD_ENTITY_DESCRIPTION, Fields::CUSTOMER_PAYMENT_PROFILE_ID_FIELDS, Fields::CUSTOMER_PROFILE_ID_FIELDS, Fields::DELETE_ADDRESS_FIELDS, Fields::DELETE_PAYMENT_FIELDS, Fields::DELETE_PROFILE_FIELDS, Fields::ECHECK_ENTITY_DESCRIPTION, Fields::FIELDS, Fields::GET_ADDRESS_FIELDS, Fields::GET_HOSTED_PROFILE_FIELDS, Fields::GET_PAYMENT_FIELDS, Fields::GET_PROFILE_FIELDS, Fields::GET_PROFILE_IDS_FIELDS, Fields::PAYMENT_PROFILE_ENTITY_DESCRIPTION, Fields::PAYMENT_PROFILE_FIELDS, Fields::PROFILE_ENTITY_DESCRIPTION, Fields::PROFILE_FIELDS, Fields::REFID_FIELDS, Fields::SHIP_TO_FIELDS, Fields::TRANSACTION_AUTH_CAPTURE_FIELDS, Fields::TRANSACTION_AUTH_FIELDS, Fields::TRANSACTION_CAPTURE_FIELDS, Fields::TRANSACTION_FIELDS, Fields::TRANSACTION_PRIOR_AUTH_CAPTURE_FIELDS, Fields::TRANSACTION_REFUND_FIELDS, Fields::TRANSACTION_VOID_FIELDS, Fields::UPDATE_ADDRESS_FIELDS, Fields::UPDATE_PAYMENT_FIELDS, Fields::UPDATE_PROFILE_FIELDS, Fields::UPDATE_SPLIT_FIELDS, Fields::VALIDATE_PAYMENT_FIELDS, Fields::VALIDATION_MODE_FIELDS

Constants included from TypeConversions

TypeConversions::API_FIELD_PREFIX

Instance Attribute Summary collapse

Attributes inherited from XmlResponse

#message_code, #message_text, #reference_id, #result_code

Instance Method Summary collapse

Methods inherited from XmlResponse

#connection_failure?, #raw, #response_code, #response_reason_code, #response_reason_text, #success?, #xml

Methods inherited from Response

#success?

Methods included from TypeConversions

#boolean_to_value, #date_to_value, #datetime_to_value, #decimal_to_value, #integer_to_value, #to_external_field, #to_internal_field, #to_param, #value_to_boolean, #value_to_date, #value_to_datetime, #value_to_decimal, #value_to_integer

Constructor Details

#initialize(raw_response, transaction) ⇒ Response

Constructs a new response object from raw_response in the context of transaction. You don‘t typically construct this object yourself, as AuthorizeNet::CIM::Transaction will build one for you when it makes the request to the gateway.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/authorize_net/cim/response.rb', line 9

def initialize(raw_response, transaction)
  super
  unless connection_failure?
    begin
      @customer_profile_id = node_content_unless_nil(@root.at_css('customerProfileId'))
      @customer_payment_profile_id = node_content_unless_nil(@root.at_css('customerPaymentProfileId'))
      @customer_payment_profile_id_list = node_child_content_unless_nil(@root.at_css('customerPaymentProfileIdList'))
      @customer_shipping_address_id_list = node_child_content_unless_nil(@root.at_css('customerShippingAddressIdList'))
      @customer_address_id = node_content_unless_nil(@root.at_css('customerAddressId'))
      @validation_direct_response_list = @root.at_css('validationDirectResponseList')
      @validation_direct_response = @root.at_css('validationDirectResponse')
      @direct_response = @root.at_css('directResponse')
      @customer_profile_id_list = node_child_content_unless_nil(@root.at_css('ids'))
      @address = @root.at_css('address')
      @payment_profile = @root.at_css('paymentProfile')
      @profile = @root.at_css('profile')
      @token = node_content_unless_nil(@root.at_css('token'))
    rescue StandardError
      @raw_response = $ERROR_INFO
    end
  end
end

Instance Attribute Details

#tokenObject (readonly)

Returns hosted profile access token when requested. Returns nil otherwise.



66
67
68
# File 'lib/authorize_net/cim/response.rb', line 66

def token
  @token
end

Instance Method Details

#addressObject

Returns an Address built from the entity returned by the gateway. Returns nil otherwise.



104
105
106
# File 'lib/authorize_net/cim/response.rb', line 104

def address
  build_entity(@address, Fields::ADDRESS_ENTITY_DESCRIPTION) unless @address.nil?
end

#address_idObject

Returns an Address ID if one was returned by the gateway. Returns nil otherwise. Note that this method will return nil if we got back a list of IDs (see address_ids).



45
46
47
# File 'lib/authorize_net/cim/response.rb', line 45

def address_id
  @customer_address_id
end

#address_idsObject

Returns a list of Address IDs if any were returned by the gateway. Returns nil otherwise.



50
51
52
# File 'lib/authorize_net/cim/response.rb', line 50

def address_ids
  @customer_shipping_address_id_list
end

#direct_responseObject

Returns the direct response as an AuthorizeNet::AIM::Response object if a direct response was returned by the gateway. Returns nil otherwise.



89
90
91
# File 'lib/authorize_net/cim/response.rb', line 89

def direct_response
  AuthorizeNet::AIM::Response.new(@direct_response.dup, @transaction) unless @direct_response.nil?
end

#payment_profileObject

Returns a PaymentProfile built from the entity returned by the gateway. Returns nil otherwise.



99
100
101
# File 'lib/authorize_net/cim/response.rb', line 99

def payment_profile
  build_entity(@payment_profile, Fields::PAYMENT_PROFILE_ENTITY_DESCRIPTION) unless @payment_profile.nil?
end

#payment_profile_idObject

Returns a PaymentProfile ID if one was returned by the gateway. Returns nil otherwise. Note that this method will return nil if we got back a list of IDs (see payment_profile_ids).



56
57
58
# File 'lib/authorize_net/cim/response.rb', line 56

def payment_profile_id
  @customer_payment_profile_id
end

#payment_profile_idsObject

Returns a list of PaymentProfile IDs if any were returned by the gateway. Returns nil otherwise.



61
62
63
# File 'lib/authorize_net/cim/response.rb', line 61

def payment_profile_ids
  @customer_payment_profile_id_list
end

#profileObject

Returns a CustomerProfile built from the entity returned by the gateway. Returns nil otherwise.



94
95
96
# File 'lib/authorize_net/cim/response.rb', line 94

def profile
  build_entity(@profile, Fields::PROFILE_ENTITY_DESCRIPTION) unless @profile.nil?
end

#profile_idObject

Returns a CustomerProfile ID if one was returned by the gateway. Returns nil otherwise. Note that this method will return nil if we got back a list of IDs (see profile_ids).



34
35
36
# File 'lib/authorize_net/cim/response.rb', line 34

def profile_id
  @customer_profile_id
end

#profile_idsObject

Returns a list of CustomerProfile IDs if any were returned by the gateway. Returns nil otherwise.



39
40
41
# File 'lib/authorize_net/cim/response.rb', line 39

def profile_ids
  @customer_profile_id_list
end

#validation_responseObject

Returns a validation response as an AuthorizeNet::AIM::Response object if a validation response was returned by the gateway. Returns nil otherwise. Note that this method will return nil if we got back a list of IDs (see validation_responses).



71
72
73
# File 'lib/authorize_net/cim/response.rb', line 71

def validation_response
  AuthorizeNet::AIM::Response.new(@validation_direct_response.dup, @transaction) unless @validation_direct_response.nil?
end

#validation_responsesObject

Returns a list of validation response as an AuthorizeNet::AIM::Response objects if a list of validation response was returned by the gateway. Returns nil otherwise.



77
78
79
80
81
82
83
84
85
# File 'lib/authorize_net/cim/response.rb', line 77

def validation_responses
  unless @validation_direct_response_list.nil?
    responses = []
    @validation_direct_response_list.element_children.each do |child|
      responses <<= AuthorizeNet::AIM::Response.new(child.dup, @transaction) unless child.nil?
    end
    return responses unless responses.empty?
  end
end