Class: ActiveMerchant::Billing::IdealStatusResponse

Inherits:
IdealResponse
  • Object
show all
Defined in:
lib/active_merchant_ideal/ideal_response.rb

Overview

An instance of IdealStatusResponse is returned from IdealGateway#capture which returns whether or not the transaction that was started with IdealGateway#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 Method Summary collapse

Methods inherited from IdealResponse

#consumer_error_message, #error_code, #error_details, #error_message, #error_type

Constructor Details

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

Returns a new instance of IdealStatusResponse.



172
173
174
175
# File 'lib/active_merchant_ideal/ideal_response.rb', line 172

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

Instance Method Details

#consumer_account_numberObject

Returns the bankaccount number when the transaction was successful.



193
194
195
# File 'lib/active_merchant_ideal/ideal_response.rb', line 193

def 
  text('//consumerAccountNumber')
end

#consumer_cityObject

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



205
206
207
# File 'lib/active_merchant_ideal/ideal_response.rb', line 205

def consumer_city
  text('//consumerCity')
end

#consumer_nameObject

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



199
200
201
# File 'lib/active_merchant_ideal/ideal_response.rb', line 199

def consumer_name
  text('//consumerName')
end

#statusObject

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



180
181
182
183
# File 'lib/active_merchant_ideal/ideal_response.rb', line 180

def status
  status = text('//status')
  status.downcase.to_sym unless status.blank?
end

#verified?Boolean

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

Returns:

  • (Boolean)


187
188
189
190
# File 'lib/active_merchant_ideal/ideal_response.rb', line 187

def verified?
  @verified ||= IdealGateway.ideal_certificate.public_key.
                  verify(OpenSSL::Digest::SHA1.new, signature, message)
end