Class: CardConnect::Service::VoidResponse

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

Constant Summary collapse

FIELDS =
[:merchid, :amount, :currency, :retref, :authcode,
:respcode, :respproc, :respstat, :resptext].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) ⇒ VoidResponse

Returns a new instance of VoidResponse.



16
17
18
19
20
# File 'lib/cardconnect/services/void/void_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/void/void_response.rb', line 10

def errors
  @errors
end

Instance Method Details

#bodyObject



26
27
28
# File 'lib/cardconnect/services/void/void_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/void/void_response.rb', line 22

def success?
  errors.empty?
end