CnpOnline 8.31.1 → 9.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +29 -12
  3. data/DESCRIPTION +2 -2
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/Rakefile +4 -4
  7. data/Rakefile~ +5 -5
  8. data/SETUP.md +3 -3
  9. data/bin/Setup.rb +9 -8
  10. data/bin/sample_batch_driver.rb +1 -1
  11. data/bin/sample_driver.rb +1 -1
  12. data/lib/Communications.rb +1 -1
  13. data/lib/Configuration.rb +16 -16
  14. data/lib/EnvironmentVariables.rb +1 -2
  15. data/lib/LitleBatchRequest.rb +283 -147
  16. data/lib/LitleListeners.rb +132 -33
  17. data/lib/LitleOnline.rb +5 -4
  18. data/lib/LitleOnlineRequest.rb +69 -59
  19. data/lib/LitleRequest.rb +178 -141
  20. data/lib/LitleTransaction.rb +279 -122
  21. data/lib/LitleXmlMapper.rb +9 -4
  22. data/lib/XMLFields.rb +345 -26
  23. data/test/certification/certTest1_base.rb +74 -73
  24. data/test/certification/certTest2_authenhanced.rb +1 -1
  25. data/test/certification/certTest3_authreversal.rb +1 -1
  26. data/test/certification/certTest4_echeck.rb +4 -1
  27. data/test/certification/certTest5_token.rb +4 -4
  28. data/test/certification/certTest_batchAll.rb +296 -55
  29. data/test/certification/ts_all.rb +1 -1
  30. data/test/functional/test_activate.rb +7 -3
  31. data/test/functional/test_activateReversal.rb +7 -3
  32. data/test/functional/test_auth.rb +119 -16
  33. data/test/functional/test_authReversal.rb +5 -3
  34. data/test/functional/test_balanceInquiry.rb +5 -3
  35. data/test/functional/test_batch.rb +3 -3
  36. data/test/functional/test_batchStream.rb +14 -4
  37. data/test/functional/test_cancelSubscription.rb +5 -3
  38. data/test/functional/test_capture.rb +34 -3
  39. data/test/functional/test_captureGivenAuth.rb +55 -4
  40. data/test/functional/test_configuration.rb +2 -2
  41. data/test/functional/test_createPlan.rb +5 -3
  42. data/test/functional/test_credit.rb +45 -16
  43. data/test/functional/test_deactivate.rb +5 -3
  44. data/test/functional/test_deactivateReversal.rb +5 -3
  45. data/test/functional/test_depositReversal.rb +5 -3
  46. data/test/functional/test_echeckCredit.rb +26 -9
  47. data/test/functional/test_echeckRedeposit.rb +5 -3
  48. data/test/functional/test_echeckSale.rb +49 -28
  49. data/test/functional/test_echeckVerification.rb +20 -12
  50. data/test/functional/test_echeckVoid.rb +1 -1
  51. data/test/functional/test_forceCapture.rb +44 -22
  52. data/test/functional/test_fraudCheck.rb +77 -0
  53. data/test/functional/test_litle_requests.rb +24 -24
  54. data/test/functional/test_load.rb +5 -3
  55. data/test/functional/test_loadReversal.rb +5 -3
  56. data/test/functional/test_refundReversal.rb +5 -3
  57. data/test/functional/test_sale.rb +214 -29
  58. data/test/functional/test_token.rb +19 -3
  59. data/test/functional/test_unload.rb +5 -3
  60. data/test/functional/test_unloadReversal.rb +6 -4
  61. data/test/functional/test_updateCardValidationNumOnToken.rb +1 -1
  62. data/test/functional/test_updatePlan.rb +5 -3
  63. data/test/functional/test_updateSubscription.rb +5 -3
  64. data/test/functional/test_utf8.rb +44 -0
  65. data/test/functional/test_xmlfields.rb +10 -6
  66. data/test/functional/ts_all.rb +2 -1
  67. data/test/unit/test_LitleAUBatch.rb +29 -1
  68. data/test/unit/test_LitleBatchRequest.rb +247 -113
  69. data/test/unit/test_LitleOnlineRequest.rb +37 -54
  70. data/test/unit/test_LitleRequest.rb +3 -3
  71. data/test/unit/test_LitleTransaction.rb +5 -5
  72. data/test/unit/test_LitleXmlMapper.rb +136 -0
  73. data/test/unit/test_activate.rb +1 -21
  74. data/test/unit/test_activateReversal.rb +1 -1
  75. data/test/unit/test_auth.rb +54 -14
  76. data/test/unit/test_authReversal.rb +1 -1
  77. data/test/unit/test_balanceInquiry.rb +1 -1
  78. data/test/unit/test_cancelSubscription.rb +1 -1
  79. data/test/unit/test_capture.rb +27 -1
  80. data/test/unit/test_captureGivenAuth.rb +44 -18
  81. data/test/unit/test_createPlan.rb +1 -1
  82. data/test/unit/test_credit.rb +16 -3
  83. data/test/unit/test_deactivate.rb +1 -1
  84. data/test/unit/test_deactivateReversal.rb +1 -1
  85. data/test/unit/test_depositReversal.rb +1 -1
  86. data/test/unit/test_echeckCredit.rb +15 -2
  87. data/test/unit/test_echeckRedeposit.rb +1 -1
  88. data/test/unit/test_echeckSale.rb +18 -1
  89. data/test/unit/test_echeckVerification.rb +1 -1
  90. data/test/unit/test_echeckVoid.rb +1 -1
  91. data/test/unit/test_forceCapture.rb +20 -2
  92. data/test/unit/test_fraudCheck.rb +45 -0
  93. data/test/unit/test_load.rb +1 -1
  94. data/test/unit/test_loadReversal.rb +1 -1
  95. data/test/unit/test_refundReversal.rb +1 -1
  96. data/test/unit/test_sale.rb +73 -7
  97. data/test/unit/test_token.rb +15 -4
  98. data/test/unit/test_unload.rb +1 -1
  99. data/test/unit/test_unloadReversal.rb +1 -1
  100. data/test/unit/test_updateCardValidationNumOnToken.rb +1 -1
  101. data/test/unit/test_updatePlan.rb +1 -1
  102. data/test/unit/test_updateSubscription.rb +1 -1
  103. data/test/unit/test_xmlfields.rb +1 -1
  104. data/test/unit/ts_unit.rb +2 -1
  105. metadata +10 -7
  106. data/CHANGELOG~ +0 -142
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -67,11 +67,12 @@ module LitleOnline
67
67
  'transactionId'=>'1234'
68
68
  },
69
69
  'signature' =>'1',
70
- 'version'=>'12345'
70
+ 'version'=>'1.0.0'
71
71
  }
72
72
  }
73
73
  response= LitleOnlineRequest.new.register_token_request(hash)
74
74
  assert_equal('Valid Format', response.message)
75
+ assert_equal('0', response.registerTokenResponse.applepayResponse.transactionAmount)
75
76
  end
76
77
 
77
78
  def test_simple_token_echeck
@@ -110,6 +111,21 @@ module LitleOnline
110
111
  response= LitleOnlineRequest.new.register_token_request(hash)
111
112
  assert_equal('Valid Format', response.message)
112
113
  end
114
+
115
+ def test_simple_token_with_androidpay
116
+ hash = {
117
+ 'merchantId' => '101',
118
+ 'version'=>'8.8',
119
+ 'reportGroup'=>'Planets',
120
+ 'orderId'=>'androidpay',
121
+ 'accountNumber'=>'1233456789103801'
122
+ }
123
+ response= LitleOnlineRequest.new.register_token_request(hash)
124
+ assert_equal('Account number was successfully registered', response.registerTokenResponse.message)
125
+ assert_equal('01', response.registerTokenResponse.androidpayResponse.expMonth)
126
+ assert_equal('2050', response.registerTokenResponse.androidpayResponse.expYear)
127
+ assert_equal('aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ0K', response.registerTokenResponse.androidpayResponse.cryptogram)
128
+ end
129
+
113
130
  end
114
-
115
131
  end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -75,8 +75,10 @@ def test_simple_happy
75
75
  'amount' =>'500',
76
76
  }
77
77
 
78
- response= LitleOnlineRequest.new.unload_request(hash)
79
- assert(response.message =~ /Error validating xml data against the schema/)
78
+ #Get exceptions
79
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.unload_request(hash)}
80
+ #Test
81
+ assert(exception.message =~ /Error validating xml data against the schema/)
80
82
  end
81
83
  end
82
84
  end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -48,9 +48,11 @@ def test_simple
48
48
  'version'=>'8.8',
49
49
  'reportGroup'=>'Planets',
50
50
  }
51
-
52
- response= LitleOnlineRequest.new.unload_reversal(hash)
53
- assert(response.message =~ /Error validating xml data against the schema/)
51
+
52
+ #Get exceptions
53
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.unload_reversal(hash)}
54
+ #Test
55
+ assert(exception.message =~ /Error validating xml data against the schema/)
54
56
  end
55
57
  end
56
58
  end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -51,8 +51,10 @@ def test_simple_happy
51
51
  'planCode'=>'planCodeString',
52
52
  }
53
53
 
54
- response= LitleOnlineRequest.new.update_plan(hash)
55
- assert(response.message =~ /Error validating xml data against the schema/)
54
+ #Get exceptions
55
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.update_plan(hash)}
56
+ #Test
57
+ assert(exception.message =~ /Error validating xml data against the schema/)
56
58
  end
57
59
  end
58
60
  end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -69,8 +69,10 @@ def test_simple_happy
69
69
  'reportGroup'=>'Planets',
70
70
  }
71
71
 
72
- response= LitleOnlineRequest.new.update_subscription(hash)
73
- assert(response.message =~ /Error validating xml data against the schema/)
72
+ #Get exceptions
73
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.update_subscription(hash)}
74
+ #Test
75
+ assert(exception.message =~ /Error validating xml data against the schema/)
74
76
  end
75
77
  end
76
78
  end
@@ -0,0 +1,44 @@
1
+ =begin
2
+ Copyright (c) 2017 Vantiv eCommerce
3
+
4
+ Permission is hereby granted, free of charge, to any person
5
+ obtaining a copy of this software and associated documentation
6
+ files (the "Software"), to deal in the Software without
7
+ restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
+ OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+ require File.expand_path("../../../lib/LitleOnline",__FILE__)
26
+ require 'test/unit'
27
+
28
+ #test ActivateReversal Transaction
29
+ module LitleOnline
30
+ class TestActivateReversal < Test::Unit::TestCase
31
+
32
+ def test_simple
33
+ hash = {
34
+ 'merchantId' => '101',
35
+ 'version'=>'8.8',
36
+ 'reportGroup'=>'русский中文',
37
+ 'litleTxnId' =>'5000'
38
+ }
39
+
40
+ response= LitleOnlineRequest.new.activate_reversal(hash)
41
+ assert_equal('Valid Format', response.message)
42
+ end
43
+ end
44
+ end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -41,8 +41,10 @@ module LitleOnline
41
41
  'expDate' =>'1210',
42
42
  'cardValidationNum'=> '123'
43
43
  }}
44
- response= LitleOnlineRequest.new.sale(hash)
45
- assert(response.message =~ /Error validating xml data against the schema/)
44
+ #Get exceptions
45
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.sale(hash)}
46
+ #Test
47
+ assert(exception.message =~ /Error validating xml data against the schema/)
46
48
  end
47
49
 
48
50
  def test_simple_custom_billing
@@ -111,7 +113,7 @@ module LitleOnline
111
113
  'orderId'=>'12344',
112
114
  'amount'=>'106',
113
115
  'orderSource'=>'ecommerce',
114
- 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'},
116
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'vantiv.com'},
115
117
  'card'=>{
116
118
  'type'=>'VI',
117
119
  'number' =>'4100000000000000',
@@ -189,8 +191,10 @@ module LitleOnline
189
191
  'expDate' =>'1210'},
190
192
  'amexAggregatorData'=>{'sellerMerchantCategoryCode'=>'1234'}
191
193
  }
192
- response= LitleOnlineRequest.new.credit(hash)
193
- assert(response.message =~ /Error validating xml data against the schema/)
194
+ #Get exceptions
195
+ exception = assert_raise(RuntimeError){LitleOnlineRequest.new.credit(hash)}
196
+ #Test
197
+ assert(exception.message =~ /Error validating xml data against the schema/)
194
198
  end
195
199
 
196
200
  def test_simple_enhanced_data
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2012 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -64,3 +64,4 @@ require_relative 'test_unloadReversal'
64
64
  require_relative 'test_deactivateReversal'
65
65
  require_relative 'test_override'
66
66
  require_relative 'test_configuration'
67
+ require_relative 'test_fraudCheck'
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2011 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -212,5 +212,33 @@ module LitleOnline
212
212
 
213
213
  assert_equal 5, counts[:numAccountUpdates]
214
214
  end
215
+
216
+ def test_AU_batch_with_token
217
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
218
+ File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').at_most(7)
219
+ File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').at_most(5)
220
+ File.expects(:rename).once
221
+ File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once
222
+ File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once
223
+ Dir.expects(:mkdir).with('/usr/local/Batches/').once
224
+ File.expects(:directory?).returns(false).once
225
+
226
+ batch = LitleAUBatch.new
227
+ batch.create_new_batch('/usr/local/Batches/')
228
+
229
+ accountUpdateHash = {
230
+ 'reportGroup'=>'Planets',
231
+ 'id'=>'12345',
232
+ 'customerId'=>'0987',
233
+ 'token'=>{'litleToken'=>'1234567890123'
234
+ }}
235
+
236
+ 5.times(){ batch.account_update(accountUpdateHash ) }
237
+
238
+ batch.close_batch()
239
+ counts = batch.get_counts_and_amounts
240
+
241
+ assert_equal 5, counts[:numAccountUpdates]
242
+ end
215
243
  end
216
244
  end
@@ -1,5 +1,5 @@
1
1
  =begin
2
- Copyright (c) 2011 Litle & Co.
2
+ Copyright (c) 2017 Vantiv eCommerce
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person
5
5
  obtaining a copy of this software and associated documentation
@@ -22,25 +22,22 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
22
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
23
  OTHER DEALINGS IN THE SOFTWARE.
24
24
  =end
25
- require File.expand_path("../../../lib/LitleOnline",__FILE__)
26
-
25
+ require File.expand_path("../../../lib/LitleOnline",__FILE__)
27
26
  require 'test/unit'
28
27
  require 'mocha/setup'
29
28
 
30
29
  module LitleOnline
31
-
32
30
  class TestLitleBatchRequest < Test::Unit::TestCase
33
31
  def test_create_new_batch
34
32
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
35
33
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').twice
36
34
  Dir.expects(:mkdir).with('/usr/local/Batches/').once
37
35
  File.expects(:directory?).returns(false).once
38
-
36
+
39
37
  batch = LitleBatchRequest.new
40
38
  batch.create_new_batch('/usr/local/Batches/')
41
39
  end
42
-
43
-
40
+
44
41
  def test_add_authorization
45
42
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
46
43
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
@@ -57,25 +54,25 @@ module LitleOnline
57
54
  'type'=>'VI',
58
55
  'number' =>'4100000000000001',
59
56
  'expDate' =>'1210'
60
- }}
61
-
57
+ }}
58
+
62
59
  batch = LitleBatchRequest.new
63
60
  batch.create_new_batch('/usr/local/Batches/')
64
-
61
+
65
62
  2.times(){ batch.authorization(authHash) }
66
63
  counts = batch.get_counts_and_amounts
67
-
64
+
68
65
  assert_equal 2, counts[:auth][:numAuths]
69
66
  assert_equal 212, counts[:auth][:authAmount]
70
- end
71
-
67
+ end
68
+
72
69
  def test_add_sale
73
70
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
74
71
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
75
72
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
76
73
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
77
74
  File.expects(:directory?).returns(true).once
78
-
75
+
79
76
  saleHash = {
80
77
  'reportGroup'=>'Planets',
81
78
  'id' => '006',
@@ -86,24 +83,24 @@ module LitleOnline
86
83
  'type'=>'VI',
87
84
  'number' =>'4100000000000001',
88
85
  'expDate' =>'1210'
89
- }}
90
-
86
+ }}
87
+
91
88
  batch = LitleBatchRequest.new
92
89
  batch.create_new_batch('D:\Batches\\')
93
90
  batch.sale(saleHash)
94
-
91
+
95
92
  counts = batch.get_counts_and_amounts
96
93
  assert_equal 1, counts[:sale][:numSales]
97
94
  assert_equal 6000, counts[:sale][:saleAmount]
98
95
  end
99
-
96
+
100
97
  def test_add_credit
101
98
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
102
99
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
103
100
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
104
101
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
105
102
  File.expects(:directory?).returns(true).once
106
-
103
+
107
104
  creditHash = {
108
105
  'merchantId' => '101',
109
106
  'version'=>'8.8',
@@ -116,23 +113,23 @@ module LitleOnline
116
113
  'number' =>'4100000000000001',
117
114
  'expDate' =>'1210'
118
115
  }}
119
-
116
+
120
117
  batch = LitleBatchRequest.new
121
118
  batch.create_new_batch('D:\Batches\\')
122
119
  batch.credit(creditHash)
123
-
120
+
124
121
  counts = batch.get_counts_and_amounts
125
122
  assert_equal 1, counts[:credit][:numCredits]
126
123
  assert_equal 106, counts[:credit][:creditAmount]
127
124
  end
128
-
125
+
129
126
  def test_add_auth_reversal
130
127
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
131
128
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
132
129
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
133
130
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
134
131
  File.expects(:directory?).returns(true).once
135
-
132
+
136
133
  authReversalHash = {
137
134
  'merchantId' => '101',
138
135
  'version'=>'8.8',
@@ -140,24 +137,24 @@ module LitleOnline
140
137
  'litleTxnId'=>'12345678000',
141
138
  'amount'=>'106',
142
139
  'payPalNotes'=>'Notes'
143
- }
144
-
140
+ }
141
+
145
142
  batch = LitleBatchRequest.new
146
143
  batch.create_new_batch('D:\Batches\\')
147
144
  batch.auth_reversal(authReversalHash)
148
-
145
+
149
146
  counts = batch.get_counts_and_amounts
150
147
  assert_equal 1, counts[:authReversal][:numAuthReversals]
151
148
  assert_equal 106, counts[:authReversal][:authReversalAmount]
152
149
  end
153
-
150
+
154
151
  def test_add_register_token_request
155
152
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
156
153
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
157
154
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
158
155
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
159
156
  File.expects(:directory?).returns(true).once
160
-
157
+
161
158
  registerTokenHash = {
162
159
  'merchantId' => '101',
163
160
  'version'=>'8.8',
@@ -165,11 +162,11 @@ module LitleOnline
165
162
  'orderId'=>'12344',
166
163
  'accountNumber'=>'1233456789103801'
167
164
  }
168
-
165
+
169
166
  batch = LitleBatchRequest.new
170
167
  batch.create_new_batch('D:\Batches\\')
171
168
  batch.register_token_request(registerTokenHash)
172
-
169
+
173
170
  counts = batch.get_counts_and_amounts
174
171
  assert_equal 1, counts[:numTokenRegistrations]
175
172
  end
@@ -180,18 +177,18 @@ module LitleOnline
180
177
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
181
178
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
182
179
  File.expects(:directory?).returns(true).once
183
-
180
+
184
181
  hash = {
185
182
  'merchantId' => '101',
186
183
  'version'=>'8.8',
187
184
  'reportGroup'=>'Planets',
188
185
  'subscriptionId'=>'100'
189
- }
186
+ }
190
187
 
191
188
  batch = LitleBatchRequest.new
192
189
  batch.create_new_batch('D:\Batches\\')
193
190
  batch.cancel_subscription(hash)
194
-
191
+
195
192
  counts = batch.get_counts_and_amounts
196
193
  assert_equal 1, counts[:numCancelSubscriptions]
197
194
  end
@@ -202,30 +199,31 @@ module LitleOnline
202
199
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
203
200
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
204
201
  File.expects(:directory?).returns(true).once
205
-
202
+
206
203
  hash = {
207
204
  'merchantId' => '101',
208
205
  'version'=>'8.8',
209
206
  'reportGroup'=>'Planets',
210
207
  'subscriptionId'=>'100',
211
- 'planCode'=>'planCodeString',
212
- 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
213
- }
208
+ 'planCode'=>'planCodeString',
209
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'vantiv.com'}
210
+ }
214
211
 
215
212
  batch = LitleBatchRequest.new
216
213
  batch.create_new_batch('D:\Batches\\')
217
214
  batch.update_subscription(hash)
218
-
215
+
219
216
  counts = batch.get_counts_and_amounts
220
217
  assert_equal 1, counts[:numUpdateSubscriptions]
221
218
  end
219
+
222
220
  def test_add_update_card_validation_num_on_token
223
221
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
224
222
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
225
223
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
226
224
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
227
225
  File.expects(:directory?).returns(true).once
228
-
226
+
229
227
  updateCardHash = {
230
228
  'merchantId' => '101',
231
229
  'version'=>'8.8',
@@ -234,22 +232,22 @@ module LitleOnline
234
232
  'litleToken'=>'1233456789103801',
235
233
  'cardValidationNum'=>'123'
236
234
  }
237
-
235
+
238
236
  batch = LitleBatchRequest.new
239
237
  batch.create_new_batch('D:\Batches\\')
240
238
  batch.update_card_validation_num_on_token(updateCardHash)
241
-
239
+
242
240
  counts = batch.get_counts_and_amounts
243
241
  assert_equal 1, counts[:numUpdateCardValidationNumOnTokens]
244
242
  end
245
-
243
+
246
244
  def test_add_force_capture
247
245
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
248
246
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
249
247
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
250
248
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
251
249
  File.expects(:directory?).returns(true).once
252
-
250
+
253
251
  forceCaptHash = {
254
252
  'merchantId' => '101',
255
253
  'version'=>'8.8',
@@ -263,23 +261,23 @@ module LitleOnline
263
261
  'number' =>'4100000000000001',
264
262
  'expDate' =>'1210'
265
263
  }}
266
-
264
+
267
265
  batch = LitleBatchRequest.new
268
266
  batch.create_new_batch('D:\Batches\\')
269
267
  batch.force_capture(forceCaptHash)
270
-
268
+
271
269
  counts = batch.get_counts_and_amounts
272
270
  assert_equal 1, counts[:forceCapture][:numForceCaptures]
273
271
  assert_equal 106, counts[:forceCapture][:forceCaptureAmount]
274
272
  end
275
-
273
+
276
274
  def test_add_capture
277
275
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
278
276
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
279
277
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
280
278
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
281
279
  File.expects(:directory?).returns(true).once
282
-
280
+
283
281
  captHash = {
284
282
  'merchantId' => '101',
285
283
  'version'=>'8.8',
@@ -287,23 +285,23 @@ module LitleOnline
287
285
  'litleTxnId'=>'123456000',
288
286
  'amount'=>'106',
289
287
  }
290
-
288
+
291
289
  batch = LitleBatchRequest.new
292
290
  batch.create_new_batch('D:\Batches\\')
293
291
  batch.capture(captHash)
294
-
292
+
295
293
  counts = batch.get_counts_and_amounts
296
294
  assert_equal 1, counts[:capture][:numCaptures]
297
295
  assert_equal 106, counts[:capture][:captureAmount]
298
296
  end
299
-
297
+
300
298
  def test_add_capture_given_auth
301
299
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
302
300
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
303
301
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
304
302
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
305
303
  File.expects(:directory?).returns(true).once
306
-
304
+
307
305
  captGivenAuthHash = {
308
306
  'merchantId' => '101',
309
307
  'version'=>'8.8',
@@ -320,23 +318,23 @@ module LitleOnline
320
318
  'number' =>'4100000000000000',
321
319
  'expDate' =>'1210'
322
320
  }}
323
-
321
+
324
322
  batch = LitleBatchRequest.new
325
323
  batch.create_new_batch('D:\Batches\\')
326
324
  batch.capture_given_auth(captGivenAuthHash)
327
-
325
+
328
326
  counts = batch.get_counts_and_amounts
329
327
  assert_equal 1, counts[:captureGivenAuth][:numCaptureGivenAuths]
330
328
  assert_equal 106, counts[:captureGivenAuth][:captureGivenAuthAmount]
331
329
  end
332
-
330
+
333
331
  def test_add_echeck_verification
334
332
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
335
333
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
336
334
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
337
335
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
338
336
  File.expects(:directory?).returns(true).once
339
-
337
+
340
338
  echeckVerificationHash = {
341
339
  'merchantId' => '101',
342
340
  'version'=>'8.8',
@@ -345,25 +343,25 @@ module LitleOnline
345
343
  'orderId'=>'12345',
346
344
  'orderSource'=>'ecommerce',
347
345
  'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
348
- 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
346
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'vantiv.com'}
349
347
  }
350
-
348
+
351
349
  batch = LitleBatchRequest.new
352
350
  batch.create_new_batch('D:\Batches\\')
353
351
  batch.echeck_verification(echeckVerificationHash)
354
-
352
+
355
353
  counts = batch.get_counts_and_amounts
356
354
  assert_equal 1, counts[:echeckVerification][:numEcheckVerification]
357
355
  assert_equal 123456, counts[:echeckVerification][:echeckVerificationAmount]
358
356
  end
359
-
357
+
360
358
  def test_add_echeck_credit
361
359
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
362
360
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
363
361
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
364
362
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
365
363
  File.expects(:directory?).returns(true).once
366
-
364
+
367
365
  echeckCreditHash = {
368
366
  'merchantId' => '101',
369
367
  'version'=>'8.8',
@@ -371,45 +369,45 @@ module LitleOnline
371
369
  'litleTxnId'=>'123456789101112',
372
370
  'amount'=>'12'
373
371
  }
374
-
372
+
375
373
  batch = LitleBatchRequest.new
376
374
  batch.create_new_batch('D:\Batches\\')
377
375
  batch.echeck_credit(echeckCreditHash)
378
-
376
+
379
377
  counts = batch.get_counts_and_amounts
380
378
  assert_equal 1, counts[:echeckCredit][:numEcheckCredit]
381
379
  assert_equal 12, counts[:echeckCredit][:echeckCreditAmount]
382
380
  end
383
-
381
+
384
382
  def test_add_echeck_redeposit
385
383
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
386
384
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
387
385
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
388
386
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
389
387
  File.expects(:directory?).returns(true).once
390
-
388
+
391
389
  echeckRedeopsitHash = {
392
390
  'merchantId' => '101',
393
391
  'version'=>'8.8',
394
392
  'reportGroup'=>'Planets',
395
393
  'litleTxnId'=>'123456'
396
394
  }
397
-
395
+
398
396
  batch = LitleBatchRequest.new
399
397
  batch.create_new_batch('D:\Batches\\')
400
398
  batch.echeck_redeposit(echeckRedeopsitHash)
401
-
399
+
402
400
  counts = batch.get_counts_and_amounts
403
401
  assert_equal 1, counts[:numEcheckRedeposit]
404
402
  end
405
-
403
+
406
404
  def test_add_echeck_sale
407
405
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
408
406
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
409
407
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').twice
410
408
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').once
411
409
  File.expects(:directory?).returns(true).once
412
-
410
+
413
411
  echeckSaleHash = {
414
412
  'merchantId' => '101',
415
413
  'version'=>'8.8',
@@ -419,18 +417,18 @@ module LitleOnline
419
417
  'orderId'=>'12345',
420
418
  'orderSource'=>'ecommerce',
421
419
  'echeck' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'},
422
- 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'litle.com'}
420
+ 'billToAddress'=>{'name'=>'Bob','city'=>'lowell','state'=>'MA','email'=>'vantiv.com'}
423
421
  }
424
-
422
+
425
423
  batch = LitleBatchRequest.new
426
424
  batch.create_new_batch('D:\Batches\\')
427
425
  batch.echeck_sale(echeckSaleHash)
428
-
426
+
429
427
  counts = batch.get_counts_and_amounts
430
428
  assert_equal 1, counts[:echeckSale][:numEcheckSales]
431
429
  assert_equal 123456, counts[:echeckSale][:echeckSalesAmount]
432
430
  end
433
-
431
+
434
432
  def test_close_batch
435
433
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
436
434
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
@@ -440,7 +438,7 @@ module LitleOnline
440
438
  File.expects(:rename).once
441
439
  File.expects(:delete).once
442
440
  File.expects(:directory?).returns(true).once
443
-
441
+
444
442
  saleHash = {
445
443
  'reportGroup'=>'Planets',
446
444
  'id' => '006',
@@ -451,17 +449,17 @@ module LitleOnline
451
449
  'type'=>'VI',
452
450
  'number' =>'4100000000000001',
453
451
  'expDate' =>'1210'
454
- }}
452
+ }}
455
453
 
456
454
  batch = LitleBatchRequest.new
457
- batch.create_new_batch('D:\Batches\\')
455
+ batch.create_new_batch('D:\Batches\\')
458
456
 
459
457
  batch.sale(saleHash)
460
458
  batch.close_batch()
461
- end
462
-
459
+ end
460
+
463
461
  def test_open_existing_batch
464
-
462
+
465
463
  saleHash = {
466
464
  'reportGroup'=>'Planets',
467
465
  'id' => '006',
@@ -472,20 +470,18 @@ module LitleOnline
472
470
  'type'=>'VI',
473
471
  'number' =>'4100000000000001',
474
472
  'expDate' =>'1210'
475
- }}
476
-
473
+ }}
474
+
477
475
  open = sequence('open')
478
476
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).times(2).in_sequence(open)
479
-
477
+
480
478
  File.expects(:file?).returns(false).once.in_sequence(open)
481
479
  File.expects(:directory?).returns(true).in_sequence(open)
482
480
  File.expects(:file?).returns(false).in_sequence(open)
483
481
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(open)
484
482
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(open)
485
483
  File.expects(:file?).returns(true).in_sequence(open)
486
-
487
-
488
-
484
+
489
485
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'rb').returns({:numAccountUpdates => 0}).once.in_sequence(open)
490
486
  File.expects(:rename).once.in_sequence(open)
491
487
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once.in_sequence(open)
@@ -497,7 +493,7 @@ module LitleOnline
497
493
  batch2.open_existing_batch(batch1.get_batch_name)
498
494
  batch2.close_batch()
499
495
  end
500
-
496
+
501
497
  def test_build_batch_header
502
498
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
503
499
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
@@ -506,29 +502,29 @@ module LitleOnline
506
502
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'w').once
507
503
  File.expects(:delete).once
508
504
  File.expects(:directory?).returns(true).once
509
-
505
+
510
506
  batch = LitleBatchRequest.new
511
507
  batch.get_counts_and_amounts.expects(:[]).returns(hash = Hash.new).at_least(25)
512
508
  hash.expects(:[]).returns('a').at_least(20)
513
-
509
+
514
510
  batch.create_new_batch('/usr/local/Batches')
515
511
  batch.close_batch()
516
512
  end
517
-
513
+
518
514
  def test_create_new_batch_missing_separator
519
515
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
520
516
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').once
521
517
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').once
522
-
518
+
523
519
  batch = LitleBatchRequest.new
524
520
  batch.create_new_batch('/usr/local')
525
-
521
+
526
522
  assert batch.get_batch_name.include?('/usr/local/')
527
523
  end
528
-
524
+
529
525
  def test_create_new_batch_name_collision
530
526
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
531
-
527
+
532
528
  fileExists = sequence('fileExists')
533
529
  File.expects(:file?).with(regexp_matches(/.*\/usr\/local\//)).returns(false).in_sequence(fileExists)
534
530
  File.expects(:file?).with(regexp_matches(/.*batch_.*\d.*/)).returns(true).in_sequence(fileExists)
@@ -536,33 +532,32 @@ module LitleOnline
536
532
  File.expects(:file?).with(regexp_matches(/.*batch_.*\d.*/)).returns(false).in_sequence(fileExists)
537
533
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(fileExists)
538
534
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(fileExists)
539
-
540
-
535
+
541
536
  batch = LitleBatchRequest.new
542
537
  batch.create_new_batch('/usr/local/')
543
538
  end
544
-
539
+
545
540
  def test_create_new_batch_when_full
546
541
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
547
-
542
+
548
543
  batch = LitleBatchRequest.new
549
544
  addTxn = sequence('addTxn')
550
-
545
+
551
546
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').in_sequence(addTxn)
552
547
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(addTxn)
553
548
  batch.create_new_batch('/usr/local')
554
-
549
+
555
550
  batch.get_counts_and_amounts.expects(:[]).with(:sale).returns({:numSales => 10, :saleAmount => 20}).twice.in_sequence(addTxn)
556
551
  batch.get_counts_and_amounts.expects(:[]).with(:total).returns(499999).in_sequence(addTxn)
557
-
552
+
558
553
  File.expects(:open).with(regexp_matches(/.*batch_.*\d_txns.*/), 'a+').in_sequence(addTxn)
559
554
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').in_sequence(addTxn)
560
555
  batch.get_counts_and_amounts.expects(:[]).with(:total).returns(100000).in_sequence(addTxn)
561
-
556
+
562
557
  batch.expects(:close_batch).once.in_sequence(addTxn)
563
558
  batch.expects(:initialize).once.in_sequence(addTxn)
564
559
  batch.expects(:create_new_batch).once.in_sequence(addTxn)
565
-
560
+
566
561
  saleHash = {
567
562
  'reportGroup'=>'Planets',
568
563
  'id' => '006',
@@ -573,12 +568,12 @@ module LitleOnline
573
568
  'type'=>'VI',
574
569
  'number' =>'4100000000000001',
575
570
  'expDate' =>'1210'
576
- }}
577
-
571
+ }}
572
+
578
573
  batch.sale(saleHash)
579
-
574
+
580
575
  end
581
-
576
+
582
577
  def test_complete_batch
583
578
  Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'8.10'}).once
584
579
  File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').at_most(9)
@@ -588,7 +583,7 @@ module LitleOnline
588
583
  File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once
589
584
  Dir.expects(:mkdir).with('/usr/local/Batches/').once
590
585
  File.expects(:directory?).returns(false).once
591
-
586
+
592
587
  authHash = {
593
588
  'reportGroup'=>'Planets',
594
589
  'orderId'=>'12344',
@@ -598,8 +593,8 @@ module LitleOnline
598
593
  'type'=>'VI',
599
594
  'number' =>'4100000000000001',
600
595
  'expDate' =>'1210'
601
- }}
602
-
596
+ }}
597
+
603
598
  saleHash = {
604
599
  'reportGroup'=>'Planets',
605
600
  'id' => '006',
@@ -610,8 +605,8 @@ module LitleOnline
610
605
  'type'=>'VI',
611
606
  'number' =>'4100000000000001',
612
607
  'expDate' =>'1210'
613
- }}
614
-
608
+ }}
609
+
615
610
  updateCardHash = {
616
611
  'merchantId' => '101',
617
612
  'version'=>'8.8',
@@ -622,10 +617,10 @@ module LitleOnline
622
617
  'litleToken'=>'1233456789103801',
623
618
  'cardValidationNum'=>'123'
624
619
  }
625
-
620
+
626
621
  batch = LitleBatchRequest.new
627
622
  batch.create_new_batch('/usr/local/Batches/')
628
-
623
+
629
624
  5.times(){ batch.authorization(authHash) }
630
625
  2.times(){ batch.sale(saleHash) }
631
626
 
@@ -633,11 +628,150 @@ module LitleOnline
633
628
  #puts "PID: " + pid.to_s + " size: " + size.to_s
634
629
  batch.close_batch()
635
630
  counts = batch.get_counts_and_amounts
636
-
631
+
637
632
  assert_equal 5, counts[:auth][:numAuths]
638
633
  #assert_equal 212, counts[:auth][:authAmount]
639
634
  assert_equal 2, counts[:sale][:numSales]
640
635
  #assert_equal 6000, counts[:sale][:saleAmount]
641
636
  end
637
+
638
+ def test_PFIF_instruction_txn
639
+ Configuration.any_instance.stubs(:config).returns({'currency_merchant_map'=>{'DEFAULT'=>'1'}, 'user'=>'a','password'=>'b','version'=>'9.3'}).once
640
+ File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'a+').at_most(12)
641
+ File.expects(:open).with(regexp_matches(/.*batch_.*\d.*/), 'wb').at_most(10)
642
+ File.expects(:rename).once
643
+ File.expects(:open).with(regexp_matches(/.*batch_.*\d.closed.*/), 'w').once
644
+ File.expects(:delete).with(regexp_matches(/.*batch_.*\d_txns.*/)).once
645
+ Dir.expects(:mkdir).with('/usr/local/Batches/').once
646
+ File.expects(:directory?).returns(false).once
647
+
648
+ submerchantCreditHash = {
649
+ 'reportGroup'=>'Planets',
650
+ 'orderId'=>'12344',
651
+ 'fundingSubmerchantId'=>'123456',
652
+ 'submerchantName'=>'001',
653
+ 'fundsTransferId'=>'1234567',
654
+ 'amount'=>'106',
655
+ 'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
656
+ }
657
+
658
+ vendorCreditHash = {
659
+ 'reportGroup'=>'Planets',
660
+ 'orderId'=>'12344',
661
+ 'fundingSubmerchantId'=>'123456',
662
+ 'vendorName'=>'001',
663
+ 'fundsTransferId'=>'1234567',
664
+ 'amount'=>'107',
665
+ 'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
666
+ }
667
+
668
+ payFacCreditHash = {
669
+ 'reportGroup'=>'Planets',
670
+ 'orderId'=>'12344',
671
+ 'fundingSubmerchantId'=>'123456',
672
+ 'fundsTransferId'=>'1234567',
673
+ 'amount'=>'108',
674
+ }
675
+
676
+ reserveCreditHash = {
677
+ 'reportGroup'=>'Planets',
678
+ 'orderId'=>'12344',
679
+ 'fundingSubmerchantId'=>'123456',
680
+ 'fundsTransferId'=>'1234567',
681
+ 'amount'=>'109',
682
+ }
683
+
684
+ physicalCheckCreditHash = {
685
+ 'reportGroup'=>'Planets',
686
+ 'orderId'=>'12344',
687
+ 'fundingSubmerchantId'=>'123456',
688
+ 'fundsTransferId'=>'1234567',
689
+ 'amount'=>'110',
690
+ }
691
+
692
+ submerchantDebitHash = {
693
+ 'reportGroup'=>'Planets',
694
+ 'orderId'=>'12344',
695
+ 'fundingSubmerchantId'=>'123456',
696
+ 'submerchantName'=>'001',
697
+ 'fundsTransferId'=>'1234567',
698
+ 'amount'=>'106',
699
+ 'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
700
+ }
701
+
702
+ vendorDebitHash = {
703
+ 'reportGroup'=>'Planets',
704
+ 'orderId'=>'12344',
705
+ 'fundingSubmerchantId'=>'123456',
706
+ 'vendorName'=>'001',
707
+ 'fundsTransferId'=>'1234567',
708
+ 'amount'=>'107',
709
+ 'accountInfo' => {'accType'=>'Checking','accNum'=>'12345657890','routingNum'=>'123456789','checkNum'=>'123455'}
710
+ }
711
+
712
+ payFacDebitHash = {
713
+ 'reportGroup'=>'Planets',
714
+ 'orderId'=>'12344',
715
+ 'fundingSubmerchantId'=>'123456',
716
+ 'fundsTransferId'=>'1234567',
717
+ 'amount'=>'108',
718
+ }
719
+
720
+ reserveDebitHash = {
721
+ 'reportGroup'=>'Planets',
722
+ 'orderId'=>'12344',
723
+ 'fundingSubmerchantId'=>'123456',
724
+ 'fundsTransferId'=>'1234567',
725
+ 'amount'=>'109',
726
+ }
727
+
728
+ physicalCheckDebitHash = {
729
+ 'reportGroup'=>'Planets',
730
+ 'orderId'=>'12344',
731
+ 'fundingSubmerchantId'=>'123456',
732
+ 'fundsTransferId'=>'1234567',
733
+ 'amount'=>'110',
734
+ }
735
+ batch = LitleBatchRequest.new
736
+ batch.create_new_batch('/usr/local/Batches/')
737
+
738
+ batch.submerchant_credit(submerchantCreditHash)
739
+ batch.payFac_credit(payFacCreditHash)
740
+ batch.vendor_credit(vendorCreditHash)
741
+ batch.reserve_credit(reserveCreditHash)
742
+ batch.physical_check_credit(physicalCheckCreditHash)
743
+ batch.submerchant_debit(submerchantDebitHash)
744
+ batch.payFac_debit(payFacDebitHash)
745
+ batch.vendor_debit(vendorDebitHash)
746
+ batch.reserve_debit(reserveDebitHash)
747
+ batch.physical_check_debit(physicalCheckDebitHash)
748
+
749
+ #pid, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`.strip.split.map(&:to_i)
750
+ #puts "PID: " + pid.to_s + " size: " + size.to_s
751
+ batch.close_batch()
752
+ counts = batch.get_counts_and_amounts
753
+
754
+ assert_equal 1, counts[:submerchantCredit ][:numSubmerchantCredit ]
755
+ assert_equal 1, counts[:payFacCredit ][:numPayFacCredit ]
756
+ assert_equal 1, counts[:reserveCredit ][:numReserveCredit ]
757
+ assert_equal 1, counts[:vendorCredit ][:numVendorCredit ]
758
+ assert_equal 1, counts[:physicalCheckCredit ][:numPhysicalCheckCredit ]
759
+ assert_equal 106, counts[:submerchantCredit ][:submerchantCreditAmount ]
760
+ assert_equal 108, counts[:payFacCredit ][:payFacCreditAmount ]
761
+ assert_equal 109, counts[:reserveCredit ][:reserveCreditAmount ]
762
+ assert_equal 107, counts[:vendorCredit ][:vendorCreditAmount ]
763
+ assert_equal 110, counts[:physicalCheckCredit ][:physicalCheckCreditAmount ]
764
+
765
+ assert_equal 1, counts[:submerchantDebit ][:numSubmerchantDebit ]
766
+ assert_equal 1, counts[:payFacDebit ][:numPayFacDebit ]
767
+ assert_equal 1, counts[:reserveDebit ][:numReserveDebit ]
768
+ assert_equal 1, counts[:vendorDebit ][:numVendorDebit ]
769
+ assert_equal 1, counts[:physicalCheckDebit ][:numPhysicalCheckDebit ]
770
+ assert_equal 106, counts[:submerchantDebit ][:submerchantDebitAmount ]
771
+ assert_equal 108, counts[:payFacDebit ][:payFacDebitAmount ]
772
+ assert_equal 109, counts[:reserveDebit ][:reserveDebitAmount ]
773
+ assert_equal 107, counts[:vendorDebit ][:vendorDebitAmount ]
774
+ assert_equal 110, counts[:physicalCheckDebit ][:physicalCheckDebitAmount ]
775
+ end
642
776
  end
643
777
  end