Class: Agms::SAFEResponse

Inherits:
Response show all
Defined in:
lib/agms/response/safe_response.rb

Instance Method Summary collapse

Methods inherited from Response

#doMap, #mapResponse, #toArray

Constructor Details

#initialize(response, op) ⇒ SAFEResponse

A class representing AGMS SAFE Response objects.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/agms/response/safe_response.rb', line 5

def initialize(response, op)
  super(response, op)
  @mapping = {
      'STATUS_CODE' => 'response_code',
      'STATUS_MSG' => 'response_message',
      'TRANS_ID' => 'transaction_id',
      'AUTH_CODE' => 'authorization_code',
      'AVS_CODE' => 'avs_result',
      'AVS_MSG' => 'avs_message',
      'CVV2_CODE' => 'cvv_result',
      'CVV2_MSG' => 'cvv_message',
      'ORDERID' => 'order_id',
      'SAFE_ID' => 'safe_id',
      'FULLRESPONSE' => 'full_response',
      'POSTSTRING' => 'post_string',
      'BALANCE' => 'gift_balance',
      'GIFTRESPONSE' => 'gift_response',
      'MERCHANT_ID' => 'merchant_id',
      'CUSTOMER_MESSAGE' => 'customer_message',
      'RRN' => 'rrn'
  }

  @response = response
  @op = op

  if not isSuccessful()
    response_array = toArray()
    raise ResponseError.new("Transaction failed with error code #{response_array['response_code']}  and message #{response_array['response_message']}", response_array)
  end
end

Instance Method Details

#getSafeIdObject



46
47
48
49
# File 'lib/agms/response/safe_response.rb', line 46

def getSafeId
  response_array = toArray()
  return response_array['safe_id']
end

#isSuccessfulObject



36
37
38
39
40
41
42
43
44
# File 'lib/agms/response/safe_response.rb', line 36

def isSuccessful
  response_array = toArray()
  code = response_array['response_code']
  if code != '1' and code != '2'
    return false
  else
    return true
  end
end