Class: Hps::HpsCheckResponse

Inherits:
HpsTransaction show all
Defined in:
lib/hps/entities/hps_check_response.rb

Instance Attribute Summary collapse

Attributes inherited from HpsTransaction

#reference_number, #response_code, #response_text, #transaction_header, #transaction_id

Class Method Summary collapse

Methods inherited from HpsTransaction

#initialize

Constructor Details

This class inherits a constructor from Hps::HpsTransaction

Instance Attribute Details

#authorization_codeObject

Returns the value of attribute authorization_code.



3
4
5
# File 'lib/hps/entities/hps_check_response.rb', line 3

def authorization_code
  @authorization_code
end

#customer_idObject

Returns the value of attribute customer_id.



3
4
5
# File 'lib/hps/entities/hps_check_response.rb', line 3

def customer_id
  @customer_id
end

#detailsObject

Returns the value of attribute details.



3
4
5
# File 'lib/hps/entities/hps_check_response.rb', line 3

def details
  @details
end

Class Method Details

.from_hash(rsp, txn_type) ⇒ Object



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
# File 'lib/hps/entities/hps_check_response.rb', line 7

def self.from_hash(rsp, txn_type)
  header = rsp["Header"]
  data = rsp["Transaction"][txn_type.to_s]

  result = HpsCheckResponse.new(HpsService.new.hydrate_transaction_header(header))
  result.transaction_id = header["GatewayTxnId"]
  result.authorization_code = data["AuthCode"]
  result.reference_number = data["RefNbr"]
  result.response_code = data["RspCode"]
  result.response_text = data["RspMessage"]

  if data["CheckRspInfo"]
    result.details = []
    check_info = data["CheckRspInfo"]
    if check_info.is_a? Hash
      result.details = HpsCheckResponse.hydrate_rsp_details(check_info)
    else
      check_info.map { |details|
        result.details.push HpsCheckResponse.hydrate_rsp_details(details)
      }
    end
  end

  result
end