hps 2.3.2 → 2.4.0
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.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Gemfile.lock +59 -0
- data/LICENSE.md +264 -264
- data/PRIVACY.txt +65 -65
- data/README.md +213 -213
- data/Rakefile +15 -15
- data/examples/sinatra-verify-only/Gemfile +4 -4
- data/examples/sinatra-verify-only/app.rb +32 -32
- data/examples/sinatra-verify-only/views/index.erb +478 -478
- data/examples/sinatra-verify-only/views/result.erb +39 -39
- data/hps.gemspec +28 -27
- data/lib/hps/configuration.rb +17 -17
- data/lib/hps/entities/hps_account_verify.rb +8 -8
- data/lib/hps/entities/hps_address.rb +6 -6
- data/lib/hps/entities/hps_authorization.rb +12 -12
- data/lib/hps/entities/hps_batch.rb +6 -6
- data/lib/hps/entities/hps_cardholder.rb +6 -6
- data/lib/hps/entities/hps_charge.rb +8 -8
- data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
- data/lib/hps/entities/hps_check.rb +18 -18
- data/lib/hps/entities/hps_check_holder.rb +10 -10
- data/lib/hps/entities/hps_check_response.rb +45 -45
- data/lib/hps/entities/hps_check_response_details.rb +9 -9
- data/lib/hps/entities/hps_credit_card.rb +34 -34
- data/lib/hps/entities/hps_direct_market_data.rb +5 -5
- data/lib/hps/entities/hps_encryption_data.rb +6 -6
- data/lib/hps/entities/hps_gift_card.rb +133 -133
- data/lib/hps/entities/hps_manage_tokens.rb +8 -8
- data/lib/hps/entities/hps_refund.rb +8 -8
- data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
- data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
- data/lib/hps/entities/hps_reversal.rb +10 -10
- data/lib/hps/entities/hps_token_data.rb +10 -10
- data/lib/hps/entities/hps_track_data.rb +5 -5
- data/lib/hps/entities/hps_transaction.rb +161 -161
- data/lib/hps/entities/hps_transaction_details.rb +6 -6
- data/lib/hps/entities/hps_transaction_header.rb +8 -8
- data/lib/hps/entities/hps_transaction_type.rb +16 -16
- data/lib/hps/entities/hps_void.rb +8 -8
- data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
- data/lib/hps/infrastructure/authentication_exception.rb +11 -11
- data/lib/hps/infrastructure/card_exception.rb +15 -15
- data/lib/hps/infrastructure/exceptions.json +547 -547
- data/lib/hps/infrastructure/hps_account_type.rb +11 -11
- data/lib/hps/infrastructure/hps_check_exception.rb +13 -13
- data/lib/hps/infrastructure/hps_check_type.rb +11 -11
- data/lib/hps/infrastructure/hps_data_entry_mode.rb +11 -11
- data/lib/hps/infrastructure/hps_exception.rb +25 -25
- data/lib/hps/infrastructure/hps_exception_mapper.rb +145 -145
- data/lib/hps/infrastructure/hps_gateway_response_validation.rb +20 -20
- data/lib/hps/infrastructure/hps_input_validation.rb +13 -13
- data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
- data/lib/hps/infrastructure/hps_sec_code.rb +27 -27
- data/lib/hps/infrastructure/hps_track_data_method.rb +6 -6
- data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
- data/lib/hps/services/hps_batch_service.rb +29 -29
- data/lib/hps/services/hps_charge_service.rb +773 -773
- data/lib/hps/services/hps_check_service.rb +110 -110
- data/lib/hps/services/hps_gift_card_service.rb +301 -301
- data/lib/hps/services/hps_service.rb +141 -136
- data/lib/hps/version.rb +3 -3
- data/lib/hps.rb +63 -63
- data/tests/amex_tests.rb +292 -292
- data/tests/cert_tests.rb +80 -80
- data/tests/certification/card_present_spec.rb +320 -320
- data/tests/certification/gift_card_certification_test.rb +106 -106
- data/tests/certification/gift_card_certification_tests.rb +107 -107
- data/tests/check_tests.rb +50 -50
- data/tests/discover_tests.rb +386 -386
- data/tests/exception_mapper_tests.rb +311 -311
- data/tests/general_tests.rb +140 -140
- data/tests/giftcard_tests.rb +212 -212
- data/tests/hps_token_service.rb +56 -56
- data/tests/mastercard_tests.rb +387 -387
- data/tests/secret_key.rb +11 -11
- data/tests/test_check.rb +77 -77
- data/tests/test_data.rb +138 -138
- data/tests/test_helper.rb +179 -179
- data/tests/token_tests.rb +512 -512
- data/tests/visa_tests.rb +445 -445
- metadata +31 -11
data/tests/general_tests.rb
CHANGED
@@ -1,141 +1,141 @@
|
|
1
|
-
require File.join( File.dirname(__FILE__), "test_helper.rb" )
|
2
|
-
|
3
|
-
describe "General Tests" do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
Hps::TestHelper.configure_hps_module()
|
7
|
-
@service = Hps::HpsChargeService.new()
|
8
|
-
end
|
9
|
-
|
10
|
-
it "SecretAPIKey with spaces on Visa charge should return OK" do
|
11
|
-
Hps::TestHelper.configure_hps_module_secret_key_with_spaces
|
12
|
-
@service = Hps::HpsChargeService.new()
|
13
|
-
result = @service.charge(5, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
14
|
-
expect(result.response_code).to eql("00")
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
it "charge when amount is less than zero should throw invalid request exception" do
|
19
|
-
expect {
|
20
|
-
@service.charge(-5, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
21
|
-
}.to raise_error(Hps::InvalidRequestException)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "charge when currency is empty should throw invalid request exception" do
|
25
|
-
expect {
|
26
|
-
@service.charge(50, "", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
27
|
-
}.to raise_error(Hps::InvalidRequestException)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "charge when currency is not usd should throw invalid request exception" do
|
31
|
-
expect {
|
32
|
-
@service.charge(50, "eur", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
33
|
-
}.to raise_error(Hps::InvalidRequestException)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "charge when configuration is invalid should throw hps exception" do
|
37
|
-
expect {
|
38
|
-
@service = Hps::HpsChargeService.new :service_uri => nil
|
39
|
-
@service.charge(50, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
40
|
-
}.to raise_error(Hps::HpsException)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "charge when license_id is invalid should throw authentication exception" do
|
44
|
-
expect {
|
45
|
-
@service = Hps::HpsChargeService.new :license_id => 11111
|
46
|
-
@service.charge(50, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
47
|
-
}.to raise_error(Hps::AuthenticationException)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "charge when card number is invalid should throw hps exception" do
|
51
|
-
expect {
|
52
|
-
@service.charge(50, "usd", Hps::TestData::invalid_card, Hps::TestData::valid_cardholder)
|
53
|
-
}.to raise_error(Hps::HpsException)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "list when charge is in filter range should show in list" do
|
57
|
-
start_date = DateTime.now - 12.hours
|
58
|
-
charge = @service.charge(50, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
59
|
-
end_date = DateTime.now
|
60
|
-
|
61
|
-
charges = @service.list(start_date, end_date)
|
62
|
-
expect(charges).to have_at_least(1).items
|
63
|
-
expect(charges.any? { |c| c.transaction_id = charge.transaction_id }).to be_true
|
64
|
-
end
|
65
|
-
|
66
|
-
it "updates multi-use token" do
|
67
|
-
Hps::TestHelper.valid_multi_use_config
|
68
|
-
service = Hps::HpsChargeService.new()
|
69
|
-
verify = service.verify(Hps::TestData::valid_visa, Hps::TestData.valid_cardholder, true)
|
70
|
-
expect(verify).not_to be_nil
|
71
|
-
expect(verify.response_code).to eql("85")
|
72
|
-
expect(verify.token_data).not_to be_nil
|
73
|
-
expect(verify.token_data.token_value).not_to be_nil
|
74
|
-
expect(verify.token_data.token_value).not_to be_empty
|
75
|
-
|
76
|
-
month = Time.now.strftime('%m')
|
77
|
-
year = (Time.now + 2.years).strftime('%Y')
|
78
|
-
result = service.update_token_expiration(verify.token_data.token_value, month, year)
|
79
|
-
expect(result).not_to be_nil
|
80
|
-
expect(result.response_code).to eql("00")
|
81
|
-
end
|
82
|
-
|
83
|
-
it "fails to update multi-use token with bad year" do
|
84
|
-
Hps::TestHelper.valid_multi_use_config
|
85
|
-
service = Hps::HpsChargeService.new()
|
86
|
-
verify = service.verify(Hps::TestData::valid_visa, Hps::TestData.valid_cardholder, true)
|
87
|
-
expect(verify).not_to be_nil
|
88
|
-
expect(verify.response_code).to eql("85")
|
89
|
-
expect(verify.token_data).not_to be_nil
|
90
|
-
expect(verify.token_data.token_value).not_to be_nil
|
91
|
-
expect(verify.token_data.token_value).not_to be_empty
|
92
|
-
|
93
|
-
month = nil
|
94
|
-
year = 19
|
95
|
-
|
96
|
-
expect {
|
97
|
-
service.update_token_expiration(verify.token_data.token_value, month, year)
|
98
|
-
}.to raise_error(TypeError)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "fails to update multi-use token with nil date" do
|
102
|
-
Hps::TestHelper.valid_multi_use_config
|
103
|
-
service = Hps::HpsChargeService.new()
|
104
|
-
verify = service.verify(Hps::TestData::valid_visa, Hps::TestData.valid_cardholder, true)
|
105
|
-
expect(verify).not_to be_nil
|
106
|
-
expect(verify.response_code).to eql("85")
|
107
|
-
expect(verify.token_data).not_to be_nil
|
108
|
-
expect(verify.token_data.token_value).not_to be_nil
|
109
|
-
expect(verify.token_data.token_value).not_to be_empty
|
110
|
-
|
111
|
-
month = nil
|
112
|
-
year = nil
|
113
|
-
|
114
|
-
expect {
|
115
|
-
service.update_token_expiration(verify.token_data.token_value, month, year)
|
116
|
-
}.to raise_error(TypeError)
|
117
|
-
end
|
118
|
-
|
119
|
-
it "fails to update multi-use token with invalid token" do
|
120
|
-
Hps::TestHelper.valid_multi_use_config
|
121
|
-
service = Hps::HpsChargeService.new()
|
122
|
-
month = Time.now.strftime('%m')
|
123
|
-
year = (Time.now + 2.years).strftime('%Y')
|
124
|
-
|
125
|
-
expect {
|
126
|
-
service.update_token_expiration("abcdefg", month, year)
|
127
|
-
}.to raise_error(Hps::HpsException)
|
128
|
-
end
|
129
|
-
|
130
|
-
it "fails to update multi-use token with nil token" do
|
131
|
-
Hps::TestHelper.valid_multi_use_config
|
132
|
-
service = Hps::HpsChargeService.new()
|
133
|
-
month = Time.now.strftime('%m')
|
134
|
-
year = (Time.now + 2.years).strftime('%Y')
|
135
|
-
|
136
|
-
expect {
|
137
|
-
service.update_token_expiration(nil, month, year)
|
138
|
-
}.to raise_error(Hps::HpsException)
|
139
|
-
end
|
140
|
-
|
1
|
+
require File.join( File.dirname(__FILE__), "test_helper.rb" )
|
2
|
+
|
3
|
+
describe "General Tests" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
Hps::TestHelper.configure_hps_module()
|
7
|
+
@service = Hps::HpsChargeService.new()
|
8
|
+
end
|
9
|
+
|
10
|
+
it "SecretAPIKey with spaces on Visa charge should return OK" do
|
11
|
+
Hps::TestHelper.configure_hps_module_secret_key_with_spaces
|
12
|
+
@service = Hps::HpsChargeService.new()
|
13
|
+
result = @service.charge(5, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
14
|
+
expect(result.response_code).to eql("00")
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
it "charge when amount is less than zero should throw invalid request exception" do
|
19
|
+
expect {
|
20
|
+
@service.charge(-5, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
21
|
+
}.to raise_error(Hps::InvalidRequestException)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "charge when currency is empty should throw invalid request exception" do
|
25
|
+
expect {
|
26
|
+
@service.charge(50, "", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
27
|
+
}.to raise_error(Hps::InvalidRequestException)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "charge when currency is not usd should throw invalid request exception" do
|
31
|
+
expect {
|
32
|
+
@service.charge(50, "eur", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
33
|
+
}.to raise_error(Hps::InvalidRequestException)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "charge when configuration is invalid should throw hps exception" do
|
37
|
+
expect {
|
38
|
+
@service = Hps::HpsChargeService.new :service_uri => nil
|
39
|
+
@service.charge(50, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
40
|
+
}.to raise_error(Hps::HpsException)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "charge when license_id is invalid should throw authentication exception" do
|
44
|
+
expect {
|
45
|
+
@service = Hps::HpsChargeService.new :license_id => 11111
|
46
|
+
@service.charge(50, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
47
|
+
}.to raise_error(Hps::AuthenticationException)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "charge when card number is invalid should throw hps exception" do
|
51
|
+
expect {
|
52
|
+
@service.charge(50, "usd", Hps::TestData::invalid_card, Hps::TestData::valid_cardholder)
|
53
|
+
}.to raise_error(Hps::HpsException)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "list when charge is in filter range should show in list" do
|
57
|
+
start_date = DateTime.now - 12.hours
|
58
|
+
charge = @service.charge(50, "usd", Hps::TestData::valid_visa, Hps::TestData::valid_cardholder)
|
59
|
+
end_date = DateTime.now
|
60
|
+
|
61
|
+
charges = @service.list(start_date, end_date)
|
62
|
+
expect(charges).to have_at_least(1).items
|
63
|
+
expect(charges.any? { |c| c.transaction_id = charge.transaction_id }).to be_true
|
64
|
+
end
|
65
|
+
|
66
|
+
it "updates multi-use token" do
|
67
|
+
Hps::TestHelper.valid_multi_use_config
|
68
|
+
service = Hps::HpsChargeService.new()
|
69
|
+
verify = service.verify(Hps::TestData::valid_visa, Hps::TestData.valid_cardholder, true)
|
70
|
+
expect(verify).not_to be_nil
|
71
|
+
expect(verify.response_code).to eql("85")
|
72
|
+
expect(verify.token_data).not_to be_nil
|
73
|
+
expect(verify.token_data.token_value).not_to be_nil
|
74
|
+
expect(verify.token_data.token_value).not_to be_empty
|
75
|
+
|
76
|
+
month = Time.now.strftime('%m')
|
77
|
+
year = (Time.now + 2.years).strftime('%Y')
|
78
|
+
result = service.update_token_expiration(verify.token_data.token_value, month, year)
|
79
|
+
expect(result).not_to be_nil
|
80
|
+
expect(result.response_code).to eql("00")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "fails to update multi-use token with bad year" do
|
84
|
+
Hps::TestHelper.valid_multi_use_config
|
85
|
+
service = Hps::HpsChargeService.new()
|
86
|
+
verify = service.verify(Hps::TestData::valid_visa, Hps::TestData.valid_cardholder, true)
|
87
|
+
expect(verify).not_to be_nil
|
88
|
+
expect(verify.response_code).to eql("85")
|
89
|
+
expect(verify.token_data).not_to be_nil
|
90
|
+
expect(verify.token_data.token_value).not_to be_nil
|
91
|
+
expect(verify.token_data.token_value).not_to be_empty
|
92
|
+
|
93
|
+
month = nil
|
94
|
+
year = 19
|
95
|
+
|
96
|
+
expect {
|
97
|
+
service.update_token_expiration(verify.token_data.token_value, month, year)
|
98
|
+
}.to raise_error(TypeError)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "fails to update multi-use token with nil date" do
|
102
|
+
Hps::TestHelper.valid_multi_use_config
|
103
|
+
service = Hps::HpsChargeService.new()
|
104
|
+
verify = service.verify(Hps::TestData::valid_visa, Hps::TestData.valid_cardholder, true)
|
105
|
+
expect(verify).not_to be_nil
|
106
|
+
expect(verify.response_code).to eql("85")
|
107
|
+
expect(verify.token_data).not_to be_nil
|
108
|
+
expect(verify.token_data.token_value).not_to be_nil
|
109
|
+
expect(verify.token_data.token_value).not_to be_empty
|
110
|
+
|
111
|
+
month = nil
|
112
|
+
year = nil
|
113
|
+
|
114
|
+
expect {
|
115
|
+
service.update_token_expiration(verify.token_data.token_value, month, year)
|
116
|
+
}.to raise_error(TypeError)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "fails to update multi-use token with invalid token" do
|
120
|
+
Hps::TestHelper.valid_multi_use_config
|
121
|
+
service = Hps::HpsChargeService.new()
|
122
|
+
month = Time.now.strftime('%m')
|
123
|
+
year = (Time.now + 2.years).strftime('%Y')
|
124
|
+
|
125
|
+
expect {
|
126
|
+
service.update_token_expiration("abcdefg", month, year)
|
127
|
+
}.to raise_error(Hps::HpsException)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "fails to update multi-use token with nil token" do
|
131
|
+
Hps::TestHelper.valid_multi_use_config
|
132
|
+
service = Hps::HpsChargeService.new()
|
133
|
+
month = Time.now.strftime('%m')
|
134
|
+
year = (Time.now + 2.years).strftime('%Y')
|
135
|
+
|
136
|
+
expect {
|
137
|
+
service.update_token_expiration(nil, month, year)
|
138
|
+
}.to raise_error(Hps::HpsException)
|
139
|
+
end
|
140
|
+
|
141
141
|
end
|