tomriley-active_merchant 1.4.2.3 → 1.4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/CONTRIBUTERS +12 -0
- data/active_merchant.gemspec +3 -2
- data/init.rb +0 -1
- data/lib/active_merchant/billing/credit_card_methods.rb +1 -1
- data/lib/active_merchant/billing/expiry_date.rb +10 -4
- data/lib/active_merchant/billing/gateway.rb +4 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +12 -1
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -1
- data/lib/active_merchant/billing/gateways/bogus.rb +19 -0
- data/lib/active_merchant/billing/gateways/eway.rb +6 -1
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +259 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
- data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +45 -12
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
- data/lib/active_merchant/billing/response.rb +9 -1
- data/test/fixtures.yml +16 -1
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_ogone_test.rb +108 -0
- data/test/remote/gateways/remote_paypal_test.rb +12 -1
- data/test/remote/gateways/remote_protx_three_d_secure_test.rb +259 -0
- data/test/remote/gateways/{remote_protx_test.rb → remote_sage_pay_test.rb} +8 -8
- data/test/unit/credit_card_methods_test.rb +9 -0
- data/test/unit/expiry_date_test.rb +12 -1
- data/test/unit/gateways/bogus_test.rb +31 -0
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +6 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/ogone_test.rb +256 -0
- data/test/unit/gateways/paypal_test.rb +49 -0
- data/test/unit/gateways/sage_pay_test.rb +183 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +1 -1
- data/test/unit/response_test.rb +16 -0
- metadata +16 -5
- data/test/unit/gateways/protx_test.rb +0 -139
@@ -0,0 +1,256 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OgoneTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@credentials = { :login => 'merchant id',
|
7
|
+
:user => 'username',
|
8
|
+
:password => 'password',
|
9
|
+
:signature => 'mynicesig' }
|
10
|
+
@gateway = OgoneGateway.new(@credentials)
|
11
|
+
@credit_card = credit_card
|
12
|
+
@amount = 100
|
13
|
+
@identification = "3014726"
|
14
|
+
@options = {
|
15
|
+
:order_id => '1',
|
16
|
+
:billing_address => address,
|
17
|
+
:description => 'Store Purchase'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_successful_authorize
|
22
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
23
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
24
|
+
assert_success response
|
25
|
+
assert_equal '3014726;RES', response.authorization
|
26
|
+
assert response.test?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_successful_purchase
|
30
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
31
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
32
|
+
assert_success response
|
33
|
+
assert_equal '3014726;SAL', response.authorization
|
34
|
+
assert response.test?
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_successful_purchase_without_order_id
|
38
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
39
|
+
@options.delete(:order_id)
|
40
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
41
|
+
assert_success response
|
42
|
+
assert_equal '3014726;SAL', response.authorization
|
43
|
+
assert response.test?
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_successful_capture
|
47
|
+
@gateway.expects(:ssl_post).returns(successful_capture_response)
|
48
|
+
assert response = @gateway.capture(@amount, "3048326")
|
49
|
+
assert_success response
|
50
|
+
assert_equal '3048326;SAL', response.authorization
|
51
|
+
assert response.test?
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_successful_void
|
55
|
+
@gateway.expects(:ssl_post).returns(successful_void_response)
|
56
|
+
assert response = @gateway.void("3048606")
|
57
|
+
assert_success response
|
58
|
+
assert_equal '3048606;DES', response.authorization
|
59
|
+
assert response.test?
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_successful_referenced_credit
|
63
|
+
@gateway.expects(:ssl_post).returns(successful_referenced_credit_response)
|
64
|
+
assert response = @gateway.credit(@amount, "3049652")
|
65
|
+
assert_success response
|
66
|
+
assert_equal '3049652;RFD', response.authorization
|
67
|
+
assert response.test?
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_successful_unreferenced_credit
|
71
|
+
@gateway.expects(:ssl_post).returns(successful_unreferenced_credit_response)
|
72
|
+
assert response = @gateway.credit(@amount, @credit_card)
|
73
|
+
assert_success response
|
74
|
+
assert_equal "3049654;RFD", response.authorization
|
75
|
+
assert response.test?
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_unsuccessful_request
|
79
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
80
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
81
|
+
assert_failure response
|
82
|
+
assert response.test?
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_supported_countries
|
86
|
+
assert_equal ['BE', 'DE', 'FR', 'NL', 'AT', 'CH'], OgoneGateway.supported_countries
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_supported_card_types
|
90
|
+
assert_equal [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro], OgoneGateway.supported_cardtypes
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_default_currency
|
94
|
+
assert_equal 'EUR', OgoneGateway.default_currency
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_avs_result
|
98
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
99
|
+
response = @gateway.purchase(@amount, @credit_card)
|
100
|
+
assert_equal 'R', response.avs_result['code']
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_cvv_result
|
104
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
105
|
+
response = @gateway.purchase(@amount, @credit_card)
|
106
|
+
assert_equal 'P', response.cvv_result['code']
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def successful_authorize_response
|
112
|
+
<<-END
|
113
|
+
<?xml version="1.0"?><ncresponse
|
114
|
+
orderID="1233680882919266242708828"
|
115
|
+
PAYID="3014726"
|
116
|
+
NCSTATUS="0"
|
117
|
+
NCERROR="0"
|
118
|
+
NCERRORPLUS="!"
|
119
|
+
ACCEPTANCE="test123"
|
120
|
+
STATUS="5"
|
121
|
+
IPCTY="99"
|
122
|
+
CCCTY="99"
|
123
|
+
ECI="7"
|
124
|
+
CVCCheck="NO"
|
125
|
+
AAVCheck="NO"
|
126
|
+
VC="NO"
|
127
|
+
amount="1"
|
128
|
+
currency="EUR"
|
129
|
+
PM="CreditCard"
|
130
|
+
BRAND="VISA">
|
131
|
+
</ncresponse>
|
132
|
+
END
|
133
|
+
end
|
134
|
+
|
135
|
+
def successful_purchase_response
|
136
|
+
<<-END
|
137
|
+
<?xml version="1.0"?><ncresponse
|
138
|
+
orderID="1233680882919266242708828"
|
139
|
+
PAYID="3014726"
|
140
|
+
NCSTATUS="0"
|
141
|
+
NCERROR="0"
|
142
|
+
NCERRORPLUS="!"
|
143
|
+
ACCEPTANCE="test123"
|
144
|
+
STATUS="5"
|
145
|
+
IPCTY="99"
|
146
|
+
CCCTY="99"
|
147
|
+
ECI="7"
|
148
|
+
CVCCheck="NO"
|
149
|
+
AAVCheck="NO"
|
150
|
+
VC="NO"
|
151
|
+
amount="1"
|
152
|
+
currency="EUR"
|
153
|
+
PM="CreditCard"
|
154
|
+
BRAND="VISA">
|
155
|
+
</ncresponse>
|
156
|
+
END
|
157
|
+
end
|
158
|
+
|
159
|
+
def failed_purchase_response
|
160
|
+
<<-END
|
161
|
+
<?xml version="1.0"?>
|
162
|
+
<ncresponse
|
163
|
+
orderID=""
|
164
|
+
PAYID="0"
|
165
|
+
NCSTATUS="5"
|
166
|
+
NCERROR="50001111"
|
167
|
+
NCERRORPLUS=" no orderid"
|
168
|
+
ACCEPTANCE=""
|
169
|
+
STATUS="0"
|
170
|
+
amount=""
|
171
|
+
currency="EUR"
|
172
|
+
PM=""
|
173
|
+
BRAND="">
|
174
|
+
</ncresponse>
|
175
|
+
END
|
176
|
+
end
|
177
|
+
|
178
|
+
def successful_capture_response
|
179
|
+
<<-END
|
180
|
+
<?xml version="1.0"?>
|
181
|
+
<ncresponse
|
182
|
+
orderID="1234956106974734203514539"
|
183
|
+
PAYID="3048326"
|
184
|
+
PAYIDSUB="1"
|
185
|
+
NCSTATUS="0"
|
186
|
+
NCERROR="0"
|
187
|
+
NCERRORPLUS="!"
|
188
|
+
ACCEPTANCE=""
|
189
|
+
STATUS="91"
|
190
|
+
amount="1"
|
191
|
+
currency="EUR">
|
192
|
+
</ncresponse>
|
193
|
+
END
|
194
|
+
end
|
195
|
+
|
196
|
+
def successful_void_response
|
197
|
+
<<-END
|
198
|
+
<?xml version="1.0"?>
|
199
|
+
<ncresponse
|
200
|
+
orderID="1234961140253559268757474"
|
201
|
+
PAYID="3048606"
|
202
|
+
PAYIDSUB="1"
|
203
|
+
NCSTATUS="0"
|
204
|
+
NCERROR="0"
|
205
|
+
NCERRORPLUS="!"
|
206
|
+
ACCEPTANCE=""
|
207
|
+
STATUS="61"
|
208
|
+
amount="1"
|
209
|
+
currency="EUR">
|
210
|
+
</ncresponse>
|
211
|
+
END
|
212
|
+
end
|
213
|
+
|
214
|
+
def successful_referenced_credit_response
|
215
|
+
<<-END
|
216
|
+
<?xml version="1.0"?>
|
217
|
+
<ncresponse
|
218
|
+
orderID="1234976251872867104376350"
|
219
|
+
PAYID="3049652"
|
220
|
+
PAYIDSUB="1"
|
221
|
+
NCSTATUS="0"
|
222
|
+
NCERROR="0"
|
223
|
+
NCERRORPLUS="!"
|
224
|
+
ACCEPTANCE=""
|
225
|
+
STATUS="81"
|
226
|
+
amount="1"
|
227
|
+
currency="EUR">
|
228
|
+
</ncresponse>
|
229
|
+
END
|
230
|
+
end
|
231
|
+
|
232
|
+
def successful_unreferenced_credit_response
|
233
|
+
<<-END
|
234
|
+
<?xml version="1.0"?><ncresponse
|
235
|
+
orderID="1234976330656672481134758"
|
236
|
+
PAYID="3049654"
|
237
|
+
NCSTATUS="0"
|
238
|
+
NCERROR="0"
|
239
|
+
NCERRORPLUS="!"
|
240
|
+
ACCEPTANCE=""
|
241
|
+
STATUS="81"
|
242
|
+
IPCTY="99"
|
243
|
+
CCCTY="99"
|
244
|
+
ECI="7"
|
245
|
+
CVCCheck="NO"
|
246
|
+
AAVCheck="NO"
|
247
|
+
VC="NO"
|
248
|
+
amount="1"
|
249
|
+
currency="EUR"
|
250
|
+
PM="CreditCard"
|
251
|
+
BRAND="VISA">
|
252
|
+
</ncresponse>
|
253
|
+
END
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
@@ -30,6 +30,24 @@ class PaypalTest < Test::Unit::TestCase
|
|
30
30
|
assert response.test?
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_successful_reference_purchase
|
34
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
35
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
36
|
+
assert_instance_of Response, response
|
37
|
+
assert_success response
|
38
|
+
assert_equal '62U664727W5914806', response.authorization
|
39
|
+
|
40
|
+
ref_id = response.authorization
|
41
|
+
|
42
|
+
gateway2 = PaypalGateway.new(:login => 'cody', :password => 'test', :pem => 'PEM')
|
43
|
+
gateway2.expects(:ssl_post).returns(successful_reference_purchase_response)
|
44
|
+
assert response = gateway2.purchase(@amount, ref_id, @options)
|
45
|
+
assert_instance_of Response, response
|
46
|
+
assert_success response
|
47
|
+
assert_equal '62U664727W5915049', response.authorization
|
48
|
+
assert response.test?
|
49
|
+
end
|
50
|
+
|
33
51
|
def test_failed_purchase
|
34
52
|
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
35
53
|
|
@@ -252,6 +270,37 @@ class PaypalTest < Test::Unit::TestCase
|
|
252
270
|
RESPONSE
|
253
271
|
end
|
254
272
|
|
273
|
+
def successful_reference_purchase_response
|
274
|
+
<<-RESPONSE
|
275
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
276
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
|
277
|
+
<SOAP-ENV:Header>
|
278
|
+
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
|
279
|
+
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
|
280
|
+
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
|
281
|
+
<Username xsi:type="xs:string"/>
|
282
|
+
<Password xsi:type="xs:string"/>
|
283
|
+
<Subject xsi:type="xs:string"/>
|
284
|
+
</Credentials>
|
285
|
+
</RequesterCredentials>
|
286
|
+
</SOAP-ENV:Header>
|
287
|
+
<SOAP-ENV:Body id="_0">
|
288
|
+
<DoReferenceTransactionResponse xmlns="urn:ebay:api:PayPalAPI">
|
289
|
+
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-01-06T23:41:25Z</Timestamp>
|
290
|
+
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
|
291
|
+
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">fee61882e6f47</CorrelationID>
|
292
|
+
<Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
|
293
|
+
<Build xmlns="urn:ebay:apis:eBLBaseComponents">1.0006</Build>
|
294
|
+
<Amount xsi:type="cc:BasicAmountType" currencyID="USD">3.00</Amount>
|
295
|
+
<AVSCode xsi:type="xs:string">X</AVSCode>
|
296
|
+
<CVV2Code xsi:type="xs:string">M</CVV2Code>
|
297
|
+
<TransactionID>62U664727W5915049</TransactionID>
|
298
|
+
</DoReferenceTransactionResponse>
|
299
|
+
</SOAP-ENV:Body>
|
300
|
+
</SOAP-ENV:Envelope>
|
301
|
+
RESPONSE
|
302
|
+
end
|
303
|
+
|
255
304
|
def failed_purchase_response
|
256
305
|
<<-RESPONSE
|
257
306
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SagePayTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@gateway = SagePayGateway.new(
|
6
|
+
:login => 'X'
|
7
|
+
)
|
8
|
+
|
9
|
+
@credit_card = credit_card('4242424242424242', :type => 'visa')
|
10
|
+
@options = {
|
11
|
+
:billing_address => {
|
12
|
+
:name => 'Tekin Suleyman',
|
13
|
+
:address1 => 'Flat 10 Lapwing Court',
|
14
|
+
:address2 => 'West Didsbury',
|
15
|
+
:city => "Manchester",
|
16
|
+
:county => 'Greater Manchester',
|
17
|
+
:country => 'GB',
|
18
|
+
:zip => 'M20 2PS'
|
19
|
+
},
|
20
|
+
:order_id => '1',
|
21
|
+
:description => 'Store purchase',
|
22
|
+
:ip => '86.150.65.37',
|
23
|
+
:email => 'tekin@tekin.co.uk',
|
24
|
+
:phone => '0161 123 4567'
|
25
|
+
}
|
26
|
+
@amount = 100
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_successful_purchase
|
30
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
31
|
+
|
32
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
33
|
+
assert_instance_of Response, response
|
34
|
+
assert_equal "1;B8AE1CF6-9DEF-C876-1BB4-9B382E6CE520;4193753;OHMETD7DFK;purchase", response.authorization
|
35
|
+
assert_success response
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_unsuccessful_purchase
|
39
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
40
|
+
|
41
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
42
|
+
assert_instance_of Response, response
|
43
|
+
assert_failure response
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_response_requires_three_d_secure_authentication
|
47
|
+
@gateway.stubs(:ssl_post).returns(three_d_secure_response)
|
48
|
+
|
49
|
+
response = @gateway.purchase(100, @credit_card, @options)
|
50
|
+
assert_failure response
|
51
|
+
assert response.three_d_secure?
|
52
|
+
|
53
|
+
assert_equal 'eJxVUttygjAQfe9XMH4AuUCoOGscW9sRx7ZM7UsfmZAWVEBDUPr3TRCqzdOes5uzuyeBWVvsnZNUdV6V0xFx8WjG7+AjU1IuNlI0SnJ4kXWdfEsnT6cjign1mH8fMC8MKSMMeyMO8fxdHjn0OtzIuATQAI2AEllSag6JOD5Er5yRceD7gHoIhVTRgjMcMi8ICb4cQBcayqSQfKOlSspd5ax1CqijQFRNqdUPH9MA0ACgUXueaX2YIHQ+n926v+iKym12gGwa0HWkuLFRbeTaPOWRV7+VpyzX0Xr79bxdr0TytFx9Yr2YTwHZCkgTLTnFOMSU+g4hE8YmXgio4yEp7BycdAv0AA62x/w2c8uAsVnJUgyLDAhke6hKaSoooL8YUlkLHqtKt85LHJm+FgO67vG4tEYLbbwj1uMusmK5sceMHXRqFgCytah/PtQ/tIn+fYBfp7GzSg==',
|
54
|
+
response.pa_req
|
55
|
+
assert_equal '2012354765399251503',
|
56
|
+
response.md
|
57
|
+
assert_equal 'https://ukvpstest.protx.com/mpitools/accesscontroler?action=pareq',
|
58
|
+
response.acs_url
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_supports_3d_secure
|
62
|
+
assert @gateway.supports_3d_secure
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_can_enable_3d_secure
|
66
|
+
assert !@gateway.three_d_secure_enabled?
|
67
|
+
@gateway2 = ProtxGateway.new(:login => 'X', :enable_3d_secure => true)
|
68
|
+
assert @gateway2.three_d_secure_enabled?
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_three_d_complete
|
72
|
+
@gateway.stubs(:ssl_post).returns(successful_purchase_response)
|
73
|
+
|
74
|
+
response = @gateway.three_d_complete('PARes VALUE','MD VALUE')
|
75
|
+
assert_success response
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_purchase_url
|
79
|
+
assert_equal 'https://test.sagepay.com/gateway/service/vspdirect-register.vsp', @gateway.send(:url_for, :purchase)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_capture_url
|
83
|
+
assert_equal 'https://test.sagepay.com/gateway/service/release.vsp', @gateway.send(:url_for, :capture)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_electron_cards
|
87
|
+
# Visa range
|
88
|
+
assert_no_match SagePayGateway::ELECTRON, '4245180000000000'
|
89
|
+
|
90
|
+
# First electron range
|
91
|
+
assert_match SagePayGateway::ELECTRON, '4245190000000000'
|
92
|
+
|
93
|
+
# Second range
|
94
|
+
assert_match SagePayGateway::ELECTRON, '4249620000000000'
|
95
|
+
assert_match SagePayGateway::ELECTRON, '4249630000000000'
|
96
|
+
|
97
|
+
# Third
|
98
|
+
assert_match SagePayGateway::ELECTRON, '4508750000000000'
|
99
|
+
|
100
|
+
# Fourth
|
101
|
+
assert_match SagePayGateway::ELECTRON, '4844060000000000'
|
102
|
+
assert_match SagePayGateway::ELECTRON, '4844080000000000'
|
103
|
+
|
104
|
+
# Fifth
|
105
|
+
assert_match SagePayGateway::ELECTRON, '4844110000000000'
|
106
|
+
assert_match SagePayGateway::ELECTRON, '4844550000000000'
|
107
|
+
|
108
|
+
# Sixth
|
109
|
+
assert_match SagePayGateway::ELECTRON, '4917300000000000'
|
110
|
+
assert_match SagePayGateway::ELECTRON, '4917590000000000'
|
111
|
+
|
112
|
+
# Seventh
|
113
|
+
assert_match SagePayGateway::ELECTRON, '4918800000000000'
|
114
|
+
|
115
|
+
# Visa
|
116
|
+
assert_no_match SagePayGateway::ELECTRON, '4918810000000000'
|
117
|
+
|
118
|
+
# 19 PAN length
|
119
|
+
assert_match SagePayGateway::ELECTRON, '4249620000000000000'
|
120
|
+
|
121
|
+
# 20 PAN length
|
122
|
+
assert_no_match SagePayGateway::ELECTRON, '42496200000000000'
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_avs_result
|
126
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
127
|
+
|
128
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
129
|
+
assert_equal 'Y', response.avs_result['postal_match']
|
130
|
+
assert_equal 'N', response.avs_result['street_match']
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_cvv_result
|
134
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
135
|
+
|
136
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
137
|
+
assert_equal 'N', response.cvv_result['code']
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def successful_purchase_response
|
143
|
+
<<-RESP
|
144
|
+
VPSProtocol=2.23
|
145
|
+
Status=OK
|
146
|
+
StatusDetail=0000 : The Authorisation was Successful.
|
147
|
+
VPSTxId=B8AE1CF6-9DEF-C876-1BB4-9B382E6CE520
|
148
|
+
SecurityKey=OHMETD7DFK
|
149
|
+
TxAuthNo=4193753
|
150
|
+
AVSCV2=NO DATA MATCHES
|
151
|
+
AddressResult=NOTMATCHED
|
152
|
+
PostCodeResult=MATCHED
|
153
|
+
CV2Result=NOTMATCHED
|
154
|
+
3DSecureStatus=NOTCHECKED
|
155
|
+
RESP
|
156
|
+
end
|
157
|
+
|
158
|
+
def unsuccessful_purchase_response
|
159
|
+
<<-RESP
|
160
|
+
VPSProtocol=2.23
|
161
|
+
Status=NOTAUTHED
|
162
|
+
StatusDetail=VSP Direct transaction from VSP Simulator.
|
163
|
+
VPSTxId=7BBA9078-8489-48CD-BF0D-10B0E6B0EF30
|
164
|
+
SecurityKey=DKDYLDYLXV
|
165
|
+
AVSCV2=ALL MATCH
|
166
|
+
AddressResult=MATCHED
|
167
|
+
PostCodeResult=MATCHED
|
168
|
+
CV2Result=MATCHED
|
169
|
+
RESP
|
170
|
+
end
|
171
|
+
|
172
|
+
def three_d_secure_response
|
173
|
+
<<-RESP
|
174
|
+
Status=3DAUTH
|
175
|
+
MD=2012354765399251503
|
176
|
+
ACSURL=https://ukvpstest.protx.com/mpitools/accesscontroler?action=pareq
|
177
|
+
PAReq=eJxVUttygjAQfe9XMH4AuUCoOGscW9sRx7ZM7UsfmZAWVEBDUPr3TRCqzdOes5uzuyeBWVvsnZNUdV6V0xFx8WjG7+AjU1IuNlI0SnJ4kXWdfEsnT6cjign1mH8fMC8MKSMMeyMO8fxdHjn0OtzIuATQAI2AEllSag6JOD5Er5yRceD7gHoIhVTRgjMcMi8ICb4cQBcayqSQfKOlSspd5ax1CqijQFRNqdUPH9MA0ACgUXueaX2YIHQ+n926v+iKym12gGwa0HWkuLFRbeTaPOWRV7+VpyzX0Xr79bxdr0TytFx9Yr2YTwHZCkgTLTnFOMSU+g4hE8YmXgio4yEp7BycdAv0AA62x/w2c8uAsVnJUgyLDAhke6hKaSoooL8YUlkLHqtKt85LHJm+FgO67vG4tEYLbbwj1uMusmK5sceMHXRqFgCytah/PtQ/tIn+fYBfp7GzSg==
|
178
|
+
StatusDetail=2007 : Please redirect your customer to the ACSURL, passing the MD and PaReq.
|
179
|
+
VPSProtocol=2.22
|
180
|
+
3DSecureStatus=OK
|
181
|
+
RESP
|
182
|
+
end
|
183
|
+
end
|