Class: Hps::HpsBatchService

Inherits:
HpsService show all
Defined in:
lib/hps/services/hps_batch_service.rb

Instance Attribute Summary

Attributes inherited from HpsService

#exception_mapper

Instance Method Summary collapse

Methods inherited from HpsService

#doTransaction, #gateway_url_for_key, #hydrate_transaction_header, #initialize

Constructor Details

This class inherits a constructor from Hps::HpsService

Instance Method Details

#close_batchObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hps/services/hps_batch_service.rb', line 4

def close_batch()
  
  xml = Builder::XmlMarkup.new
  
  xml.hps :Transaction do
    xml.hps :BatchClose, "BatchClose"
  end
  
  response = doTransaction(xml.target!)
  header = response["Header"]

  unless header["GatewayRspCode"].eql? "0"
    raise @exception_mapper.map_gateway_exception(header["GatewayTxnId"], header["GatewayRspCode"], header["GatewayRspMsg"])
  end

  batch_close = response["Transaction"]["BatchClose"]
  result = HpsBatch.new()
  result.id = batch_close["BatchId"]
  result.sequence_number = batch_close["BatchSeqNbr"]
  result.total_amount = batch_close["TotalAmt"]
  result.transaction_count = batch_close["TxnCnt"]
  
  result
end