Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- saleHash = {
- 'reportGroup'=>'Planets',
- 'id' => '006',
- 'orderId'=>'12344',
- 'amount'=>'6000',
- 'orderSource'=>'ecommerce',
- 'card'=>{
- 'type'=>'VI',
- 'number' =>'4100000000000001',
- 'expDate' =>'1210'
- }}
- accountUpdateHash = {
- 'reportGroup'=>'Planets',
- 'id'=>'12345',
- 'customerId'=>'0987',
- 'orderId'=>'1234',
- 'card'=>{
- 'type'=>'VI',
- 'number' =>'4100000000000001',
- 'expDate' =>'1210'
- }}
- rfrHash = {
- 'merchantId'=>101,
- 'postDay'=>'2013-06-04'
- }
- path = Dir.pwd
- request = LitleOnline::LitleRequest.new({'sessionId'=>'8675309'})
- request.create_new_litle_request(path)
- puts "Created new LitleRequest at location: " + path
- start = Time::now
- batch = LitleOnline::LitleBatchRequest.new
- batch.create_new_batch(path)
- batch.sale(saleHash)
- batch.account_update(accountUpdateHash)
- #close the batch, indicating we plan to add no more transactions
- batch.close_batch()
- #add the batch to the LitleRequest
- request.commit_batch(batch)
- request.add_rfr_request(rfrHash)
- #finish the Litle Request, indicating we plan to add no more batches
- request.finish_request
- puts "Generated final XML markup of the LitleRequest"
- #send the batch files at the given directory over fastBatch and save the responses
- request.send_to_litle_stream
- #process the responses from the server with a listener which applies the given block
- start = Time::now
- request.process_responses({:transaction_listener => LitleOnline::DefaultLitleListener.new do |transaction|
- type = transaction["type"]
- #if we're dealing with a saleResponse (check the Litle XML Reference Guide!)
- if(type == "saleResponse") then
- #grab an attribute of the parent of the response
- puts "Report Group: " + transaction["reportGroup"]
- #grab some child elements of the transaction
- puts "Litle Txn Id: " + transaction["litleTxnId"]
- puts "Order Id: " + transaction["orderId"]
- puts "Response: " + transaction["response"]
- #grab a child element of a child element of the transation
- puts "AVS Result: " + transaction["fraudResult"]["avsResult"]
- puts "Token Response Message: " + transaction["tokenResponse"]["tokenMessage"]
- end
- if(type == "RFRResponse") then
- puts "RFR Response Code: " + transaction["response"]
- puts "RFR Response Message: " + transaction["message"]
- end
- end})
- stop = Time::now
- puts "Total time: " + (stop - start).to_s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement