Class: AuthorizeNet::KeyValueResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/authorize_net/key_value_response.rb

Overview

The core, key/value response class. You shouldn’t instantiate this one. Instead you should use AuthorizeNet::AIM::Response or AuthorizeNet::SIM::Response.

Direct Known Subclasses

AIM::Response, SIM::Response

Defined Under Namespace

Modules: AVSResponseCode, CAVVResponseCode, CCVResponseCode, CardType, ResponseCode

Constant Summary

Constants included from TypeConversions

TypeConversions::API_FIELD_PREFIX

Instance Method Summary collapse

Methods inherited from Response

#initialize, #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

This class inherits a constructor from AuthorizeNet::Response

Instance Method Details

#approved?Boolean

Check to see if the transaction was approved.

Returns:

  • (Boolean)


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

def approved?
  @fields[:response_code] == ResponseCode::APPROVED
end

#custom_fieldsObject

Returns all the custom fields returned in the response, keyed by their field name.



111
112
113
# File 'lib/authorize_net/key_value_response.rb', line 111

def custom_fields
  @custom_fields
end

#declined?Boolean

Check to see if the transaction was declined.

Returns:

  • (Boolean)


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

def declined?
  @fields[:response_code] == ResponseCode::DECLINED
end

#error?Boolean

Check to see if the transaction was returned with an error.

Returns:

  • (Boolean)


76
77
78
# File 'lib/authorize_net/key_value_response.rb', line 76

def error?
  @fields[:response_code] == ResponseCode::ERROR
end

#fieldsObject

Returns all the fields returned in the response, keyed by their API name. Custom fields are NOT included (see custom_fields).



106
107
108
# File 'lib/authorize_net/key_value_response.rb', line 106

def fields
  @fields
end

#held?Boolean

Check to see if the transaction was held for review by Authorize.Net.

Returns:

  • (Boolean)


81
82
83
# File 'lib/authorize_net/key_value_response.rb', line 81

def held?
  @fields[:response_code] == ResponseCode::HELD
end

#response_codeObject

Returns the response code received from the gateway. Note: its better to use success?, approved?, etc. to check the response code.



87
88
89
# File 'lib/authorize_net/key_value_response.rb', line 87

def response_code
  @fields[:response_code]
end

#response_reason_codeObject

Returns the response reason code received from the gateway. This code can be used to identify why something failed by referencing the AIM documentation.



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

def response_reason_code
  @fields[:response_reason_code]
end

#response_reason_textObject

Returns the response reason text received from the gateway. This is a brief, human readable explanation of why you got the response code that you got. Note that these strings tend to be a bit vague. More detail can be gleaned from the response_reason_code.



100
101
102
# File 'lib/authorize_net/key_value_response.rb', line 100

def response_reason_text
  @fields[:response_reason_text]
end