hps 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +32 -0
  5. data/PRIVACY.txt +66 -0
  6. data/README.md +41 -0
  7. data/Rakefile +15 -0
  8. data/hps.gemspec +26 -0
  9. data/lib/hps.rb +45 -0
  10. data/lib/hps/configuration.rb +17 -0
  11. data/lib/hps/entities/hps_account_verify.rb +9 -0
  12. data/lib/hps/entities/hps_address.rb +7 -0
  13. data/lib/hps/entities/hps_authorization.rb +13 -0
  14. data/lib/hps/entities/hps_batch.rb +7 -0
  15. data/lib/hps/entities/hps_cardholder.rb +7 -0
  16. data/lib/hps/entities/hps_charge.rb +9 -0
  17. data/lib/hps/entities/hps_charge_exceptions.rb +7 -0
  18. data/lib/hps/entities/hps_credit_card.rb +33 -0
  19. data/lib/hps/entities/hps_refund.rb +9 -0
  20. data/lib/hps/entities/hps_report_transaction_details.rb +11 -0
  21. data/lib/hps/entities/hps_report_transaction_summary.rb +7 -0
  22. data/lib/hps/entities/hps_reversal.rb +11 -0
  23. data/lib/hps/entities/hps_token_data.rb +11 -0
  24. data/lib/hps/entities/hps_transaction.rb +161 -0
  25. data/lib/hps/entities/hps_transaction_details.rb +7 -0
  26. data/lib/hps/entities/hps_transaction_header.rb +9 -0
  27. data/lib/hps/entities/hps_transaction_type.rb +17 -0
  28. data/lib/hps/entities/hps_void.rb +9 -0
  29. data/lib/hps/infrastructure/api_connection_exception.rb +11 -0
  30. data/lib/hps/infrastructure/authentication_exception.rb +11 -0
  31. data/lib/hps/infrastructure/card_exception.rb +15 -0
  32. data/lib/hps/infrastructure/exceptions.json +469 -0
  33. data/lib/hps/infrastructure/hps_exception.rb +25 -0
  34. data/lib/hps/infrastructure/hps_exception_mapper.rb +135 -0
  35. data/lib/hps/infrastructure/hps_sdk_codes.rb +49 -0
  36. data/lib/hps/infrastructure/invalid_request_exception.rb +15 -0
  37. data/lib/hps/services/hps_batch_service.rb +30 -0
  38. data/lib/hps/services/hps_charge_service.rb +635 -0
  39. data/lib/hps/services/hps_service.rb +128 -0
  40. data/lib/hps/version.rb +3 -0
  41. data/tests/amex_tests.rb +231 -0
  42. data/tests/cert_tests.rb +81 -0
  43. data/tests/discover_tests.rb +325 -0
  44. data/tests/exception_mapper_tests.rb +245 -0
  45. data/tests/general_tests.rb +58 -0
  46. data/tests/hps_token_service.rb +56 -0
  47. data/tests/mastercard_tests.rb +326 -0
  48. data/tests/secret_key.rb +12 -0
  49. data/tests/test_data.rb +128 -0
  50. data/tests/test_helper.rb +92 -0
  51. data/tests/token_tests.rb +513 -0
  52. data/tests/visa_tests.rb +378 -0
  53. metadata +165 -0
@@ -0,0 +1,12 @@
1
+ require File.join( File.dirname(__FILE__), "test_helper" )
2
+
3
+ describe "Secret Key Tests" do
4
+
5
+ it "can charge with secret key" do
6
+ Hps::TestHelper.configure_hps_module_secret_key()
7
+ service = Hps::HpsChargeService.new()
8
+ charge = service.charge(1.00, "usd", Hps::TestData.valid_visa, Hps::TestData.valid_cardholder)
9
+ expect(charge.response_code).to eql("00")
10
+ end
11
+
12
+ end
@@ -0,0 +1,128 @@
1
+ require 'hps'
2
+
3
+ module Hps
4
+ module TestData
5
+
6
+ # card holders
7
+
8
+ def self.valid_cardholder
9
+ result = HpsCardHolder.new()
10
+ result.first_name = "Bill"
11
+ result.last_name = "Johnson"
12
+ result.address = HpsAddress.new
13
+ result.address.address = "One Heartland Way"
14
+ result.address.city = "Jeffersonville"
15
+ result.address.state = "IN"
16
+ result.address.zip = "47130"
17
+ result.address.country = "United States"
18
+ result
19
+ end
20
+
21
+ def self.cert_cardholder_shortzip
22
+ result = HpsCardHolder.new()
23
+ result.first_name = "Bill"
24
+ result.last_name = "Johnson"
25
+ result.address = HpsAddress.new
26
+ result.address.address = "6860 Dallas Pkwy"
27
+ result.address.city = "Irvine"
28
+ result.address.state = "TX"
29
+ result.address.zip = "75024"
30
+ result.address.country = "United States"
31
+ result
32
+ end
33
+
34
+ def self.cert_cardholder_shortzip_no_street
35
+ result = HpsCardHolder.new()
36
+ result.first_name = "Bill"
37
+ result.last_name = "Johnson"
38
+ result.address = HpsAddress.new
39
+ result.address.city = "Irvine"
40
+ result.address.state = "TX"
41
+ result.address.zip = "75024"
42
+ result.address.country = "United States"
43
+ result
44
+ end
45
+
46
+ def self.cert_cardholder_longzip
47
+ result = HpsCardHolder.new()
48
+ result.first_name = "Bill"
49
+ result.last_name = "Johnson"
50
+ result.address = HpsAddress.new
51
+ result.address.address = "6860 Dallas Pkwy"
52
+ result.address.city = "Irvine"
53
+ result.address.state = "TX"
54
+ result.address.zip = "750241234"
55
+ result.address.country = "United States"
56
+ result
57
+ end
58
+
59
+ def self.cert_cardholder_longzip_no_street
60
+ result = HpsCardHolder.new()
61
+ result.first_name = "Bill"
62
+ result.last_name = "Johnson"
63
+ result.address = HpsAddress.new
64
+ result.address.city = "Irvine"
65
+ result.address.state = "TX"
66
+ result.address.zip = "750241234"
67
+ result.address.country = "United States"
68
+ result
69
+ end
70
+
71
+ # credit cards
72
+
73
+ def self.valid_visa
74
+ result = HpsCreditCard.new
75
+ result.cvv = 123
76
+ result.exp_month = 12
77
+ result.exp_year = 2015
78
+ result.number = 4012002000060016
79
+ result
80
+ end
81
+
82
+ def self.valid_mastercard
83
+ result = HpsCreditCard.new
84
+ result.cvv = 123
85
+ result.exp_month = 12
86
+ result.exp_year = 2015
87
+ result.number = 5473500000000014
88
+ result
89
+ end
90
+
91
+ def self.valid_discover
92
+ result = HpsCreditCard.new
93
+ result.cvv = 123
94
+ result.exp_month = 12
95
+ result.exp_year = 2015
96
+ result.number = 6011000990156527
97
+ result
98
+ end
99
+
100
+ def self.valid_amex
101
+ result = HpsCreditCard.new
102
+ result.cvv = 1234
103
+ result.exp_month = 12
104
+ result.exp_year = 2015
105
+ result.number = 372700699251018
106
+ result
107
+ end
108
+
109
+ def self.valid_jcb
110
+ result = HpsCreditCard.new
111
+ result.cvv = 123
112
+ result.exp_month = 12
113
+ result.exp_year = 2015
114
+ result.number = 3566007770007321
115
+ result
116
+ end
117
+
118
+ def self.invalid_card
119
+ result = HpsCreditCard.new
120
+ result.cvv = 123
121
+ result.exp_month = 12
122
+ result.exp_year = 2015
123
+ result.number = 12345
124
+ result
125
+ end
126
+
127
+ end
128
+ end
@@ -0,0 +1,92 @@
1
+ require File.join( File.dirname(__FILE__), "test_data.rb" )
2
+ require "hps"
3
+ require "rspec"
4
+
5
+ module Hps
6
+ module TestHelper
7
+
8
+ def self.configure_hps_module
9
+ Hps.configure do |config|
10
+ config.secret_api_key = "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ"
11
+ end
12
+ end
13
+
14
+
15
+ def self.configure_hps_module_secret_key
16
+ Hps.configure do |config|
17
+ config.secret_api_key = "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ"
18
+ end
19
+ end
20
+
21
+ def self.configure_hps_module_for_certification
22
+ Hps.configure do |config|
23
+ config.secret_api_key = "skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ"
24
+ end
25
+ end
26
+
27
+ def self.charge_valid_amex(amount)
28
+ TestHelper.configure_hps_module()
29
+ service = Hps::HpsChargeService.new()
30
+ service.charge(amount, "usd", TestData.valid_amex, TestData.valid_cardholder)
31
+ end
32
+
33
+ def self.charge_valid_discover(amount)
34
+ TestHelper.configure_hps_module()
35
+ service = Hps::HpsChargeService.new()
36
+ service.charge(amount, "usd", TestData.valid_discover, TestData.valid_cardholder)
37
+ end
38
+
39
+ def self.charge_valid_mastercard(amount)
40
+ TestHelper.configure_hps_module()
41
+ service = Hps::HpsChargeService.new()
42
+ service.charge(amount, "usd", TestData.valid_mastercard, TestData.valid_cardholder)
43
+ end
44
+
45
+ def self.charge_valid_visa(amount)
46
+ TestHelper.configure_hps_module()
47
+ service = Hps::HpsChargeService.new()
48
+ service.charge(amount, "usd", TestData.valid_visa, TestData.valid_cardholder)
49
+ end
50
+
51
+ def self.charge_token(token_value,multi_use=false)
52
+ TestHelper.valid_multi_use_config
53
+ service = Hps::HpsChargeService.new()
54
+ service.charge(50, "usd", token_value, TestData.valid_cardholder,multi_use)
55
+ end
56
+
57
+ def self.auth_token(token_value,multi_use=false)
58
+ TestHelper.valid_multi_use_config
59
+ service = Hps::HpsChargeService.new()
60
+ service.authorize(50, "usd", token_value, TestData.valid_cardholder,multi_use)
61
+ end
62
+
63
+ def self.verify_token(token_value,multi_use=false)
64
+ TestHelper.valid_multi_use_config
65
+ service = Hps::HpsChargeService.new()
66
+ service.verify(token_value, TestData.valid_cardholder,multi_use)
67
+ end
68
+
69
+ def self.refund_token(token_value)
70
+ TestHelper.valid_multi_use_config
71
+ service = Hps::HpsChargeService.new()
72
+ service.refund(50,'usd',token_value, TestData.valid_cardholder)
73
+ end
74
+
75
+ def self.reverse_token(token_value)
76
+ TestHelper.valid_multi_use_config
77
+ service = Hps::HpsChargeService.new()
78
+ service.reverse(token_value,50,'usd')
79
+ end
80
+
81
+ def self.valid_multi_use_public_key
82
+ 'pkapi_cert_P6dRqs1LzfWJ6HgGVZ'
83
+ end
84
+
85
+ def self.valid_multi_use_config
86
+ Hps.configure do |config|
87
+ config.secret_api_key ='skapi_cert_MYl2AQAowiQAbLp5JesGKh7QFkcizOP2jcX9BrEMqQ'
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,513 @@
1
+ require File.join( File.dirname(__FILE__), 'test_helper' )
2
+ require File.join( File.dirname(__FILE__), 'hps_token_service')
3
+ require File.join( File.dirname(__FILE__), 'test_data' )
4
+
5
+ describe 'token_tests' do
6
+
7
+ let(:public_key) { Hps::TestHelper.valid_multi_use_public_key}
8
+ let(:token_service) { Hps::HpsTokenService.new(public_key) }
9
+
10
+
11
+ #Basic single token fetching tests
12
+
13
+ it 'Should return a one time use token' do
14
+ token_response = token_service.get_token(Hps::TestData.valid_visa)
15
+ token_response['token_value'].should_not eq(nil)
16
+ token_response['token_value'].should include('supt')
17
+ end
18
+
19
+ it 'Should fail getting a token due to bad key' do
20
+ expect { Hps::HpsTokenService.new('bad_key') }.to raise_error('Public API Key must contain at least two underscores')
21
+ end
22
+
23
+ it 'Should fail getting an empty JSON response due to bad key' do
24
+ token_service = Hps::HpsTokenService.new('Still_bad_key')
25
+ expect { token_service.get_token(Hps::TestData.valid_visa) }.to raise_error('A JSON text must at least contain two octets!')
26
+ end
27
+
28
+ it 'Should fail and return an Error Card not Recognized' do
29
+ card = Hps::TestData.valid_visa
30
+ card.number = '11111111111111111'
31
+ token_response = token_service.get_token(card)
32
+ token_response['error']['message'].should eq('Card number is not a recognized brand.')
33
+ end
34
+
35
+ it 'Should fail and return Card Expiration Month invalid' do
36
+ card = Hps::TestData.valid_visa
37
+ card.exp_month = 13
38
+ token_response = token_service.get_token(card)
39
+ token_response['error']['message'].should eq('Card expiration month is invalid.')
40
+ end
41
+
42
+ it 'Should fail and return Card Expiration Year invalid' do
43
+ card = Hps::TestData.valid_visa
44
+ card.exp_year = 12
45
+ token_response = token_service.get_token(card)
46
+ token_response['error']['message'].should eq('Card expiration year is invalid.')
47
+ end
48
+
49
+ #Charge Testing with a token
50
+
51
+ it 'Should get a token from a Amex card and charge it with out error' do
52
+ token = token_service.get_token(Hps::TestData.valid_amex)
53
+ charge = Hps::TestHelper.charge_token(token['token_value'])
54
+
55
+ charge.transaction_id.should_not eq(nil)
56
+ charge.response_code.should eq('00')
57
+ end
58
+
59
+ it 'Should get a token from a Discover card and charge it with out error' do
60
+ token = token_service.get_token(Hps::TestData.valid_discover)
61
+ charge = Hps::TestHelper.charge_token(token['token_value'])
62
+
63
+ charge.transaction_id.should_not eq(nil)
64
+ charge.response_code.should eq('00')
65
+ end
66
+
67
+ it 'Should get a token from a Master card and charge it with out error' do
68
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
69
+ charge = Hps::TestHelper.charge_token(token['token_value'])
70
+
71
+ charge.transaction_id.should_not eq(nil)
72
+ charge.response_code.should eq('00')
73
+ end
74
+
75
+ it 'Should get a token from a Visa card and charge it with out error' do
76
+ token = token_service.get_token(Hps::TestData.valid_visa)
77
+ charge = Hps::TestHelper.charge_token(token['token_value'])
78
+
79
+ charge.transaction_id.should_not eq(nil)
80
+ charge.response_code.should eq('00')
81
+ end
82
+
83
+ # Charge Testing with a multi use token
84
+
85
+ it 'Should get a multi use token from a Amex card and charge it with out error' do
86
+ token = token_service.get_token(Hps::TestData.valid_amex)
87
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
88
+
89
+ charge.transaction_id.should_not eq(nil)
90
+ charge.response_code.should eq('00')
91
+ charge.token_data.token_value.should_not eq(nil)
92
+
93
+ multi_token = charge.token_data.token_value
94
+ charge_multi_token = Hps::TestHelper.charge_token(multi_token)
95
+ charge_multi_token.transaction_id.should_not eq(nil)
96
+ charge_multi_token.response_code.should eq('00')
97
+ end
98
+
99
+ it 'Should get a multi use token from a Discover card and charge it with out error' do
100
+ token = token_service.get_token(Hps::TestData.valid_discover)
101
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
102
+
103
+ charge.transaction_id.should_not eq(nil)
104
+ charge.response_code.should eq('00')
105
+ charge.token_data.token_value.should_not eq(nil)
106
+
107
+ multi_token = charge.token_data.token_value
108
+ charge_multi_token = Hps::TestHelper.charge_token(multi_token)
109
+ charge_multi_token.transaction_id.should_not eq(nil)
110
+ charge_multi_token.response_code.should eq('00')
111
+ end
112
+
113
+ it 'Should get a multi use token from a Master card and charge it with out error' do
114
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
115
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
116
+
117
+ charge.transaction_id.should_not eq(nil)
118
+ charge.response_code.should eq('00')
119
+ charge.token_data.token_value.should_not eq(nil)
120
+
121
+ multi_token = charge.token_data.token_value
122
+ charge_multi_token = Hps::TestHelper.charge_token(multi_token)
123
+ charge_multi_token.transaction_id.should_not eq(nil)
124
+ charge_multi_token.response_code.should eq('00')
125
+ end
126
+
127
+ it 'Should get a multi use token from a Visa card and charge it with out error' do
128
+ token = token_service.get_token(Hps::TestData.valid_visa)
129
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
130
+
131
+ charge.transaction_id.should_not eq(nil)
132
+ charge.response_code.should eq('00')
133
+ charge.token_data.token_value.should_not eq(nil)
134
+
135
+ multi_token = charge.token_data.token_value
136
+ charge_multi_token = Hps::TestHelper.charge_token(multi_token)
137
+ charge_multi_token.transaction_id.should_not eq(nil)
138
+ charge_multi_token.response_code.should eq('00')
139
+ end
140
+
141
+ ## Auth Testing with a token
142
+
143
+ it 'Should get a token from a Amex card and auth it with out error' do
144
+ token = token_service.get_token(Hps::TestData.valid_amex)
145
+ auth = Hps::TestHelper.auth_token(token['token_value'])
146
+
147
+ auth.transaction_id.should_not eq(nil)
148
+ auth.response_code.should eq('00')
149
+ end
150
+
151
+ it 'Should get a token from a Discover card and auth it with out error' do
152
+ token = token_service.get_token(Hps::TestData.valid_discover)
153
+ auth = Hps::TestHelper.auth_token(token['token_value'])
154
+
155
+ auth.transaction_id.should_not eq(nil)
156
+ auth.response_code.should eq('00')
157
+ end
158
+
159
+ it 'Should get a token from a Master card and auth it with out error' do
160
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
161
+ auth = Hps::TestHelper.auth_token(token['token_value'])
162
+
163
+ auth.transaction_id.should_not eq(nil)
164
+ auth.response_code.should eq('00')
165
+ end
166
+
167
+ it 'Should get a token from a Visa card and auth it with out error' do
168
+ token = token_service.get_token(Hps::TestData.valid_visa)
169
+ auth = Hps::TestHelper.auth_token(token['token_value'])
170
+
171
+ auth.transaction_id.should_not eq(nil)
172
+ auth.response_code.should eq('00')
173
+ end
174
+
175
+ # Authorize Testing with a multi use token
176
+
177
+ it 'Should get a multi use token from a Amex card and auth it with out error' do
178
+ token = token_service.get_token(Hps::TestData.valid_amex)
179
+ auth = Hps::TestHelper.auth_token(token['token_value'],true)
180
+
181
+ auth.transaction_id.should_not eq(nil)
182
+ auth.response_code.should eq('00')
183
+ auth.token_data.token_value.should_not eq(nil)
184
+
185
+ multi_token = auth.token_data.token_value
186
+ auth_multi_token = Hps::TestHelper.auth_token(multi_token)
187
+ auth_multi_token.transaction_id.should_not eq(nil)
188
+ auth_multi_token.response_code.should eq('00')
189
+ end
190
+
191
+ it 'Should get a multi use token from a Discover card and auth it with out error' do
192
+ token = token_service.get_token(Hps::TestData.valid_discover)
193
+ auth = Hps::TestHelper.auth_token(token['token_value'],true)
194
+
195
+ auth.transaction_id.should_not eq(nil)
196
+ auth.response_code.should eq('00')
197
+ auth.token_data.token_value.should_not eq(nil)
198
+
199
+ multi_token = auth.token_data.token_value
200
+ auth_multi_token = Hps::TestHelper.auth_token(multi_token)
201
+ auth_multi_token.transaction_id.should_not eq(nil)
202
+ auth_multi_token.response_code.should eq('00')
203
+ end
204
+
205
+ it 'Should get a multi use token from a Master card and auth it with out error' do
206
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
207
+ auth = Hps::TestHelper.auth_token(token['token_value'],true)
208
+
209
+ auth.transaction_id.should_not eq(nil)
210
+ auth.response_code.should eq('00')
211
+ auth.token_data.token_value.should_not eq(nil)
212
+
213
+ multi_token = auth.token_data.token_value
214
+ auth_multi_token = Hps::TestHelper.auth_token(multi_token)
215
+ auth_multi_token.transaction_id.should_not eq(nil)
216
+ auth_multi_token.response_code.should eq('00')
217
+ end
218
+
219
+ it 'Should get a multi use token from a Visa card and auth it with out error' do
220
+ token = token_service.get_token(Hps::TestData.valid_visa)
221
+ auth = Hps::TestHelper.auth_token(token['token_value'],true)
222
+
223
+ auth.transaction_id.should_not eq(nil)
224
+ auth.response_code.should eq('00')
225
+ auth.token_data.token_value.should_not eq(nil)
226
+
227
+ multi_token = auth.token_data.token_value
228
+ auth_multi_token = Hps::TestHelper.auth_token(multi_token)
229
+ auth_multi_token.transaction_id.should_not eq(nil)
230
+ auth_multi_token.response_code.should eq('00')
231
+ end
232
+
233
+ # Verify Testing with a token
234
+
235
+ it 'Should get a token from a Amex card and verify it with out error' do
236
+ token = token_service.get_token(Hps::TestData.valid_amex)
237
+ verify = Hps::TestHelper.verify_token(token['token_value'])
238
+
239
+ verify.transaction_id.should_not eq(nil)
240
+ verify.response_code.should eq('00')
241
+ end
242
+
243
+ it 'Should get a token from a Discover card and verify it with out error' do
244
+ token = token_service.get_token(Hps::TestData.valid_discover)
245
+ verify = Hps::TestHelper.verify_token(token['token_value'])
246
+
247
+ verify.transaction_id.should_not eq(nil)
248
+ verify.response_code.should eq('85')
249
+ end
250
+
251
+ it 'Should get a token from a Master card and verify it with out error' do
252
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
253
+ verify = Hps::TestHelper.verify_token(token['token_value'])
254
+
255
+ verify.transaction_id.should_not eq(nil)
256
+ verify.response_code.should eq('85')
257
+ end
258
+
259
+ it 'Should get a token from a Visa card and verify it with out error' do
260
+ token = token_service.get_token(Hps::TestData.valid_visa)
261
+ verify = Hps::TestHelper.verify_token(token['token_value'])
262
+
263
+ verify.transaction_id.should_not eq(nil)
264
+ verify.response_code.should eq('85')
265
+ end
266
+
267
+ # Verify Testing with a multi use token
268
+
269
+ it 'Should get a token from a Amex card verify it get a multi token and test with out error' do
270
+ token = token_service.get_token(Hps::TestData.valid_amex)
271
+ verify = Hps::TestHelper.verify_token(token['token_value'],true)
272
+
273
+ verify.transaction_id.should_not eq(nil)
274
+ verify.response_code.should eq('00')
275
+ verify.token_data.token_value.should_not eq(nil)
276
+
277
+ multi_token = verify.token_data.token_value
278
+ verify_multi_token = Hps::TestHelper.verify_token(multi_token)
279
+ verify_multi_token.transaction_id.should_not eq(nil)
280
+ verify_multi_token.response_code.should eq('00')
281
+ end
282
+
283
+ it 'Should get a token from a Discover card verify it get a multi token and test with out error' do
284
+ token = token_service.get_token(Hps::TestData.valid_discover)
285
+ verify = Hps::TestHelper.verify_token(token['token_value'],true)
286
+
287
+ verify.transaction_id.should_not eq(nil)
288
+ verify.response_code.should eq('85')
289
+ verify.token_data.token_value.should_not eq(nil)
290
+
291
+ multi_token = verify.token_data.token_value
292
+ verify_multi_token = Hps::TestHelper.verify_token(multi_token)
293
+ verify_multi_token.transaction_id.should_not eq(nil)
294
+ verify_multi_token.response_code.should eq('85')
295
+ end
296
+
297
+ it 'Should get a token from a Master card verify it get a multi token and test with out error' do
298
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
299
+ verify = Hps::TestHelper.verify_token(token['token_value'],true)
300
+
301
+ verify.transaction_id.should_not eq(nil)
302
+ verify.response_code.should eq('85')
303
+ verify.token_data.token_value.should_not eq(nil)
304
+
305
+ multi_token = verify.token_data.token_value
306
+ verify_multi_token = Hps::TestHelper.verify_token(multi_token)
307
+ verify_multi_token.transaction_id.should_not eq(nil)
308
+ verify_multi_token.response_code.should eq('85')
309
+ end
310
+
311
+ it 'Should get a token from a Visa card verify it get a multi token and test with out error' do
312
+ token = token_service.get_token(Hps::TestData.valid_visa)
313
+ verify = Hps::TestHelper.verify_token(token['token_value'],true)
314
+
315
+ verify.transaction_id.should_not eq(nil)
316
+ verify.response_code.should eq('85')
317
+ verify.token_data.token_value.should_not eq(nil)
318
+
319
+ multi_token = verify.token_data.token_value
320
+ verify_multi_token = Hps::TestHelper.verify_token(multi_token)
321
+ verify_multi_token.transaction_id.should_not eq(nil)
322
+ verify_multi_token.response_code.should eq('85')
323
+ end
324
+
325
+ # Refund Token Tests
326
+
327
+ it 'Should get Amex token return should be okay' do
328
+ token = token_service.get_token(Hps::TestData.valid_amex)
329
+ refund = Hps::TestHelper.refund_token(token['token_value'])
330
+
331
+ refund.transaction_id.should_not eq(nil)
332
+ refund.response_code.should eq('00')
333
+ end
334
+
335
+
336
+ it 'Should get Discover token return should be okay' do
337
+ token = token_service.get_token(Hps::TestData.valid_discover)
338
+ refund = Hps::TestHelper.refund_token(token['token_value'])
339
+
340
+ refund.transaction_id.should_not eq(nil)
341
+ refund.response_code.should eq('00')
342
+ end
343
+
344
+
345
+ it 'Should get MasterCard token return should be okay' do
346
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
347
+ refund = Hps::TestHelper.refund_token(token['token_value'])
348
+
349
+ refund.transaction_id.should_not eq(nil)
350
+ refund.response_code.should eq('00')
351
+ end
352
+
353
+ it 'Should get Visa token return should be okay' do
354
+ token = token_service.get_token(Hps::TestData.valid_visa)
355
+ refund = Hps::TestHelper.refund_token(token['token_value'])
356
+
357
+ refund.transaction_id.should_not eq(nil)
358
+ refund.response_code.should eq('00')
359
+ end
360
+
361
+ # Refund Multi Token Tests
362
+
363
+ it 'Should get Amex Mulit token return should be okay' do
364
+ token = token_service.get_token(Hps::TestData.valid_amex)
365
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
366
+
367
+ charge.transaction_id.should_not eq(nil)
368
+ charge.response_code.should eq('00')
369
+ charge.token_data.token_value.should_not eq(nil)
370
+
371
+ refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
372
+
373
+ refund.transaction_id.should_not eq(nil)
374
+ refund.response_code.should eq('00')
375
+ end
376
+
377
+ it 'Should get Discover Mulit token return should be okay' do
378
+ token = token_service.get_token(Hps::TestData.valid_discover)
379
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
380
+
381
+ charge.transaction_id.should_not eq(nil)
382
+ charge.response_code.should eq('00')
383
+ charge.token_data.token_value.should_not eq(nil)
384
+
385
+ refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
386
+
387
+ refund.transaction_id.should_not eq(nil)
388
+ refund.response_code.should eq('00')
389
+ end
390
+
391
+ it 'Should get MasterCard Mulit token return should be okay' do
392
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
393
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
394
+
395
+ charge.transaction_id.should_not eq(nil)
396
+ charge.response_code.should eq('00')
397
+ charge.token_data.token_value.should_not eq(nil)
398
+
399
+ refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
400
+
401
+ refund.transaction_id.should_not eq(nil)
402
+ refund.response_code.should eq('00')
403
+ end
404
+
405
+ it 'Should get Visa Mulit token return should be okay' do
406
+ token = token_service.get_token(Hps::TestData.valid_visa)
407
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
408
+
409
+ charge.transaction_id.should_not eq(nil)
410
+ charge.response_code.should eq('00')
411
+ charge.token_data.token_value.should_not eq(nil)
412
+
413
+ refund = Hps::TestHelper.refund_token(charge.token_data.token_value)
414
+
415
+ refund.transaction_id.should_not eq(nil)
416
+ refund.response_code.should eq('00')
417
+ end
418
+
419
+ # Reverse Token Tests
420
+
421
+ it 'Should get Amex token reverse should be okay' do
422
+ token = token_service.get_token(Hps::TestData.valid_amex)
423
+ refund = Hps::TestHelper.reverse_token(token['token_value'])
424
+
425
+ refund.transaction_id.should_not eq(nil)
426
+ refund.response_code.should eq('00')
427
+ end
428
+
429
+
430
+ it 'Should get Discover token reverse should be okay' do
431
+ token = token_service.get_token(Hps::TestData.valid_discover)
432
+ refund = Hps::TestHelper.reverse_token(token['token_value'])
433
+
434
+ refund.transaction_id.should_not eq(nil)
435
+ refund.response_code.should eq('00')
436
+ end
437
+
438
+
439
+ it 'Should get MasterCard token reverse should be okay' do
440
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
441
+ refund = Hps::TestHelper.reverse_token(token['token_value'])
442
+
443
+ refund.transaction_id.should_not eq(nil)
444
+ refund.response_code.should eq('00')
445
+ end
446
+
447
+ it 'Should get Visa token reverse should be okay' do
448
+ token = token_service.get_token(Hps::TestData.valid_visa)
449
+ refund = Hps::TestHelper.reverse_token(token['token_value'])
450
+
451
+ refund.transaction_id.should_not eq(nil)
452
+ refund.response_code.should eq('00')
453
+ end
454
+
455
+ # Reverse Multi Token Tests
456
+
457
+ it 'Should get Amex Mulit token reverse should be okay' do
458
+ token = token_service.get_token(Hps::TestData.valid_amex)
459
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
460
+
461
+ charge.transaction_id.should_not eq(nil)
462
+ charge.response_code.should eq('00')
463
+ charge.token_data.token_value.should_not eq(nil)
464
+
465
+ refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
466
+
467
+ refund.transaction_id.should_not eq(nil)
468
+ refund.response_code.should eq('00')
469
+ end
470
+
471
+ it 'Should get Discover Mulit token reverse should be okay' do
472
+ token = token_service.get_token(Hps::TestData.valid_discover)
473
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
474
+
475
+ charge.transaction_id.should_not eq(nil)
476
+ charge.response_code.should eq('00')
477
+ charge.token_data.token_value.should_not eq(nil)
478
+
479
+ refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
480
+
481
+ refund.transaction_id.should_not eq(nil)
482
+ refund.response_code.should eq('00')
483
+ end
484
+
485
+ it 'Should get MasterCard Mulit token reverse should be okay' do
486
+ token = token_service.get_token(Hps::TestData.valid_mastercard)
487
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
488
+
489
+ charge.transaction_id.should_not eq(nil)
490
+ charge.response_code.should eq('00')
491
+ charge.token_data.token_value.should_not eq(nil)
492
+
493
+ refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
494
+
495
+ refund.transaction_id.should_not eq(nil)
496
+ refund.response_code.should eq('00')
497
+ end
498
+
499
+ it 'Should get Visa Mulit token reverse should be okay' do
500
+ token = token_service.get_token(Hps::TestData.valid_visa)
501
+ charge = Hps::TestHelper.charge_token(token['token_value'],true)
502
+
503
+ charge.transaction_id.should_not eq(nil)
504
+ charge.response_code.should eq('00')
505
+ charge.token_data.token_value.should_not eq(nil)
506
+
507
+ refund = Hps::TestHelper.reverse_token(charge.token_data.token_value)
508
+
509
+ refund.transaction_id.should_not eq(nil)
510
+ refund.response_code.should eq('00')
511
+ end
512
+
513
+ end