Class: Ideal::Response
- Inherits:
-
Object
- Object
- Ideal::Response
- Defined in:
- lib/ideal/response.rb
Overview
Response classes
-
Response
-
TransactionResponse
-
StatusResponse
-
DirectoryResponse
See the Response class for more information on errors.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#consumer_error_message ⇒ Object
Returns a consumer friendly error message.
-
#error_code ⇒ Object
Returns the code of the error that occured.
-
#error_details ⇒ Object
Returns details on the error if available.
-
#error_message ⇒ Object
Returns a technical error message.
-
#error_type ⇒ Object
Returns an error type inflected from the first two characters of the error code.
-
#initialize(response_body, options = {}) ⇒ Response
constructor
A new instance of Response.
-
#success? ⇒ Boolean
Returns whether the request was a success.
-
#test? ⇒ Boolean
Returns whether we’re running in test mode.
Constructor Details
#initialize(response_body, options = {}) ⇒ Response
Returns a new instance of Response.
20 21 22 23 24 25 26 27 28 |
# File 'lib/ideal/response.rb', line 20 def initialize(response_body, = {}) #@response = REXML::Document.new(response_body).root @body = response_body doc = Nokogiri::XML(response_body) doc.remove_namespaces! @response = doc.root @success = !error_occured? @test = [:test] ? [:test] : false end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
18 19 20 |
# File 'lib/ideal/response.rb', line 18 def response @response end |
Instance Method Details
#consumer_error_message ⇒ Object
Returns a consumer friendly error message.
46 47 48 |
# File 'lib/ideal/response.rb', line 46 def text('//Error/consumerMessage') unless success? end |
#error_code ⇒ Object
Returns the code of the error that occured.
Codes
IX: Invalid XML and all related problems
Such as incorrect encoding, invalid version, or otherwise unreadable:
-
IX1000
- Received XML not well-formed. -
IX1100
- Received XML not valid. -
IX1200
- Encoding type not UTF-8. -
IX1300
- XML version number invalid. -
IX1400
- Unknown message. -
IX1500
- Mandatory main value missing. (Merchant ID ?) -
IX1600
- Mandatory value missing.
SO: System maintenance or failure
The errors that are communicated in the event of system maintenance or system failure. Also covers the situation where new requests are no longer being accepted but requests already submitted will be dealt with (until a certain time):
-
SO1000
- Failure in system. -
SO1200
- System busy. Try again later. -
SO1400
- Unavailable due to maintenance.
SE: Security and authentication errors
Incorrect authentication methods and expired certificates:
-
SE2000
- Authentication error. -
SE2100
- Authentication method not supported. -
SE2700
- Invalid electronic signature.
BR: Field errors
Extra information on incorrect fields:
-
BR1200
- iDEAL version number invalid. -
BR1210
- Value contains non-permitted character. -
BR1220
- Value too long. -
BR1230
- Value too short. -
BR1240
- Value too high. -
BR1250
- Value too low. -
BR1250
- Unknown entry in list. -
BR1270
- Invalid date/time. -
BR1280
- Invalid URL.
AP: Application errors
Errors relating to IDs, account numbers, time zones, transactions:
-
AP1000
- Acquirer ID unknown. -
AP1100
- Merchant ID unknown. -
AP1200
- Issuer ID unknown. -
AP1300
- Sub ID unknown. -
AP1500
- Merchant ID not active. -
AP2600
- Transaction does not exist. -
AP2620
- Transaction already submitted. -
AP2700
- Bank account number not 11-proof. -
AP2900
- Selected currency not supported. -
AP2910
- Maximum amount exceeded. (Detailed record states the maximum amount). -
AP2915
- Amount too low. (Detailed record states the minimum amount). -
AP2920
- Please adjust expiration period. See suggested expiration period.
147 148 149 |
# File 'lib/ideal/response.rb', line 147 def error_code text('//errorCode') unless success? end |
#error_details ⇒ Object
Returns details on the error if available.
51 52 53 |
# File 'lib/ideal/response.rb', line 51 def error_details text('//Error/errorDetail') unless success? end |
#error_message ⇒ Object
Returns a technical error message.
41 42 43 |
# File 'lib/ideal/response.rb', line 41 def text('//Error/errorMessage') unless success? end |
#error_type ⇒ Object
Returns an error type inflected from the first two characters of the error code. See error_code for a full list of errors.
Error code to type mappings:
-
IX
-:xml
-
SO
-:system
-
SE
-:security
-
BR
-:value
-
AP
-:application
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ideal/response.rb', line 65 def error_type unless success? case error_code[0, 2] when 'IX' then :xml when 'SO' then :system when 'SE' then :security when 'BR' then :value when 'AP' then :application end end end |
#success? ⇒ Boolean
Returns whether the request was a success
36 37 38 |
# File 'lib/ideal/response.rb', line 36 def success? @success end |
#test? ⇒ Boolean
Returns whether we’re running in test mode
31 32 33 |
# File 'lib/ideal/response.rb', line 31 def test? @test end |