Class: Adyen::API::PaymentService::AuthorisationResponse
- Defined in:
- lib/adyen/api/payment_service.rb
Constant Summary collapse
- ERRORS =
{ "validation 101 Invalid card number" => [:number, 'is not a valid creditcard number'], "validation 103 CVC is not the right length" => [:cvc, 'is not the right length'], "validation 128 Card Holder Missing" => [:holder_name, "can't be blank"], "validation Couldn't parse expiry year" => [:expiry_year, 'could not be recognized'], "validation Expiry month should be between 1 and 12 inclusive" => [:expiry_month, 'could not be recognized'], }
- AUTHORISED =
'Authorised'
- REFUSED =
'Refused'
Instance Attribute Summary
Attributes inherited from Response
Instance Method Summary collapse
-
#error(prefix = nil) ⇒ Array<Symbol, String>
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.
-
#invalid_request? ⇒ Boolean
Returns whether or not the request was valid.
- #params ⇒ Object
- #refused? ⇒ Boolean
- #success? ⇒ Boolean (also: #authorised?, #authorized?)
Methods inherited from Response
#body, #fault_message, #http_failure?, #initialize, response_attrs, #server_error?, #xml_querier
Constructor Details
This class inherits a constructor from Adyen::API::Response
Instance Method Details
#error(prefix = nil) ⇒ Array<Symbol, String>
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.
318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/adyen/api/payment_service.rb', line 318 def error(prefix = nil) if error = ERRORS[] prefix ? ["#{prefix}_#{error[0]}".to_sym, error[1]] : error elsif [:base, ] elsif refused? [:base, 'Transaction was refused.'] else [:base, 'Transaction failed for unkown reasons.'] end end |
#invalid_request? ⇒ Boolean
Returns whether or not the request was valid.
304 305 306 |
# File 'lib/adyen/api/payment_service.rb', line 304 def invalid_request? !.nil? end |
#params ⇒ Object
330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/adyen/api/payment_service.rb', line 330 def params @params ||= xml_querier.xpath('//payment:authoriseResponse/payment:paymentResult') do |result| { :psp_reference => result.text('./payment:pspReference'), :result_code => result.text('./payment:resultCode'), :auth_code => result.text('./payment:authCode'), :additional_data => parse_additional_data(result.xpath('.//payment:additionalData')), :refusal_reason => (invalid_request? ? : result.text('./payment:refusalReason')) } end end |
#refused? ⇒ Boolean
296 297 298 |
# File 'lib/adyen/api/payment_service.rb', line 296 def refused? params[:result_code] == REFUSED end |
#success? ⇒ Boolean Also known as: ,
292 293 294 |
# File 'lib/adyen/api/payment_service.rb', line 292 def success? super && params[:result_code] == AUTHORISED end |