Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. saleHash = {
  2. 'reportGroup'=>'Planets',
  3. 'id' => '006',
  4. 'orderId'=>'12344',
  5. 'amount'=>'6000',
  6. 'orderSource'=>'ecommerce',
  7. 'card'=>{
  8. 'type'=>'VI',
  9. 'number' =>'4100000000000001',
  10. 'expDate' =>'1210'
  11. }}
  12.  
  13. accountUpdateHash = {
  14. 'reportGroup'=>'Planets',
  15. 'id'=>'12345',
  16. 'customerId'=>'0987',
  17. 'orderId'=>'1234',
  18. 'card'=>{
  19. 'type'=>'VI',
  20. 'number' =>'4100000000000001',
  21. 'expDate' =>'1210'
  22. }}
  23.  
  24. rfrHash = {
  25. 'merchantId'=>101,
  26. 'postDay'=>'2013-06-04'
  27. }
  28.  
  29. path = Dir.pwd
  30.  
  31. request = LitleOnline::LitleRequest.new({'sessionId'=>'8675309'})
  32.  
  33. request.create_new_litle_request(path)
  34. puts "Created new LitleRequest at location: " + path
  35. start = Time::now
  36. batch = LitleOnline::LitleBatchRequest.new
  37. batch.create_new_batch(path)
  38.  
  39. batch.sale(saleHash)
  40. batch.account_update(accountUpdateHash)
  41.  
  42. #close the batch, indicating we plan to add no more transactions
  43. batch.close_batch()
  44. #add the batch to the LitleRequest
  45. request.commit_batch(batch)
  46.  
  47. request.add_rfr_request(rfrHash)
  48.  
  49. #finish the Litle Request, indicating we plan to add no more batches
  50. request.finish_request
  51. puts "Generated final XML markup of the LitleRequest"
  52.  
  53. #send the batch files at the given directory over fastBatch and save the responses
  54. request.send_to_litle_stream
  55. #process the responses from the server with a listener which applies the given block
  56. start = Time::now
  57. request.process_responses({:transaction_listener => LitleOnline::DefaultLitleListener.new do |transaction|
  58. type = transaction["type"]
  59. #if we're dealing with a saleResponse (check the Litle XML Reference Guide!)
  60. if(type == "saleResponse") then
  61. #grab an attribute of the parent of the response
  62. puts "Report Group: " + transaction["reportGroup"]
  63.  
  64. #grab some child elements of the transaction
  65. puts "Litle Txn Id: " + transaction["litleTxnId"]
  66. puts "Order Id: " + transaction["orderId"]
  67. puts "Response: " + transaction["response"]
  68.  
  69. #grab a child element of a child element of the transation
  70. puts "AVS Result: " + transaction["fraudResult"]["avsResult"]
  71. puts "Token Response Message: " + transaction["tokenResponse"]["tokenMessage"]
  72. end
  73.  
  74. if(type == "RFRResponse") then
  75. puts "RFR Response Code: " + transaction["response"]
  76. puts "RFR Response Message: " + transaction["message"]
  77. end
  78. end})
  79. stop = Time::now
  80. puts "Total time: " + (stop - start).to_s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement