hps 2.2.5 → 2.3.2
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 +5 -5
- data/LICENSE.md +264 -0
- data/README.md +44 -47
- data/hps.gemspec +2 -3
- data/lib/hps.rb +2 -0
- data/lib/hps/entities/hps_gift_card.rb +133 -0
- data/lib/hps/infrastructure/exceptions.json +81 -2
- data/lib/hps/infrastructure/hps_exception_mapper.rb +26 -15
- data/lib/hps/infrastructure/hps_input_validation.rb +1 -1
- data/lib/hps/services/hps_gift_card_service.rb +301 -0
- data/lib/hps/version.rb +1 -1
- data/tests/certification/gift_card_certification_test.rb +107 -0
- data/tests/certification/gift_card_certification_tests.rb +107 -0
- data/tests/exception_mapper_tests.rb +105 -38
- data/tests/giftcard_tests.rb +212 -0
- data/tests/test_data.rb +32 -22
- data/tests/test_helper.rb +63 -0
- metadata +14 -9
- data/LICENSE.txt +0 -32
data/lib/hps/version.rb
CHANGED
@@ -0,0 +1,107 @@
|
|
1
|
+
require File.join( File.dirname(File.dirname(__FILE__)), "test_helper" )
|
2
|
+
|
3
|
+
describe "Gift card certification tests" do
|
4
|
+
let(:service) do
|
5
|
+
Hps::TestHelper.valid_multi_use_config
|
6
|
+
Hps::HpsGiftCardService.new
|
7
|
+
end
|
8
|
+
|
9
|
+
# Test #96
|
10
|
+
it "testActivateSVA1" do
|
11
|
+
activation = service.activate( sva1, 6.00 )
|
12
|
+
expect( activation.response_code ).to eql("0")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Test #97
|
16
|
+
it "testActivateSVA2" do
|
17
|
+
activation = service.activate( sva2, 7.00 )
|
18
|
+
expect( activation.response_code ).to eql("0")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Test #98
|
22
|
+
it "testAddValueSVA1" do
|
23
|
+
add_value = service.add_value( sva1, 8.00 )
|
24
|
+
expect( add_value.response_code ).to eql("0")
|
25
|
+
end
|
26
|
+
|
27
|
+
# Test #99
|
28
|
+
it "testAddValueSVA2" do
|
29
|
+
add_value = service.add_value( sva2, 9.00 )
|
30
|
+
expect( add_value.response_code ).to eql("0")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Test #100
|
34
|
+
it "testBalanceSVA1" do
|
35
|
+
balance = service.balance( sva1 )
|
36
|
+
expect( balance.response_code ).to eql("0")
|
37
|
+
expect( balance.balance_amount.to_i ).to eql(10)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Test #101
|
41
|
+
it "testBalanceSVA2" do
|
42
|
+
balance = service.balance( sva2 )
|
43
|
+
expect( balance.response_code ).to eql("0")
|
44
|
+
expect( balance.balance_amount.to_i ).to eql(10)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Test #102
|
48
|
+
it "testReplaceSVA1" do
|
49
|
+
replace = service.replace(sva1, sva2)
|
50
|
+
expect( replace.response_code ).to eql("0")
|
51
|
+
end
|
52
|
+
|
53
|
+
# Test #103
|
54
|
+
it "testReplaceSVA2" do
|
55
|
+
replace = service.replace(sva2, sva1)
|
56
|
+
expect( replace.response_code ).to eql("0")
|
57
|
+
end
|
58
|
+
|
59
|
+
# Test #104
|
60
|
+
it "testSaleSVA1" do
|
61
|
+
sale = service.sale(sva1, 1.00)
|
62
|
+
expect( sale.response_code ).to eql("0")
|
63
|
+
end
|
64
|
+
|
65
|
+
# Test #105
|
66
|
+
it "testSaleSVA2" do
|
67
|
+
sale = service.sale(sva2, 2.00)
|
68
|
+
expect( sale.response_code ).to eql("0")
|
69
|
+
end
|
70
|
+
|
71
|
+
# Test #106 & Test #108
|
72
|
+
it "testSaleAndVoidSVA1" do
|
73
|
+
sale = service.sale(sva1, 3.00)
|
74
|
+
expect( sale.response_code ).to eql("0")
|
75
|
+
void = service.void(sale.transaction_id)
|
76
|
+
expect( void.response_code ).to eql("0")
|
77
|
+
end
|
78
|
+
|
79
|
+
# Test #107 & Test # 109
|
80
|
+
it "testSaleAndReversalSVA2" do
|
81
|
+
sale = service.sale(sva2, 4.00)
|
82
|
+
expect( sale.response_code ).to eql("0")
|
83
|
+
reverse = service.reverse(sale.transaction_id, 4.00)
|
84
|
+
expect( reverse.response_code ).to eql("0")
|
85
|
+
end
|
86
|
+
|
87
|
+
# Test #110
|
88
|
+
it "testDeactivateSVA1" do
|
89
|
+
deactivate = service.deactivate(sva1)
|
90
|
+
expect( deactivate.response_code ).to eql("0")
|
91
|
+
end
|
92
|
+
|
93
|
+
# Test #111
|
94
|
+
it "testDeactivateSVA1" do
|
95
|
+
deactivate = service.deactivate(sva2)
|
96
|
+
expect( deactivate.response_code ).to eql("0")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Helper methods
|
101
|
+
def sva1
|
102
|
+
Hps::HpsGiftCard.new(5022440000000000098)
|
103
|
+
end
|
104
|
+
|
105
|
+
def sva2
|
106
|
+
Hps::HpsGiftCard.new(5022440000000000007)
|
107
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require File.join( File.dirname(File.dirname(__FILE__)), "test_helper" )
|
2
|
+
|
3
|
+
describe "Gift card certification tests" do
|
4
|
+
let(:service) do
|
5
|
+
Hps::TestHelper.valid_multi_use_config
|
6
|
+
Hps::HpsGiftCardService.new
|
7
|
+
end
|
8
|
+
|
9
|
+
# Test #96
|
10
|
+
it "testActivateSVA1" do
|
11
|
+
activation = service.activate( sva1, 6.00 )
|
12
|
+
expect( activation.response_code ).to eql("0")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Test #97
|
16
|
+
it "testActivateSVA2" do
|
17
|
+
activation = service.activate( sva2, 7.00 )
|
18
|
+
expect( activation.response_code ).to eql("0")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Test #98
|
22
|
+
it "testAddValueSVA1" do
|
23
|
+
add_value = service.add_value( sva1, 8.00 )
|
24
|
+
expect( add_value.response_code ).to eql("0")
|
25
|
+
end
|
26
|
+
|
27
|
+
# Test #99
|
28
|
+
it "testAddValueSVA2" do
|
29
|
+
add_value = service.add_value( sva2, 9.00 )
|
30
|
+
expect( add_value.response_code ).to eql("0")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Test #100
|
34
|
+
it "testBalanceSVA1" do
|
35
|
+
balance = service.balance( sva1 )
|
36
|
+
expect( balance.response_code ).to eql("0")
|
37
|
+
expect( balance.balance_amount.to_i ).to eql(10)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Test #101
|
41
|
+
it "testBalanceSVA2" do
|
42
|
+
balance = service.balance( sva2 )
|
43
|
+
expect( balance.response_code ).to eql("0")
|
44
|
+
expect( balance.balance_amount.to_i ).to eql(10)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Test #102
|
48
|
+
it "testReplaceSVA1" do
|
49
|
+
replace = service.replace(sva1, sva2)
|
50
|
+
expect( replace.response_code ).to eql("0")
|
51
|
+
end
|
52
|
+
|
53
|
+
# Test #103
|
54
|
+
it "testReplaceSVA2" do
|
55
|
+
replace = service.replace(sva2, sva1)
|
56
|
+
expect( replace.response_code ).to eql("0")
|
57
|
+
end
|
58
|
+
|
59
|
+
# Test #104
|
60
|
+
it "testSaleSVA1" do
|
61
|
+
sale = service.sale(sva1, 1.00)
|
62
|
+
expect( sale.response_code ).to eql("0")
|
63
|
+
end
|
64
|
+
|
65
|
+
# Test #105
|
66
|
+
it "testSaleSVA2" do
|
67
|
+
sale = service.sale(sva2, 2.00)
|
68
|
+
expect( sale.response_code ).to eql("0")
|
69
|
+
end
|
70
|
+
|
71
|
+
# Test #106 & Test #108
|
72
|
+
it "testSaleAndVoidSVA1" do
|
73
|
+
sale = service.sale(sva1, 3.00)
|
74
|
+
expect( sale.response_code ).to eql("0")
|
75
|
+
void = service.void(sale.transaction_id)
|
76
|
+
expect( void.response_code ).to eql("0")
|
77
|
+
end
|
78
|
+
|
79
|
+
# Test #107 & Test # 109
|
80
|
+
it "testSaleAndReversalSVA2" do
|
81
|
+
sale = service.sale(sva2, 4.00)
|
82
|
+
expect( sale.response_code ).to eql("0")
|
83
|
+
reverse = service.reverse(sale.transaction_id, 4.00)
|
84
|
+
expect( reverse.response_code ).to eql("0")
|
85
|
+
end
|
86
|
+
|
87
|
+
# Test #110
|
88
|
+
it "testDeactivateSVA1" do
|
89
|
+
deactivate = service.deactivate(sva1)
|
90
|
+
expect( deactivate.response_code ).to eql("0")
|
91
|
+
end
|
92
|
+
|
93
|
+
# Test #111
|
94
|
+
it "testDeactivateSVA1" do
|
95
|
+
deactivate = service.deactivate(sva2)
|
96
|
+
expect( deactivate.response_code ).to eql("0")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Helper methods
|
101
|
+
def sva1
|
102
|
+
Hps::HpsGiftCard.new(5022440000000000098)
|
103
|
+
end
|
104
|
+
|
105
|
+
def sva2
|
106
|
+
Hps::HpsGiftCard.new(5022440000000000007)
|
107
|
+
end
|
@@ -9,14 +9,14 @@ describe "ExceptionMapper Tests" do
|
|
9
9
|
|
10
10
|
|
11
11
|
it "mapping version number accessible" do
|
12
|
-
expect(@mapper.version_number).to eq("1.0.
|
13
|
-
end
|
12
|
+
expect(@mapper.version_number).to eq("1.0.1")
|
13
|
+
end
|
14
14
|
|
15
15
|
# Issuer Exceptions
|
16
16
|
|
17
17
|
it "issuer card declined test codes" do
|
18
18
|
|
19
|
-
[ "02", "03", "04", "05", "41", "43", "44", "51", "56", "61", "62", "63", "65", "78" ].each { |code|
|
19
|
+
[ "02", "03", "04", "05", "41", "43", "44", "51", "56", "61", "62", "63", "65", "78" ].each { |code|
|
20
20
|
|
21
21
|
result = @mapper.map_issuer_exception(1, code, "")
|
22
22
|
expect(result.transaction_id).to eq(1)
|
@@ -28,7 +28,7 @@ describe "ExceptionMapper Tests" do
|
|
28
28
|
|
29
29
|
it "issuer processing error test codes" do
|
30
30
|
|
31
|
-
[ "06", "07", "12", "15", "19", "12", "52", "53", "57", "58", "76", "77", "91", "96", "EC" ].each { |code|
|
31
|
+
[ "06", "07", "12", "15", "19", "12", "52", "53", "57", "58", "76", "77", "91", "96", "EC" ].each { |code|
|
32
32
|
|
33
33
|
result = @mapper.map_issuer_exception(2, code, "")
|
34
34
|
expect(result.transaction_id).to eq(2)
|
@@ -42,72 +42,72 @@ describe "ExceptionMapper Tests" do
|
|
42
42
|
result = @mapper.map_issuer_exception(3, "13", "")
|
43
43
|
expect(result.transaction_id).to eq(3)
|
44
44
|
expect(result.code).to eq("invalid_amount")
|
45
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
45
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
46
46
|
end
|
47
47
|
|
48
48
|
it "issuer incorrect number test" do
|
49
49
|
result = @mapper.map_issuer_exception(4, "14", "")
|
50
50
|
expect(result.transaction_id).to eq(4)
|
51
51
|
expect(result.code).to eq("incorrect_number")
|
52
|
-
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectNumber"))
|
52
|
+
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectNumber"))
|
53
53
|
end
|
54
54
|
|
55
55
|
it "issuer expired card test" do
|
56
56
|
result = @mapper.map_issuer_exception(5, "54", "")
|
57
57
|
expect(result.transaction_id).to eq(5)
|
58
58
|
expect(result.code).to eq("expired_card")
|
59
|
-
expect(result.message).to eq(message_for_code("Exception_Message_CardExpired"))
|
59
|
+
expect(result.message).to eq(message_for_code("Exception_Message_CardExpired"))
|
60
60
|
end
|
61
61
|
|
62
62
|
it "issuer invalid pin test" do
|
63
63
|
result = @mapper.map_issuer_exception(6, "55", "")
|
64
64
|
expect(result.transaction_id).to eq(6)
|
65
65
|
expect(result.code).to eq("invalid_pin")
|
66
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidPin"))
|
66
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidPin"))
|
67
67
|
end
|
68
68
|
|
69
69
|
it "issuer pin retries exceeded test" do
|
70
70
|
result = @mapper.map_issuer_exception(7, "75", "")
|
71
71
|
expect(result.transaction_id).to eq(7)
|
72
72
|
expect(result.code).to eq("pin_retries_exceeded")
|
73
|
-
expect(result.message).to eq(message_for_code("Exception_Message_PinExceeded"))
|
73
|
+
expect(result.message).to eq(message_for_code("Exception_Message_PinExceeded"))
|
74
74
|
end
|
75
75
|
|
76
76
|
it "issuer invalid expiry test" do
|
77
77
|
result = @mapper.map_issuer_exception(8, "80", "")
|
78
78
|
expect(result.transaction_id).to eq(8)
|
79
79
|
expect(result.code).to eq("invalid_expiry")
|
80
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidExpiry"))
|
80
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidExpiry"))
|
81
81
|
end
|
82
82
|
|
83
83
|
it "issuer pin verification test" do
|
84
84
|
result = @mapper.map_issuer_exception(9, "86", "")
|
85
85
|
expect(result.transaction_id).to eq(9)
|
86
86
|
expect(result.code).to eq("pin_verification")
|
87
|
-
expect(result.message).to eq(message_for_code("Exception_Message_PinVerification"))
|
87
|
+
expect(result.message).to eq(message_for_code("Exception_Message_PinVerification"))
|
88
88
|
end
|
89
89
|
|
90
90
|
it "issuer incorrect cvc test" do
|
91
|
-
[ "EB", "N7" ].each { |code|
|
91
|
+
[ "EB", "N7" ].each { |code|
|
92
92
|
result = @mapper.map_issuer_exception(10, code, "")
|
93
93
|
expect(result.transaction_id).to eq(10)
|
94
94
|
expect(result.code).to eq("incorrect_cvc")
|
95
95
|
expect(result.message).to eq(message_for_code("Exception_Message_IncorrectCvc"))
|
96
|
-
}
|
96
|
+
}
|
97
97
|
end
|
98
98
|
|
99
99
|
it "issuer unknown test" do
|
100
100
|
result = @mapper.map_issuer_exception(11, "Foo", "Foo")
|
101
101
|
expect(result.transaction_id).to eq(11)
|
102
102
|
expect(result.code).to eq("unknown_card_exception")
|
103
|
-
expect(result.message).to eq("Foo")
|
103
|
+
expect(result.message).to eq("Foo")
|
104
104
|
end
|
105
105
|
|
106
106
|
it "issuer nil test" do
|
107
107
|
result = @mapper.map_issuer_exception(0, nil, nil)
|
108
108
|
expect(result.transaction_id).to eq(0)
|
109
109
|
expect(result.code).to eq("unknown_card_exception")
|
110
|
-
expect(result.message).to eq("Hps::CardException")
|
110
|
+
expect(result.message).to eq("Hps::CardException")
|
111
111
|
end
|
112
112
|
|
113
113
|
# Gateway exceptions
|
@@ -115,57 +115,57 @@ describe "ExceptionMapper Tests" do
|
|
115
115
|
it "gateway authentication exception test" do
|
116
116
|
result = @mapper.map_gateway_exception(0, "-2", nil)
|
117
117
|
expect(result.code).to eq("unknown")
|
118
|
-
expect(result.message).to eq(message_for_code("Exception_Message_AuthenticationError"))
|
118
|
+
expect(result.message).to eq(message_for_code("Exception_Message_AuthenticationError"))
|
119
119
|
end
|
120
120
|
|
121
121
|
it "gateway invalid request exception cpc test" do
|
122
122
|
result = @mapper.map_gateway_exception(0, "12", nil)
|
123
123
|
expect(result.param).to eq("card")
|
124
124
|
expect(result.code).to eq("invalid_cpc_data")
|
125
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCpcData"))
|
125
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCpcData"))
|
126
126
|
end
|
127
127
|
|
128
128
|
it "gateway invalid request exception card data test" do
|
129
129
|
result = @mapper.map_gateway_exception(0, "13", nil)
|
130
130
|
expect(result.param).to eq("card")
|
131
131
|
expect(result.code).to eq("invalid_card_data")
|
132
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCardData"))
|
132
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCardData"))
|
133
133
|
end
|
134
134
|
|
135
135
|
it "gateway card exception test" do
|
136
136
|
result = @mapper.map_gateway_exception(0, "14", nil)
|
137
137
|
expect(result.code).to eq("invalid_number")
|
138
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidNumber"))
|
138
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidNumber"))
|
139
139
|
end
|
140
140
|
|
141
141
|
it "gateway message passthrough test" do
|
142
142
|
result = @mapper.map_gateway_exception(0, "1", "Foo")
|
143
143
|
expect(result.code).to eq("unknown")
|
144
|
-
expect(result.message).to eq("Foo")
|
144
|
+
expect(result.message).to eq("Foo")
|
145
145
|
end
|
146
146
|
|
147
147
|
it "gateway invalid original transaction test" do
|
148
148
|
result = @mapper.map_gateway_exception(0, "3", "Foo")
|
149
149
|
expect(result.code).to eq("invalid_original_transaction")
|
150
|
-
expect(result.message).to eq("Foo")
|
150
|
+
expect(result.message).to eq("Foo")
|
151
151
|
end
|
152
152
|
|
153
153
|
it "gateway no open batch test" do
|
154
154
|
result = @mapper.map_gateway_exception(0, "5", "Foo")
|
155
155
|
expect(result.code).to eq("no_open_batch")
|
156
|
-
expect(result.message).to eq("Foo")
|
156
|
+
expect(result.message).to eq("Foo")
|
157
157
|
end
|
158
158
|
|
159
159
|
it "gateway timeout test" do
|
160
160
|
result = @mapper.map_gateway_exception(0, "30", nil)
|
161
161
|
expect(result.code).to eq("unknown")
|
162
|
-
expect(result.message).to eq(message_for_code("Exception_Message_GatewayTimedOut"))
|
162
|
+
expect(result.message).to eq(message_for_code("Exception_Message_GatewayTimedOut"))
|
163
163
|
end
|
164
164
|
|
165
165
|
it "gateway unknown test" do
|
166
166
|
result = @mapper.map_gateway_exception(0, "Foo", "Foo")
|
167
167
|
expect(result.code).to eq("unknown")
|
168
|
-
expect(result.message).to eq("Foo")
|
168
|
+
expect(result.message).to eq("Foo")
|
169
169
|
end
|
170
170
|
|
171
171
|
# Sdk Exceptions
|
@@ -174,67 +174,134 @@ describe "ExceptionMapper Tests" do
|
|
174
174
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_transaction_id, nil)
|
175
175
|
expect(result.param).to eq("gatewayTransactionId")
|
176
176
|
expect(result.code).to eq("invalid_transaction_id")
|
177
|
-
expect(result.message).to eq(message_for_code("Exception_Message_TransactionIdLessThanEqualZero"))
|
178
|
-
end
|
177
|
+
expect(result.message).to eq(message_for_code("Exception_Message_TransactionIdLessThanEqualZero"))
|
178
|
+
end
|
179
179
|
|
180
180
|
it "sdk invalid gateway url test" do
|
181
181
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_gateway_url, nil)
|
182
182
|
expect(result.param).to eq("HpsServiceUri")
|
183
183
|
expect(result.code).to eq("sdk_exception")
|
184
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
185
|
-
end
|
184
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
185
|
+
end
|
186
186
|
|
187
187
|
it "sdk unable to process transaction test" do
|
188
188
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_gateway_url, nil)
|
189
189
|
expect(result.param).to eq("HpsServiceUri")
|
190
190
|
expect(result.code).to eq("sdk_exception")
|
191
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
191
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidGatewayUrl"))
|
192
192
|
end
|
193
193
|
|
194
194
|
it "sdk missing currency" do
|
195
195
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.missing_currency, nil)
|
196
196
|
expect(result.param).to eq("currency")
|
197
197
|
expect(result.code).to eq("missing_currency")
|
198
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ArgumentNull"))
|
199
|
-
end
|
198
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ArgumentNull"))
|
199
|
+
end
|
200
200
|
|
201
201
|
it "sdk invalid currency" do
|
202
202
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_currency, nil)
|
203
203
|
expect(result.param).to eq("currency")
|
204
204
|
expect(result.code).to eq("invalid_currency")
|
205
|
-
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCurrency"))
|
205
|
+
expect(result.message).to eq(message_for_code("Exception_Message_InvalidCurrency"))
|
206
206
|
end
|
207
207
|
|
208
208
|
it "sdk invalid amount" do
|
209
209
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.invalid_amount, nil)
|
210
210
|
expect(result.param).to eq("amount")
|
211
211
|
expect(result.code).to eq("invalid_amount")
|
212
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
212
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ChargeAmount"))
|
213
213
|
end
|
214
214
|
|
215
215
|
it "sdk reversal error after gateway timeout" do
|
216
216
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.reversal_error_after_gateway_timeout, nil)
|
217
217
|
expect(result.code).to eq("gateway_timeout")
|
218
|
-
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterGatewayTimeout"))
|
218
|
+
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterGatewayTimeout"))
|
219
219
|
end
|
220
220
|
|
221
221
|
it "sdk reversal error after issuer timeout" do
|
222
222
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.reversal_error_after_issuer_timeout, nil)
|
223
223
|
expect(result.code).to eq("issuer_timeout")
|
224
|
-
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterIssuerTimeout"))
|
224
|
+
expect(result.message).to eq(message_for_code("Exception_Message_UnableToReverseTransactionAfterIssuerTimeout"))
|
225
225
|
end
|
226
226
|
|
227
227
|
it "sdk processing error" do
|
228
228
|
result = @mapper.map_sdk_exception(Hps::SdkCodes.processing_error, nil)
|
229
229
|
expect(result.code).to eq("processing_error")
|
230
|
-
expect(result.message).to eq(message_for_code("Exception_Message_ProcessingError"))
|
231
|
-
end
|
230
|
+
expect(result.message).to eq(message_for_code("Exception_Message_ProcessingError"))
|
231
|
+
end
|
232
|
+
|
233
|
+
# GiftCards
|
234
|
+
context "Gift card exception mapper" do
|
235
|
+
it "unknown gift card error" do
|
236
|
+
%w(1 2 11).each do |n|
|
237
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
238
|
+
expect( result.code ).to eql("unknown_card_exception")
|
239
|
+
expect( result.message ).to eql("Response Text")
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
it "invalid card data" do
|
244
|
+
%w(3 8).each do |n|
|
245
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
246
|
+
expect( result.code ).to eql("invalid_card_data")
|
247
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_InvalidCardData"))
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
it "expired card error" do
|
252
|
+
%w(4).each do |n|
|
253
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
254
|
+
expect( result.code ).to eql("expired_card")
|
255
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_CardExpired"))
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it "declined card error" do
|
260
|
+
%w(5 12).each do |n|
|
261
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
262
|
+
expect( result.code ).to eql("card_declined")
|
263
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_CardDeclined"))
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
it "processing error" do
|
268
|
+
%w(6 7 10).each do |n|
|
269
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
270
|
+
expect( result.code ).to eql("processing_error")
|
271
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_ProcessingError"))
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
it "invalid amount error" do
|
276
|
+
%w(9).each do |n|
|
277
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
278
|
+
expect( result.code ).to eql("invalid_amount")
|
279
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_ChargeAmount"))
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
it "partial approval error" do
|
284
|
+
%w(13).each do |n|
|
285
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
286
|
+
expect( result.code ).to eql("partial_approval")
|
287
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_PartialApproval"))
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
it "invalid pin error" do
|
292
|
+
%w(14).each do |n|
|
293
|
+
result = @mapper.map_gift_card_exception(12345, n, "Response Text")
|
294
|
+
expect( result.code ).to eql("invalid_pin")
|
295
|
+
expect( result.message ).to eql(message_for_code("Exception_Message_InvalidPin"))
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
232
299
|
|
233
300
|
# Helper methods
|
234
301
|
|
235
302
|
def message_for_code(code)
|
236
303
|
|
237
|
-
mapping = @mapper.exceptions["exception_messages"].detect { |message|
|
304
|
+
mapping = @mapper.exceptions["exception_messages"].detect { |message|
|
238
305
|
message["code"] == code
|
239
306
|
}
|
240
307
|
|