activemerchant 1.3.2 → 1.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.
Files changed (85) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +58 -0
  3. data/CONTRIBUTERS +25 -0
  4. data/MIT-LICENSE +3 -3
  5. data/README +16 -10
  6. data/Rakefile +4 -3
  7. data/lib/active_merchant.rb +7 -1
  8. data/lib/active_merchant/billing/check.rb +16 -9
  9. data/lib/active_merchant/billing/gateway.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +702 -0
  11. data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
  13. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
  14. data/lib/active_merchant/billing/gateways/braintree.rb +10 -1
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +26 -2
  16. data/lib/active_merchant/billing/gateways/data_cash.rb +255 -59
  17. data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
  18. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
  19. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -0
  20. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +2 -2
  21. data/lib/active_merchant/billing/gateways/payflow_express.rb +3 -11
  22. data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
  23. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +39 -21
  24. data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
  25. data/lib/active_merchant/billing/gateways/paypal_express.rb +3 -12
  26. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
  27. data/lib/active_merchant/billing/gateways/protx.rb +25 -25
  28. data/lib/active_merchant/billing/gateways/sage.rb +145 -0
  29. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
  30. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
  31. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
  32. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -1
  33. data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -0
  34. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/wirecard.rb +304 -0
  36. data/lib/active_merchant/billing/integrations.rb +8 -2
  37. data/lib/active_merchant/billing/integrations/action_view_helper.rb +18 -4
  38. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +4 -2
  39. data/lib/active_merchant/billing/integrations/notification.rb +10 -1
  40. data/lib/active_merchant/lib/posts_data.rb +12 -3
  41. data/script/destroy +0 -0
  42. data/script/generate +0 -0
  43. data/test/extra/binding_of_caller.rb +0 -0
  44. data/test/extra/breakpoint.rb +0 -0
  45. data/test/fixtures.yml +24 -0
  46. data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
  47. data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
  48. data/test/remote/gateways/remote_beanstream_test.rb +150 -0
  49. data/test/remote/gateways/remote_braintree_test.rb +22 -0
  50. data/test/remote/gateways/remote_cyber_source_test.rb +28 -3
  51. data/test/remote/gateways/remote_data_cash_test.rb +250 -48
  52. data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
  53. data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
  54. data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
  55. data/test/remote/gateways/remote_sage_test.rb +87 -0
  56. data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
  57. data/test/remote/gateways/remote_wirecard_test.rb +76 -0
  58. data/test/remote/integrations/remote_paypal_integration_test.rb +15 -3
  59. data/test/test_helper.rb +31 -13
  60. data/test/unit/check_test.rb +14 -2
  61. data/test/unit/credit_card_methods_test.rb +18 -0
  62. data/test/unit/gateways/authorize_net_cim_test.rb +641 -0
  63. data/test/unit/gateways/beanstream_interac_test.rb +51 -0
  64. data/test/unit/gateways/beanstream_test.rb +108 -0
  65. data/test/unit/gateways/braintree_test.rb +2 -5
  66. data/test/unit/gateways/cyber_source_test.rb +18 -0
  67. data/test/unit/gateways/data_cash_test.rb +32 -4
  68. data/test/unit/gateways/gateway_test.rb +8 -1
  69. data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
  70. data/test/unit/gateways/net_registry_test.rb +6 -0
  71. data/test/unit/gateways/payflow_express_test.rb +18 -2
  72. data/test/unit/gateways/paypal_express_test.rb +154 -0
  73. data/test/unit/gateways/paypal_test.rb +140 -0
  74. data/test/unit/gateways/sage_bankcard_test.rb +162 -0
  75. data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
  76. data/test/unit/gateways/secure_pay_au_test.rb +58 -1
  77. data/test/unit/gateways/skip_jack_test.rb +8 -0
  78. data/test/unit/gateways/verifi_test.rb +0 -1
  79. data/test/unit/gateways/wirecard_test.rb +232 -0
  80. data/test/unit/integrations/action_view_helper_test.rb +3 -0
  81. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +23 -2
  82. data/test/unit/integrations/notifications/notification_test.rb +13 -0
  83. data/test/unit/posts_data_test.rb +20 -6
  84. metadata +40 -5
  85. metadata.gz.sig +0 -0
@@ -37,6 +37,12 @@ class NetRegistryTest < Test::Unit::TestCase
37
37
  response = @gateway.credit(@amount, '0707161858000000', @options)
38
38
  assert_success response
39
39
  end
40
+
41
+ def test_capture_without_credit_card_provided
42
+ assert_raise(ArgumentError) do
43
+ response = @gateway.capture(@amount, '0707161858000000', @options)
44
+ end
45
+ end
40
46
 
41
47
  def test_successful_authorization
42
48
  @gateway.stubs(:ssl_post).returns(successful_authorization_response)
@@ -1,6 +1,12 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class PayflowExpressTest < Test::Unit::TestCase
4
+ TEST_REDIRECT_URL = 'https://test-expresscheckout.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890'
5
+ LIVE_REDIRECT_URL = 'https://www.paypal.com/cgibin/webscr?cmd=_express-checkout&token=1234567890'
6
+
7
+ TEST_REDIRECT_URL_WITHOUT_REVIEW = "#{TEST_REDIRECT_URL}&useraction=commit"
8
+ LIVE_REDIRECT_URL_WITHOUT_REVIEW = "#{LIVE_REDIRECT_URL}&useraction=commit"
9
+
4
10
  def setup
5
11
  Base.gateway_mode = :test
6
12
 
@@ -53,11 +59,21 @@ class PayflowExpressTest < Test::Unit::TestCase
53
59
 
54
60
  def test_live_redirect_url
55
61
  Base.gateway_mode = :production
56
- assert_equal 'https://www.paypal.com/cgibin/webscr?cmd=_express-checkout&token=1234567890', @gateway.redirect_url_for('1234567890')
62
+ assert_equal LIVE_REDIRECT_URL, @gateway.redirect_url_for('1234567890')
57
63
  end
58
64
 
59
65
  def test_test_redirect_url
60
- assert_equal 'https://test-expresscheckout.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890', @gateway.redirect_url_for('1234567890')
66
+ assert_equal TEST_REDIRECT_URL, @gateway.redirect_url_for('1234567890')
67
+ end
68
+
69
+ def test_live_redirect_url_without_review
70
+ Base.gateway_mode = :production
71
+ assert_equal LIVE_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false)
72
+ end
73
+
74
+ def test_test_redirect_url_without_review
75
+ assert_equal :test, Base.gateway_mode
76
+ assert_equal TEST_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false)
61
77
  end
62
78
 
63
79
  def test_invalid_get_express_details_request
@@ -4,6 +4,9 @@ class PaypalExpressTest < Test::Unit::TestCase
4
4
  TEST_REDIRECT_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890'
5
5
  LIVE_REDIRECT_URL = 'https://www.paypal.com/cgibin/webscr?cmd=_express-checkout&token=1234567890'
6
6
 
7
+ TEST_REDIRECT_URL_WITHOUT_REVIEW = "#{TEST_REDIRECT_URL}&useraction=commit"
8
+ LIVE_REDIRECT_URL_WITHOUT_REVIEW = "#{LIVE_REDIRECT_URL}&useraction=commit"
9
+
7
10
  def setup
8
11
  @gateway = PaypalExpressGateway.new(
9
12
  :login => 'cody',
@@ -33,6 +36,11 @@ class PaypalExpressTest < Test::Unit::TestCase
33
36
  assert_equal LIVE_REDIRECT_URL, @gateway.redirect_url_for('1234567890')
34
37
  end
35
38
 
39
+ def test_live_redirect_url_without_review
40
+ Base.gateway_mode = :production
41
+ assert_equal LIVE_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false)
42
+ end
43
+
36
44
  def test_force_sandbox_redirect_url
37
45
  Base.gateway_mode = :production
38
46
 
@@ -52,6 +60,11 @@ class PaypalExpressTest < Test::Unit::TestCase
52
60
  assert_equal TEST_REDIRECT_URL, @gateway.redirect_url_for('1234567890')
53
61
  end
54
62
 
63
+ def test_test_redirect_url_without_review
64
+ assert_equal :test, Base.gateway_mode
65
+ assert_equal TEST_REDIRECT_URL_WITHOUT_REVIEW, @gateway.redirect_url_for('1234567890', :review => false)
66
+ end
67
+
55
68
  def test_get_express_details
56
69
  @gateway.expects(:ssl_post).returns(successful_details_response)
57
70
  response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
@@ -125,6 +138,36 @@ class PaypalExpressTest < Test::Unit::TestCase
125
138
  assert_equal 'ActiveMerchant_EC', REXML::XPath.first(xml, '//n2:ButtonSource').text
126
139
  end
127
140
 
141
+ def test_error_code_for_single_error
142
+ @gateway.expects(:ssl_post).returns(response_with_error)
143
+ response = @gateway.setup_authorization(100,
144
+ :return_url => 'http://example.com',
145
+ :cancel_return_url => 'http://example.com'
146
+ )
147
+ assert_equal "10736", response.params['error_codes']
148
+ end
149
+
150
+ def test_ensure_only_unique_error_codes
151
+ @gateway.expects(:ssl_post).returns(response_with_duplicate_errors)
152
+ response = @gateway.setup_authorization(100,
153
+ :return_url => 'http://example.com',
154
+ :cancel_return_url => 'http://example.com'
155
+ )
156
+
157
+ assert_equal "10736" , response.params['error_codes']
158
+ end
159
+
160
+ def test_error_codes_for_multiple_errors
161
+ @gateway.expects(:ssl_post).returns(response_with_errors)
162
+ response = @gateway.setup_authorization(100,
163
+ :return_url => 'http://example.com',
164
+ :cancel_return_url => 'http://example.com'
165
+ )
166
+
167
+ assert_equal ["10736", "10002"] , response.params['error_codes'].split(',')
168
+ end
169
+
170
+ private
128
171
  def successful_details_response
129
172
  <<-RESPONSE
130
173
  <?xml version='1.0' encoding='UTF-8'?>
@@ -225,4 +268,115 @@ class PaypalExpressTest < Test::Unit::TestCase
225
268
  </SOAP-ENV:Envelope>
226
269
  RESPONSE
227
270
  end
271
+
272
+ def response_with_error
273
+ <<-RESPONSE
274
+ <?xml version="1.0" encoding="UTF-8"?>
275
+ <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">
276
+ <SOAP-ENV:Header>
277
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
278
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
279
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
280
+ <Username xsi:type="xs:string"/>
281
+ <Password xsi:type="xs:string"/>
282
+ <Subject xsi:type="xs:string"/>
283
+ </Credentials>
284
+ </RequesterCredentials>
285
+ </SOAP-ENV:Header>
286
+ <SOAP-ENV:Body id="_0">
287
+ <SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
288
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-04-02T17:38:02Z</Timestamp>
289
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
290
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">cdb720feada30</CorrelationID>
291
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
292
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
293
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
294
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
295
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
296
+ </Errors>
297
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
298
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">543066</Build>
299
+ </SetExpressCheckoutResponse>
300
+ </SOAP-ENV:Body>
301
+ </SOAP-ENV:Envelope>
302
+ RESPONSE
303
+ end
304
+
305
+ def response_with_errors
306
+ <<-RESPONSE
307
+ <?xml version="1.0" encoding="UTF-8"?>
308
+ <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">
309
+ <SOAP-ENV:Header>
310
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
311
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
312
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
313
+ <Username xsi:type="xs:string"/>
314
+ <Password xsi:type="xs:string"/>
315
+ <Subject xsi:type="xs:string"/>
316
+ </Credentials>
317
+ </RequesterCredentials>
318
+ </SOAP-ENV:Header>
319
+ <SOAP-ENV:Body id="_0">
320
+ <SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
321
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-04-02T17:38:02Z</Timestamp>
322
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
323
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">cdb720feada30</CorrelationID>
324
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
325
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
326
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
327
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
328
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
329
+ </Errors>
330
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
331
+ <ShortMessage xsi:type="xs:string">Authentication/Authorization Failed</ShortMessage>
332
+ <LongMessage xsi:type="xs:string">You do not have permissions to make this API call</LongMessage>
333
+ <ErrorCode xsi:type="xs:token">10002</ErrorCode>
334
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
335
+ </Errors>
336
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
337
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">543066</Build>
338
+ </SetExpressCheckoutResponse>
339
+ </SOAP-ENV:Body>
340
+ </SOAP-ENV:Envelope>
341
+ RESPONSE
342
+ end
343
+
344
+ def response_with_duplicate_errors
345
+ <<-RESPONSE
346
+ <?xml version="1.0" encoding="UTF-8"?>
347
+ <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">
348
+ <SOAP-ENV:Header>
349
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
350
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
351
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
352
+ <Username xsi:type="xs:string"/>
353
+ <Password xsi:type="xs:string"/>
354
+ <Subject xsi:type="xs:string"/>
355
+ </Credentials>
356
+ </RequesterCredentials>
357
+ </SOAP-ENV:Header>
358
+ <SOAP-ENV:Body id="_0">
359
+ <SetExpressCheckoutResponse xmlns="urn:ebay:api:PayPalAPI">
360
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-04-02T17:38:02Z</Timestamp>
361
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
362
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">cdb720feada30</CorrelationID>
363
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
364
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
365
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
366
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
367
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
368
+ </Errors>
369
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
370
+ <ShortMessage xsi:type="xs:string">Shipping Address Invalid City State Postal Code</ShortMessage>
371
+ <LongMessage xsi:type="xs:string">A match of the Shipping Address City, State, and Postal Code failed.</LongMessage>
372
+ <ErrorCode xsi:type="xs:token">10736</ErrorCode>
373
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
374
+ </Errors>
375
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
376
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">543066</Build>
377
+ </SetExpressCheckoutResponse>
378
+ </SOAP-ENV:Body>
379
+ </SOAP-ENV:Envelope>
380
+ RESPONSE
381
+ end
228
382
  end
@@ -193,6 +193,33 @@ class PaypalTest < Test::Unit::TestCase
193
193
  assert_equal 'M', response.cvv_result['code']
194
194
  end
195
195
 
196
+ def test_fraud_review
197
+ @gateway.expects(:ssl_post).returns(fraud_review_response)
198
+
199
+ response = @gateway.purchase(@amount, @credit_card, @options)
200
+ assert_success response
201
+ assert_equal "SuccessWithWarning", response.params["ack"]
202
+ assert_equal "Payment Pending your review in Fraud Management Filters", response.message
203
+ assert response.fraud_review?
204
+ end
205
+
206
+ def test_failed_capture_due_to_pending_fraud_review
207
+ @gateway.expects(:ssl_post).returns(failed_capture_due_to_pending_fraud_review)
208
+
209
+ response = @gateway.capture(@amount, 'authorization')
210
+ assert_failure response
211
+ assert_equal "Transaction must be accepted in Fraud Management Filters before capture.", response.message
212
+ end
213
+
214
+ # This occurs when sufficient 3rd party API permissions are not present to make the call for the user
215
+ def test_authentication_failed_response
216
+ @gateway.expects(:ssl_post).returns(authentication_failed_response)
217
+ response = @gateway.purchase(@amount, @credit_card, @options)
218
+ assert_failure response
219
+ assert_equal "10002", response.params["error_codes"]
220
+ assert_equal "You do not have permissions to make this API call", response.message
221
+ end
222
+
196
223
  private
197
224
  def successful_purchase_response
198
225
  <<-RESPONSE
@@ -377,4 +404,117 @@ class PaypalTest < Test::Unit::TestCase
377
404
  </SOAP-ENV:Envelope>
378
405
  RESPONSE
379
406
  end
407
+
408
+ def fraud_review_response
409
+ <<-RESPONSE
410
+ <?xml version="1.0" encoding="UTF-8"?>
411
+ <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:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
412
+ <SOAP-ENV:Header>
413
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
414
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
415
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
416
+ <Username xsi:type="xs:string"/>
417
+ <Password xsi:type="xs:string"/>
418
+ <Signature xsi:type="xs:string">An5ns1Kso7MWUdW4ErQKJJJ4qi4-Azffuo82oMt-Cv9I8QTOs-lG5sAv</Signature>
419
+ <Subject xsi:type="xs:string"/>
420
+ </Credentials>
421
+ </RequesterCredentials>
422
+ </SOAP-ENV:Header>
423
+ <SOAP-ENV:Body id="_0">
424
+ <DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
425
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-07-04T19:27:39Z</Timestamp>
426
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">SuccessWithWarning</Ack>
427
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">205d8397e7ed</CorrelationID>
428
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
429
+ <ShortMessage xsi:type="xs:string">Payment Pending your review in Fraud Management Filters</ShortMessage>
430
+ <LongMessage xsi:type="xs:string">Payment Pending your review in Fraud Management Filters</LongMessage>
431
+ <ErrorCode xsi:type="xs:token">11610</ErrorCode>
432
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Warning</SeverityCode>
433
+ </Errors>
434
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">50.0</Version>
435
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">623197</Build>
436
+ <Amount xsi:type="cc:BasicAmountType" currencyID="USD">1500.00</Amount>
437
+ <AVSCode xsi:type="xs:string">X</AVSCode>
438
+ <CVV2Code xsi:type="xs:string">M</CVV2Code>
439
+ <TransactionID>5V117995ER6796022</TransactionID>
440
+ </DoDirectPaymentResponse>
441
+ </SOAP-ENV:Body>
442
+ </SOAP-ENV:Envelope>
443
+ RESPONSE
444
+ end
445
+
446
+ def failed_capture_due_to_pending_fraud_review
447
+ <<-RESPONSE
448
+ <?xml version="1.0" encoding="UTF-8"?>
449
+ <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">
450
+ <SOAP-ENV:Header>
451
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
452
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
453
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
454
+ <Username xsi:type="xs:string"/>
455
+ <Password xsi:type="xs:string"/>
456
+ <Subject xsi:type="xs:string"/>
457
+ </Credentials>
458
+ </RequesterCredentials>
459
+ </SOAP-ENV:Header>
460
+ <SOAP-ENV:Body id="_0">
461
+ <DoCaptureResponse xmlns="urn:ebay:api:PayPalAPI">
462
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-07-04T21:45:35Z</Timestamp>
463
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
464
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">32a3855bd35b7</CorrelationID>
465
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
466
+ <ShortMessage xsi:type="xs:string">Transaction must be accepted in Fraud Management Filters before capture.</ShortMessage>
467
+ <LongMessage xsi:type="xs:string"/>
468
+ <ErrorCode xsi:type="xs:token">11612</ErrorCode>
469
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
470
+ </Errors>
471
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">52.000000</Version>
472
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">588340</Build>
473
+ <DoCaptureResponseDetails xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:DoCaptureResponseDetailsType">
474
+ <PaymentInfo xsi:type="ebl:PaymentInfoType">
475
+ <TransactionType xsi:type="ebl:PaymentTransactionCodeType">none</TransactionType>
476
+ <PaymentType xsi:type="ebl:PaymentCodeType">none</PaymentType>
477
+ <PaymentStatus xsi:type="ebl:PaymentStatusCodeType">None</PaymentStatus>
478
+ <PendingReason xsi:type="ebl:PendingStatusCodeType">none</PendingReason>
479
+ <ReasonCode xsi:type="ebl:ReversalReasonCodeType">none</ReasonCode>
480
+ </PaymentInfo>
481
+ </DoCaptureResponseDetails>
482
+ </DoCaptureResponse>
483
+ </SOAP-ENV:Body>
484
+ </SOAP-ENV:Envelope>
485
+ RESPONSE
486
+ end
487
+
488
+ def authentication_failed_response
489
+ <<-RESPONSE
490
+ <?xml version="1.0" encoding="UTF-8"?>
491
+ <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">
492
+ <SOAP-ENV:Header>
493
+ <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
494
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
495
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
496
+ <Username xsi:type="xs:string"/>
497
+ <Password xsi:type="xs:string"/>
498
+ <Subject xsi:type="xs:string"/>
499
+ </Credentials>
500
+ </RequesterCredentials>
501
+ </SOAP-ENV:Header>
502
+ <SOAP-ENV:Body id="_0">
503
+ <DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
504
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-08-12T19:40:59Z</Timestamp>
505
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
506
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">b874109bfd11</CorrelationID>
507
+ <Errors xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:ErrorType">
508
+ <ShortMessage xsi:type="xs:string">Authentication/Authorization Failed</ShortMessage>
509
+ <LongMessage xsi:type="xs:string">You do not have permissions to make this API call</LongMessage>
510
+ <ErrorCode xsi:type="xs:token">10002</ErrorCode>
511
+ <SeverityCode xmlns="urn:ebay:apis:eBLBaseComponents">Error</SeverityCode>
512
+ </Errors>
513
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">52.000000</Version>
514
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">628921</Build>
515
+ </DoDirectPaymentResponse>
516
+ </SOAP-ENV:Body>
517
+ </SOAP-ENV:Envelope>
518
+ RESPONSE
519
+ end
380
520
  end
@@ -0,0 +1,162 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class SageBankcardGatewayTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = SageBankcardGateway.new(
6
+ :login => 'login',
7
+ :password => 'password'
8
+ )
9
+
10
+ @credit_card = credit_card
11
+ @amount = 100
12
+
13
+ @options = {
14
+ :order_id => '1',
15
+ :billing_address => address,
16
+ :description => 'Store Purchase'
17
+ }
18
+ end
19
+
20
+ def test_successful_authorization
21
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
22
+
23
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
24
+ assert_instance_of Response, response
25
+ assert_success response
26
+
27
+ assert_equal "APPROVED", response.message
28
+ assert_equal "1234567890;bankcard", response.authorization
29
+
30
+ assert_equal "A", response.params["success"]
31
+ assert_equal "911911", response.params["code"]
32
+ assert_equal "APPROVED", response.params["message"]
33
+ assert_equal "00", response.params["front_end"]
34
+ assert_equal "M", response.params["cvv_result"]
35
+ assert_equal "X", response.params["avs_result"]
36
+ assert_equal "00", response.params["risk"]
37
+ assert_equal "1234567890", response.params["reference"]
38
+ assert_equal "1000", response.params["order_number"]
39
+ assert_equal "0", response.params["recurring"]
40
+ end
41
+
42
+ def test_successful_purchase
43
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
44
+
45
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
46
+ assert_instance_of Response, response
47
+ assert_success response
48
+
49
+ assert_equal "APPROVED 000001", response.message
50
+ assert_equal "B5O89VPdf0;bankcard", response.authorization
51
+
52
+ assert_equal "A", response.params["success"]
53
+ assert_equal "000001", response.params["code"]
54
+ assert_equal "APPROVED 000001", response.params["message"]
55
+ assert_equal "10", response.params["front_end"]
56
+ assert_equal "M", response.params["cvv_result"]
57
+ assert_equal "", response.params["avs_result"]
58
+ assert_equal "00", response.params["risk"]
59
+ assert_equal "B5O89VPdf0", response.params["reference"]
60
+ assert_equal "e81cab9e6144a160da82", response.params["order_number"]
61
+ assert_equal "0", response.params["recurring"]
62
+ end
63
+
64
+ def test_declined_purchase
65
+ @gateway.expects(:ssl_post).returns(declined_purchase_response)
66
+
67
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
68
+ assert_failure response
69
+ assert response.test?
70
+ assert_equal "DECLINED", response.message
71
+ assert_equal "A5O89kkix0;bankcard", response.authorization
72
+
73
+ assert_equal "E", response.params["success"]
74
+ assert_equal "000002", response.params["code"]
75
+ assert_equal "DECLINED", response.params["message"]
76
+ assert_equal "10", response.params["front_end"]
77
+ assert_equal "N", response.params["cvv_result"]
78
+ assert_equal "", response.params["avs_result"]
79
+ assert_equal "00", response.params["risk"]
80
+ assert_equal "A5O89kkix0", response.params["reference"]
81
+ assert_equal "3443d6426188f8256b8f", response.params["order_number"]
82
+ assert_equal "0", response.params["recurring"]
83
+ end
84
+
85
+ def test_successful_capture
86
+ @gateway.expects(:ssl_post).returns(successful_capture_response)
87
+
88
+ assert response = @gateway.capture(@amount, "A5O89kkix0")
89
+ assert_instance_of Response, response
90
+ assert_success response
91
+
92
+ assert_equal "APPROVED 000001", response.message
93
+ assert_equal "B5O8AdFhu0;bankcard", response.authorization
94
+
95
+ assert_equal "A", response.params["success"]
96
+ assert_equal "000001", response.params["code"]
97
+ assert_equal "APPROVED 000001", response.params["message"]
98
+ assert_equal "10", response.params["front_end"]
99
+ assert_equal "P", response.params["cvv_result"]
100
+ assert_equal "", response.params["avs_result"]
101
+ assert_equal "00", response.params["risk"]
102
+ assert_equal "B5O8AdFhu0", response.params["reference"]
103
+ assert_equal "ID5O8AdFhw", response.params["order_number"]
104
+ assert_equal "0", response.params["recurring"]
105
+ end
106
+
107
+ def test_invalid_login
108
+ @gateway.expects(:ssl_post).returns(invalid_login_response)
109
+
110
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
111
+ assert_failure response
112
+ assert response.test?
113
+ assert_equal "SECURITY VIOLATION", response.message
114
+ assert_equal "0000000000;bankcard", response.authorization
115
+
116
+ assert_equal "X", response.params["success"]
117
+ assert_equal "911911", response.params["code"]
118
+ assert_equal "SECURITY VIOLATION", response.params["message"]
119
+ assert_equal "00", response.params["front_end"]
120
+ assert_equal "P", response.params["cvv_result"]
121
+ assert_equal "", response.params["avs_result"]
122
+ assert_equal "00", response.params["risk"]
123
+ assert_equal "0000000000", response.params["reference"]
124
+ assert_equal "", response.params["order_number"]
125
+ assert_equal "0", response.params["recurring"]
126
+ end
127
+
128
+ def test_avs_result
129
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
130
+
131
+ response = @gateway.purchase(@amount, @credit_card, @options)
132
+ assert_equal 'X', response.avs_result['code']
133
+ end
134
+
135
+ def test_cvv_result
136
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
137
+
138
+ response = @gateway.purchase(@amount, @credit_card, @options)
139
+ assert_equal 'M', response.cvv_result['code']
140
+ end
141
+
142
+ private
143
+ def successful_authorization_response
144
+ "\002A911911APPROVED 00MX001234567890\0341000\0340\034\003"
145
+ end
146
+
147
+ def successful_purchase_response
148
+ "\002A000001APPROVED 000001 10M 00B5O89VPdf0\034e81cab9e6144a160da82\0340\034\003"
149
+ end
150
+
151
+ def successful_capture_response
152
+ "\002A000001APPROVED 000001 10P 00B5O8AdFhu0\034ID5O8AdFhw\0340\034\003"
153
+ end
154
+
155
+ def declined_purchase_response
156
+ "\002E000002DECLINED 10N 00A5O89kkix0\0343443d6426188f8256b8f\0340\034\003"
157
+ end
158
+
159
+ def invalid_login_response
160
+ "\002X911911SECURITY VIOLATION 00P 000000000000\034\0340\034\003"
161
+ end
162
+ end