class Hps::HpsBatchService

Public Instance Methods

close_batch() click to toggle source
# 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