Class: Ideal::StatusResponse

Inherits:
Response show all
Defined in:
lib/ideal/response.rb

Overview

An instance of StatusResponse is returned from Gateway#capture which returns whether or not the transaction that was started with Gateway#setup_purchase was successful.

It takes care of checking if the message was authentic by verifying the the message and its signature against the iDEAL certificate.

If success? returns false because the authenticity wasn't verified there will be no error_code, error_message, and error_type. Use verified? to check if the authenticity has been verified.

Instance Attribute Summary

Attributes inherited from Response

#response

Instance Method Summary collapse

Methods inherited from Response

#consumer_error_message, #error_code, #error_details, #error_message, #error_type, #success?, #test?

Constructor Details

#initialize(response_body, options = {}) ⇒ StatusResponse

Returns a new instance of StatusResponse


205
206
207
208
# File 'lib/ideal/response.rb', line 205

def initialize(response_body, options = {})
  super
  @success = transaction_successful?
end

Instance Method Details

#consumer_bicObject

Returns the BIC of the bankaccount of the customer when the transaction was succesfull


238
239
240
# File 'lib/ideal/response.rb', line 238

def consumer_bic
  text('//consumerBIC')
end

#consumer_ibanObject

Returns the bankaccount number when the transaction was successful.


226
227
228
# File 'lib/ideal/response.rb', line 226

def consumer_iban
  text('//consumerIBAN')
end

#consumer_nameObject

Returns the name on the bankaccount of the customer when the transaction was successful.


232
233
234
# File 'lib/ideal/response.rb', line 232

def consumer_name
  text('//consumerName')
end

#signatureObject


242
243
244
# File 'lib/ideal/response.rb', line 242

def signature
  Base64.decode64(text('//SignatureValue'))
end

#statusObject

Returns the status message, which is one of: :success, :cancelled, :expired, :open, or :failure.


213
214
215
216
# File 'lib/ideal/response.rb', line 213

def status
  status = text('//status')
  status.downcase.to_sym unless (status.nil? || status.strip == '')
end

#verified?Boolean

Returns whether or not the authenticity of the message could be verified.

Returns:

  • (Boolean)

220
221
222
223
# File 'lib/ideal/response.rb', line 220

def verified?
  signed_document = Xmldsig::SignedDocument.new(@body)
  @verified ||= signed_document.validate(Ideal::Gateway.ideal_certificate)
end