Class: CardConnect::Service::AuthorizationResponse

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/cardconnect/services/authorization/authorization_response.rb

Constant Summary collapse

FIELDS =
[:respstat, :retref, :account, :expiry, :token, :amount, :merchid, :respcode,
:resptext, :respproc, :avsresp, :cvvresp, :authcode, :commcard, :profileid, :acctid].freeze
STATUS_APPROVED =
'A'.freeze
STATUS_RETRY =
'B'.freeze
STATUS_DECLINED =
'C'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#set_attributes, #symbolize_keys

Constructor Details

#initialize(response) ⇒ AuthorizationResponse

Returns a new instance of AuthorizationResponse.



16
17
18
19
20
# File 'lib/cardconnect/services/authorization/authorization_response.rb', line 16

def initialize(response)
  set_attributes(response, FIELDS)
  @errors = []
  process_errors
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



10
11
12
# File 'lib/cardconnect/services/authorization/authorization_response.rb', line 10

def errors
  @errors
end

Instance Method Details

#bodyObject



26
27
28
# File 'lib/cardconnect/services/authorization/authorization_response.rb', line 26

def body
  FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
end

#success?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/cardconnect/services/authorization/authorization_response.rb', line 22

def success?
  errors.empty?
end