Class: Adyen::API::PaymentService::AuthorizationResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/adyen/api.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'

Instance Attribute Summary

Attributes inherited from Response

#http_response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#http_failure?, #initialize, response_attrs, #xml_querier

Constructor Details

This class inherits a constructor from Adyen::API::Response

Class Method Details

.original_fault_message_for(attribute, message) ⇒ Object



294
295
296
297
298
299
300
# File 'lib/adyen/api.rb', line 294

def self.original_fault_message_for(attribute, message)
  if error = ERRORS.find { |_, (a, m)| a == attribute && m == message }
    error.first
  else
    message
  end
end

Instance Method Details

#error(prefix = nil) ⇒ Object



314
315
316
317
318
319
320
# File 'lib/adyen/api.rb', line 314

def error(prefix = nil)
  if error = ERRORS[fault_message]
    prefix ? ["#{prefix}_#{error[0]}".to_sym, error[1]] : error
  else
    [:base, fault_message]
  end
end

#invalid_request?Boolean

Returns:

  • (Boolean)


310
311
312
# File 'lib/adyen/api.rb', line 310

def invalid_request?
  !fault_message.nil?
end

#paramsObject



322
323
324
325
326
327
328
329
330
331
# File 'lib/adyen/api.rb', line 322

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'),
      :refusal_reason => (invalid_request? ? fault_message : result.text('./payment:refusalReason'))
    }
  end
end

#success?Boolean Also known as: authorized?

Returns:

  • (Boolean)


304
305
306
# File 'lib/adyen/api.rb', line 304

def success?
  super && params[:result_code] == AUTHORISED
end