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 Method Summary collapse

Methods inherited from XmlResponse

#connection_failure?, #message_code, #message_text, #raw, #reference_id, #response_code, #response_reason_code, #response_reason_text, #result_code, #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.



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

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
      @raw_response = $!
    end
  end
end

Instance Method Details

#addressObject

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



108
109
110
# File 'lib/authorize_net/cim/response.rb', line 108

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).



47
48
49
# File 'lib/authorize_net/cim/response.rb', line 47

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.



52
53
54
# File 'lib/authorize_net/cim/response.rb', line 52

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.



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

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.



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

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).



58
59
60
# File 'lib/authorize_net/cim/response.rb', line 58

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.



63
64
65
# File 'lib/authorize_net/cim/response.rb', line 63

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.



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

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).



36
37
38
# File 'lib/authorize_net/cim/response.rb', line 36

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.



41
42
43
# File 'lib/authorize_net/cim/response.rb', line 41

def profile_ids
  @customer_profile_id_list
end

#tokenObject

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



68
69
70
# File 'lib/authorize_net/cim/response.rb', line 68

def token
  @token
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).



75
76
77
# File 'lib/authorize_net/cim/response.rb', line 75

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.



81
82
83
84
85
86
87
88
89
# File 'lib/authorize_net/cim/response.rb', line 81

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.length == 0
  end
end