class Adyen::API::PaymentService::AuthorisationResponse
Constants
- AUTHORISED
- ERRORS
- REFUSED
Public Instance Methods
error(prefix = nil)
click to toggle source
In the case of a validation error, or SOAP fault message, this method will return an array describing what attribute failed validation and the accompanying message. If the errors is not of the common user validation errors, then the attribute is :base
and the full original message is returned.
An optional prefix
can be given so you can seamlessly integrate this in your ActiveRecord model and copy over errors.
@param [String,Symbol] prefix A string that should be used to prefix the error key. @return [Array<Symbol, String>] A name-message pair of the attribute with an error.
# File lib/adyen/api/payment_service.rb 318 def error(prefix = nil) 319 if error = ERRORS[fault_message] 320 prefix ? ["#{prefix}_#{error[0]}".to_sym, error[1]] : error 321 elsif fault_message 322 [:base, fault_message] 323 elsif refused? 324 [:base, 'Transaction was refused.'] 325 else 326 [:base, 'Transaction failed for unkown reasons.'] 327 end 328 end
invalid_request?()
click to toggle source
@return [Boolean] Returns whether or not the request was valid.
# File lib/adyen/api/payment_service.rb 304 def invalid_request? 305 !fault_message.nil? 306 end
params()
click to toggle source
# File lib/adyen/api/payment_service.rb 330 def params 331 @params ||= xml_querier.xpath('//payment:authoriseResponse/payment:paymentResult') do |result| 332 { 333 :psp_reference => result.text('./payment:pspReference'), 334 :result_code => result.text('./payment:resultCode'), 335 :auth_code => result.text('./payment:authCode'), 336 :additional_data => parse_additional_data(result.xpath('.//payment:additionalData')), 337 :refusal_reason => (invalid_request? ? fault_message : result.text('./payment:refusalReason')) 338 } 339 end 340 end
refused?()
click to toggle source
# File lib/adyen/api/payment_service.rb 296 def refused? 297 params[:result_code] == REFUSED 298 end
success?()
click to toggle source
Calls superclass method
# File lib/adyen/api/payment_service.rb 292 def success? 293 super && params[:result_code] == AUTHORISED 294 end
Also aliased as: authorised?, authorized?
Private Instance Methods
parse_additional_data(xpath)
click to toggle source
# File lib/adyen/api/payment_service.rb 343 def parse_additional_data(xpath) 344 if xpath.empty? 345 {} 346 else 347 results = {} 348 349 xpath.map do |node| 350 key = node.text('./payment:entry/payment:key') 351 value = node.text('./payment:entry/payment:value') 352 results[key] = value unless key.empty? 353 end 354 355 results 356 end 357 end