Class: Safecharge::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/safecharge/response.rb

Constant Summary collapse

ALLOWED_FIELDS =
[
  'Status', 'totalAmount', 'TransactionID', 'ClientUniqueID', 'ErrCode',
  'ExErrCode', 'AuthCode', 'Reason', 'Token', 'ReasonCode',
  'advanceResponseChecksum', 'ECI',
  'nameOnCard', 'currency', 
  'total_discount', 'total_handling', 'total_shipping', 'total_tax',
  'customData', 'merchant_unique_id', 'merchant_site_id',
  'requestVersion', 'message', 'Error', 'PPP_TransactionID', 'UserID',
  'ProductID', 'ppp_status', 'merchantLocale', 'unknownParameters', 'webMasterId'
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming_encoded_params = nil) ⇒ Response

Returns a new instance of Response.



22
23
24
# File 'lib/safecharge/response.rb', line 22

def initialize(incoming_encoded_params = nil)
  self.params = self.decode(incoming_encoded_params)
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



9
10
11
# File 'lib/safecharge/response.rb', line 9

def params
  @params
end

Class Method Details

.code(err, exerr) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/safecharge/response.rb', line 31

def self.code(err, exerr)
  return Safecharge::Constants::APPROVED if err == 0 && exerr == 0
  return Safecharge::Constants::DECLINED if err == -1 && exerr == 0
  # pending? see p 22 of the spec
  return Safecharge::Constants::ERROR if err == -1100 && exerr > 0
  # could be more specific. see p 22 of the spec for exerr codes
  return Safecharge::Constants::BANK_ERROR if err < 0 && exerr != 0
  return Safecharge::Constants:: if err == -1001
  return Safecharge::Constants::INVALID_IP if err == -1005
  return Safecharge::Constants::TIMEOUT if err == -1203
  return Safecharge::Constants::UNKNOWN_ERROR
end

Instance Method Details

#decode(param_string) ⇒ Object



26
27
28
29
# File 'lib/safecharge/response.rb', line 26

def decode(param_string)
  #todo write this.
  return {}
end