activemerchant 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +78 -0
  3. data/{CONTRIBUTERS → CONTRIBUTORS} +44 -0
  4. data/{README → README.rdoc} +4 -1
  5. data/Rakefile +7 -13
  6. data/lib/active_merchant.rb +11 -21
  7. data/lib/active_merchant/billing/avs_result.rb +13 -10
  8. data/lib/active_merchant/billing/base.rb +2 -2
  9. data/lib/active_merchant/billing/check.rb +1 -1
  10. data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
  11. data/lib/active_merchant/billing/expiry_date.rb +10 -4
  12. data/lib/active_merchant/billing/gateway.rb +7 -6
  13. data/lib/active_merchant/billing/gateways.rb +18 -3
  14. data/lib/active_merchant/billing/gateways/authorize_net.rb +20 -12
  15. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +40 -6
  16. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig +736 -0
  17. data/lib/active_merchant/billing/gateways/braintree.rb +6 -211
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +5 -7
  19. data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +7 -2
  21. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  22. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  23. data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
  24. data/lib/active_merchant/billing/gateways/linkpoint.rb +65 -12
  25. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  26. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  27. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +12 -6
  28. data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
  29. data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
  30. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +20 -32
  34. data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  36. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/psl_card.rb +4 -6
  38. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +7 -1
  39. data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +60 -35
  40. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  41. data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
  42. data/lib/active_merchant/billing/gateways/skip_jack.rb +23 -10
  43. data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
  44. data/lib/active_merchant/billing/gateways/transax.rb +25 -0
  45. data/lib/active_merchant/billing/gateways/viaklix.rb +38 -14
  46. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -2
  47. data/lib/active_merchant/billing/integrations.rb +18 -11
  48. data/lib/active_merchant/billing/integrations/bogus.rb +4 -3
  49. data/lib/active_merchant/billing/integrations/chronopay.rb +4 -3
  50. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +3 -1
  51. data/lib/active_merchant/billing/integrations/gestpay.rb +4 -5
  52. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +3 -1
  53. data/lib/active_merchant/billing/integrations/hi_trust.rb +4 -3
  54. data/lib/active_merchant/billing/integrations/nochex.rb +4 -3
  55. data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
  56. data/lib/active_merchant/billing/integrations/paypal.rb +3 -4
  57. data/lib/active_merchant/billing/integrations/paypal/helper.rb +9 -8
  58. data/lib/active_merchant/billing/integrations/quickpay.rb +2 -3
  59. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +1 -1
  60. data/lib/active_merchant/billing/integrations/two_checkout.rb +3 -3
  61. data/lib/active_merchant/lib/connection.rb +170 -0
  62. data/lib/active_merchant/lib/country.rb +4 -1
  63. data/lib/active_merchant/lib/posts_data.rb +22 -84
  64. data/test/fixtures.yml +39 -1
  65. data/test/remote/gateways/remote_authorize_net_cim_test.rb +2 -1
  66. data/test/remote/gateways/remote_authorize_net_test.rb +1 -1
  67. data/test/remote/gateways/remote_beanstream_interac_test.rb +1 -1
  68. data/test/remote/gateways/remote_beanstream_test.rb +1 -1
  69. data/test/remote/gateways/remote_braintree_test.rb +2 -9
  70. data/test/remote/gateways/remote_card_stream_test.rb +1 -1
  71. data/test/remote/gateways/remote_cyber_source_test.rb +1 -1
  72. data/test/remote/gateways/remote_data_cash_test.rb +1 -2
  73. data/test/remote/gateways/remote_efsnet_test.rb +1 -1
  74. data/test/remote/gateways/remote_elavon_test.rb +66 -0
  75. data/test/remote/gateways/remote_eway_test.rb +1 -1
  76. data/test/remote/gateways/remote_exact_test.rb +1 -1
  77. data/test/remote/gateways/remote_first_pay_test.rb +87 -0
  78. data/test/remote/gateways/remote_instapay_test.rb +61 -0
  79. data/test/remote/gateways/remote_jetpay_test.rb +103 -0
  80. data/test/remote/gateways/remote_linkpoint_test.rb +11 -2
  81. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
  82. data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
  83. data/test/remote/gateways/remote_modern_payments_cim_test.rb +1 -1
  84. data/test/remote/gateways/remote_modern_payments_test.rb +23 -9
  85. data/test/remote/gateways/remote_moneris_test.rb +1 -1
  86. data/test/remote/gateways/remote_net_registry_test.rb +1 -1
  87. data/test/remote/gateways/remote_netbilling_test.rb +1 -1
  88. data/test/remote/gateways/remote_ogone_test.rb +115 -0
  89. data/test/remote/gateways/remote_pay_junction_test.rb +1 -1
  90. data/test/remote/gateways/remote_pay_secure_test.rb +1 -1
  91. data/test/remote/gateways/remote_payflow_express_test.rb +1 -1
  92. data/test/remote/gateways/remote_payflow_test.rb +1 -1
  93. data/test/remote/gateways/remote_payflow_uk_test.rb +1 -1
  94. data/test/remote/gateways/remote_payment_express_test.rb +17 -7
  95. data/test/remote/gateways/remote_paypal_express_test.rb +1 -1
  96. data/test/remote/gateways/remote_paypal_test.rb +26 -2
  97. data/test/remote/gateways/remote_plugnpay_test.rb +1 -1
  98. data/test/remote/gateways/remote_psigate_test.rb +1 -1
  99. data/test/remote/gateways/remote_psl_card_test.rb +1 -3
  100. data/test/remote/gateways/remote_quickpay_test.rb +1 -1
  101. data/test/remote/gateways/remote_realex_test.rb +1 -1
  102. data/test/remote/gateways/remote_sage_bankcard_test.rb +1 -1
  103. data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
  104. data/test/remote/gateways/remote_sage_test.rb +1 -1
  105. data/test/remote/gateways/remote_sage_virtual_check_test.rb +1 -1
  106. data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
  107. data/test/remote/gateways/remote_secure_pay_au_test.rb +1 -1
  108. data/test/remote/gateways/remote_secure_pay_tech_test.rb +1 -1
  109. data/test/remote/gateways/remote_secure_pay_test.rb +2 -2
  110. data/test/remote/gateways/remote_skipjack_test.rb +1 -1
  111. data/test/remote/gateways/remote_trans_first_test.rb +1 -1
  112. data/test/remote/gateways/remote_transax_test.rb +112 -0
  113. data/test/remote/gateways/remote_trust_commerce_test.rb +1 -1
  114. data/test/remote/gateways/remote_usa_epay_test.rb +1 -1
  115. data/test/remote/gateways/remote_verifi_test.rb +1 -1
  116. data/test/remote/gateways/remote_viaklix_test.rb +1 -1
  117. data/test/remote/gateways/remote_wirecard_test.rb +34 -0
  118. data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
  119. data/test/remote/integrations/remote_paypal_integration_test.rb +1 -1
  120. data/test/test_helper.rb +81 -89
  121. data/test/unit/avs_result_test.rb +1 -1
  122. data/test/unit/base_test.rb +1 -2
  123. data/test/unit/check_test.rb +1 -1
  124. data/test/unit/connection_test.rb +129 -0
  125. data/test/unit/country_code_test.rb +1 -1
  126. data/test/unit/country_test.rb +1 -1
  127. data/test/unit/credit_card_formatting_test.rb +1 -1
  128. data/test/unit/credit_card_methods_test.rb +10 -1
  129. data/test/unit/credit_card_test.rb +1 -1
  130. data/test/unit/cvv_result_test.rb +1 -1
  131. data/test/unit/expiry_date_test.rb +13 -2
  132. data/test/unit/gateways/authorize_net_cim_test.rb +39 -1
  133. data/test/unit/gateways/authorize_net_test.rb +1 -1
  134. data/test/unit/gateways/beanstream_interac_test.rb +1 -1
  135. data/test/unit/gateways/beanstream_test.rb +1 -1
  136. data/test/unit/gateways/bogus_test.rb +1 -1
  137. data/test/unit/gateways/braintree_test.rb +16 -14
  138. data/test/unit/gateways/card_stream_test.rb +1 -1
  139. data/test/unit/gateways/cyber_source_test.rb +1 -1
  140. data/test/unit/gateways/data_cash_test.rb +2 -1
  141. data/test/unit/gateways/efsnet_test.rb +1 -1
  142. data/test/unit/gateways/elavon_test.rb +139 -0
  143. data/test/unit/gateways/eway_test.rb +1 -1
  144. data/test/unit/gateways/exact_test.rb +1 -1
  145. data/test/unit/gateways/first_pay_test.rb +125 -0
  146. data/test/unit/gateways/gateway_test.rb +1 -1
  147. data/test/unit/gateways/instapay_test.rb +102 -0
  148. data/test/unit/gateways/jetpay_test.rb +185 -0
  149. data/test/unit/gateways/linkpoint_test.rb +37 -7
  150. data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
  151. data/test/unit/gateways/merchant_ware_test.rb +188 -0
  152. data/test/unit/gateways/modern_payments_cim_test.rb +25 -34
  153. data/test/unit/gateways/moneris_test.rb +1 -1
  154. data/test/unit/gateways/net_registry_test.rb +1 -1
  155. data/test/unit/gateways/netbilling_test.rb +1 -1
  156. data/test/unit/gateways/ogone_test.rb +319 -0
  157. data/test/unit/gateways/pay_junction_test.rb +1 -1
  158. data/test/unit/gateways/pay_secure_test.rb +1 -1
  159. data/test/unit/gateways/payflow_express_test.rb +2 -2
  160. data/test/unit/gateways/payflow_express_uk_test.rb +73 -1
  161. data/test/unit/gateways/payflow_test.rb +1 -1
  162. data/test/unit/gateways/payflow_uk_test.rb +1 -1
  163. data/test/unit/gateways/payment_express_test.rb +3 -3
  164. data/test/unit/gateways/paypal_express_test.rb +1 -1
  165. data/test/unit/gateways/paypal_test.rb +50 -1
  166. data/test/unit/gateways/plugnpay_test.rb +1 -1
  167. data/test/unit/gateways/psigate_test.rb +1 -1
  168. data/test/unit/gateways/psl_card_test.rb +1 -1
  169. data/test/unit/gateways/quickpay_test.rb +1 -1
  170. data/test/unit/gateways/realex_test.rb +1 -1
  171. data/test/unit/gateways/sage_bankcard_test.rb +36 -2
  172. data/test/unit/gateways/{protx_test.rb → sage_pay_test.rb} +49 -32
  173. data/test/unit/gateways/sage_virtual_check_test.rb +1 -1
  174. data/test/unit/gateways/sallie_mae_test.rb +53 -0
  175. data/test/unit/gateways/secure_pay_au_test.rb +1 -1
  176. data/test/unit/gateways/secure_pay_tech_test.rb +1 -1
  177. data/test/unit/gateways/secure_pay_test.rb +24 -10
  178. data/test/unit/gateways/skip_jack_test.rb +81 -1
  179. data/test/unit/gateways/trans_first_test.rb +1 -1
  180. data/test/unit/gateways/trust_commerce_test.rb +1 -1
  181. data/test/unit/gateways/usa_epay_test.rb +1 -1
  182. data/test/unit/gateways/verifi_test.rb +1 -1
  183. data/test/unit/gateways/viaklix_test.rb +1 -1
  184. data/test/unit/gateways/wirecard_test.rb +19 -1
  185. data/test/unit/generators/test_generator_helper.rb +1 -1
  186. data/test/unit/integrations/action_view_helper_test.rb +1 -1
  187. data/test/unit/integrations/bogus_module_test.rb +1 -1
  188. data/test/unit/integrations/chronopay_module_test.rb +1 -1
  189. data/test/unit/integrations/gestpay_module_test.rb +1 -1
  190. data/test/unit/integrations/helpers/bogus_helper_test.rb +1 -1
  191. data/test/unit/integrations/helpers/chronopay_helper_test.rb +1 -1
  192. data/test/unit/integrations/helpers/gestpay_helper_test.rb +1 -1
  193. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +1 -1
  194. data/test/unit/integrations/helpers/nochex_helper_test.rb +1 -1
  195. data/test/unit/integrations/helpers/paypal_helper_test.rb +11 -2
  196. data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
  197. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +1 -1
  198. data/test/unit/integrations/hi_trust_module_test.rb +1 -1
  199. data/test/unit/integrations/nochex_module_test.rb +1 -1
  200. data/test/unit/integrations/notifications/chronopay_notification_test.rb +1 -1
  201. data/test/unit/integrations/notifications/gestpay_notification_test.rb +1 -1
  202. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +1 -1
  203. data/test/unit/integrations/notifications/nochex_notification_test.rb +2 -2
  204. data/test/unit/integrations/notifications/notification_test.rb +1 -1
  205. data/test/unit/integrations/notifications/paypal_notification_test.rb +1 -1
  206. data/test/unit/integrations/notifications/quickpay_notification_test.rb +1 -1
  207. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +1 -1
  208. data/test/unit/integrations/paypal_module_test.rb +1 -1
  209. data/test/unit/integrations/quickpay_module_test.rb +1 -1
  210. data/test/unit/integrations/returns/chronopay_return_test.rb +1 -1
  211. data/test/unit/integrations/returns/gestpay_return_test.rb +1 -1
  212. data/test/unit/integrations/returns/hi_trust_return_test.rb +1 -1
  213. data/test/unit/integrations/returns/nochex_return_test.rb +1 -1
  214. data/test/unit/integrations/returns/paypal_return_test.rb +1 -1
  215. data/test/unit/integrations/returns/return_test.rb +1 -1
  216. data/test/unit/integrations/returns/two_checkout_return_test.rb +1 -1
  217. data/test/unit/integrations/two_checkout_module_test.rb +1 -1
  218. data/test/unit/post_data_test.rb +1 -1
  219. data/test/unit/posts_data_test.rb +14 -66
  220. data/test/unit/response_test.rb +1 -1
  221. data/test/unit/utils_test.rb +1 -1
  222. data/test/unit/validateable_test.rb +1 -1
  223. metadata +41 -45
  224. metadata.gz.sig +0 -0
  225. data/test/extra/binding_of_caller.rb +0 -80
  226. data/test/extra/breakpoint.rb +0 -547
  227. data/test/remote/gateways/remote_protx_test.rb +0 -184
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PayflowUkTest < Test::Unit::TestCase
4
4
  def setup
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PaymentExpressTest < Test::Unit::TestCase
4
4
  def setup
@@ -109,14 +109,14 @@ class PaymentExpressTest < Test::Unit::TestCase
109
109
  def test_avs_result_not_supported
110
110
  @gateway.expects(:ssl_post).returns(successful_authorization_response)
111
111
 
112
- response = @gateway.purchase(@amount, @credit_card, @options)
112
+ response = @gateway.purchase(@amount, @visa, @options)
113
113
  assert_nil response.avs_result['code']
114
114
  end
115
115
 
116
116
  def test_cvv_result_not_supported
117
117
  @gateway.expects(:ssl_post).returns(successful_authorization_response)
118
118
 
119
- response = @gateway.purchase(@amount, @credit_card, @options)
119
+ response = @gateway.purchase(@amount, @visa, @options)
120
120
  assert_nil response.cvv_result['code']
121
121
  end
122
122
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PaypalExpressTest < Test::Unit::TestCase
4
4
  TEST_REDIRECT_URL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890'
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PaypalTest < Test::Unit::TestCase
4
4
  def setup
@@ -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"?>
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PlugnpayTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PsigateTest < Test::Unit::TestCase
4
4
  def setup
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PslCardTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class QuickpayTest < Test::Unit::TestCase
4
4
  def setup
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
  require 'digest/sha1'
3
3
 
4
4
  class RealexTest < Test::Unit::TestCase
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class SageBankcardGatewayTest < Test::Unit::TestCase
4
4
  def setup
@@ -138,7 +138,41 @@ class SageBankcardGatewayTest < Test::Unit::TestCase
138
138
  response = @gateway.purchase(@amount, @credit_card, @options)
139
139
  assert_equal 'M', response.cvv_result['code']
140
140
  end
141
-
141
+
142
+ def test_us_address_with_state
143
+ post = {}
144
+ options = {
145
+ :billing_address => { :country => "US", :state => "CA"}
146
+ }
147
+ @gateway.send(:add_addresses, post, options)
148
+
149
+ assert_equal "US", post[:C_country]
150
+ assert_equal "CA", post[:C_state]
151
+ end
152
+
153
+ def test_us_address_without_state
154
+ post = {}
155
+ options = {
156
+ :billing_address => { :country => "US", :state => ""}
157
+ }
158
+ @gateway.send(:add_addresses, post, options)
159
+
160
+ assert_equal "US", post[:C_country]
161
+ assert_equal "", post[:C_state]
162
+ end
163
+
164
+
165
+ def test_international_address_without_state
166
+ post = {}
167
+ options = {
168
+ :billing_address => { :country => "JP", :state => ""}
169
+ }
170
+ @gateway.send(:add_addresses, post, options)
171
+
172
+ assert_equal "JP", post[:C_country]
173
+ assert_equal "Outside of United States", post[:C_state]
174
+ end
175
+
142
176
  private
143
177
  def successful_authorization_response
144
178
  "\002A911911APPROVED 00MX001234567890\0341000\0340\034\003"
@@ -1,21 +1,27 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
- class ProtxTest < Test::Unit::TestCase
3
+ class SagePayTest < Test::Unit::TestCase
4
4
  def setup
5
- @gateway = ProtxGateway.new(
5
+ @gateway = SagePayGateway.new(
6
6
  :login => 'X'
7
7
  )
8
8
 
9
9
  @credit_card = credit_card('4242424242424242', :type => 'visa')
10
10
  @options = {
11
11
  :billing_address => {
12
- :address1 => '25 The Larches',
13
- :city => "Narborough",
14
- :state => "Leicester",
15
- :zip => 'LE10 2RT'
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'
16
19
  },
17
20
  :order_id => '1',
18
- :description => 'Store purchase'
21
+ :description => 'Store purchase',
22
+ :ip => '86.150.65.37',
23
+ :email => 'tekin@tekin.co.uk',
24
+ :phone => '0161 123 4567'
19
25
  }
20
26
  @amount = 100
21
27
  end
@@ -25,7 +31,7 @@ class ProtxTest < Test::Unit::TestCase
25
31
 
26
32
  assert response = @gateway.purchase(@amount, @credit_card, @options)
27
33
  assert_instance_of Response, response
28
- assert_equal "1;{7307C8A9-766E-4BD1-AC41-3C34BB83F7E5};5559;WIUMDJS607", response.authorization
34
+ assert_equal "1;B8AE1CF6-9DEF-C876-1BB4-9B382E6CE520;4193753;OHMETD7DFK;purchase", response.authorization
29
35
  assert_success response
30
36
  end
31
37
 
@@ -38,50 +44,50 @@ class ProtxTest < Test::Unit::TestCase
38
44
  end
39
45
 
40
46
  def test_purchase_url
41
- assert_equal 'https://ukvpstest.protx.com/vspgateway/service/vspdirect-register.vsp', @gateway.send(:url_for, :purchase)
47
+ assert_equal 'https://test.sagepay.com/gateway/service/vspdirect-register.vsp', @gateway.send(:url_for, :purchase)
42
48
  end
43
49
 
44
50
  def test_capture_url
45
- assert_equal 'https://ukvpstest.protx.com/vspgateway/service/release.vsp', @gateway.send(:url_for, :capture)
51
+ assert_equal 'https://test.sagepay.com/gateway/service/release.vsp', @gateway.send(:url_for, :capture)
46
52
  end
47
53
 
48
54
  def test_electron_cards
49
55
  # Visa range
50
- assert_no_match ProtxGateway::ELECTRON, '4245180000000000'
56
+ assert_no_match SagePayGateway::ELECTRON, '4245180000000000'
51
57
 
52
58
  # First electron range
53
- assert_match ProtxGateway::ELECTRON, '4245190000000000'
59
+ assert_match SagePayGateway::ELECTRON, '4245190000000000'
54
60
 
55
61
  # Second range
56
- assert_match ProtxGateway::ELECTRON, '4249620000000000'
57
- assert_match ProtxGateway::ELECTRON, '4249630000000000'
62
+ assert_match SagePayGateway::ELECTRON, '4249620000000000'
63
+ assert_match SagePayGateway::ELECTRON, '4249630000000000'
58
64
 
59
65
  # Third
60
- assert_match ProtxGateway::ELECTRON, '4508750000000000'
66
+ assert_match SagePayGateway::ELECTRON, '4508750000000000'
61
67
 
62
68
  # Fourth
63
- assert_match ProtxGateway::ELECTRON, '4844060000000000'
64
- assert_match ProtxGateway::ELECTRON, '4844080000000000'
69
+ assert_match SagePayGateway::ELECTRON, '4844060000000000'
70
+ assert_match SagePayGateway::ELECTRON, '4844080000000000'
65
71
 
66
72
  # Fifth
67
- assert_match ProtxGateway::ELECTRON, '4844110000000000'
68
- assert_match ProtxGateway::ELECTRON, '4844550000000000'
73
+ assert_match SagePayGateway::ELECTRON, '4844110000000000'
74
+ assert_match SagePayGateway::ELECTRON, '4844550000000000'
69
75
 
70
76
  # Sixth
71
- assert_match ProtxGateway::ELECTRON, '4917300000000000'
72
- assert_match ProtxGateway::ELECTRON, '4917590000000000'
77
+ assert_match SagePayGateway::ELECTRON, '4917300000000000'
78
+ assert_match SagePayGateway::ELECTRON, '4917590000000000'
73
79
 
74
80
  # Seventh
75
- assert_match ProtxGateway::ELECTRON, '4918800000000000'
81
+ assert_match SagePayGateway::ELECTRON, '4918800000000000'
76
82
 
77
83
  # Visa
78
- assert_no_match ProtxGateway::ELECTRON, '4918810000000000'
84
+ assert_no_match SagePayGateway::ELECTRON, '4918810000000000'
79
85
 
80
86
  # 19 PAN length
81
- assert_match ProtxGateway::ELECTRON, '4249620000000000000'
87
+ assert_match SagePayGateway::ELECTRON, '4249620000000000000'
82
88
 
83
89
  # 20 PAN length
84
- assert_no_match ProtxGateway::ELECTRON, '42496200000000000'
90
+ assert_no_match SagePayGateway::ELECTRON, '42496200000000000'
85
91
  end
86
92
 
87
93
  def test_avs_result
@@ -103,20 +109,31 @@ class ProtxTest < Test::Unit::TestCase
103
109
 
104
110
  def successful_purchase_response
105
111
  <<-RESP
106
- VPSProtocol=2.22
112
+ VPSProtocol=2.23
107
113
  Status=OK
108
- StatusDetail=VSP Direct transaction from VSP Simulator.
109
- VPSTxId={7307C8A9-766E-4BD1-AC41-3C34BB83F7E5}
110
- SecurityKey=WIUMDJS607
111
- TxAuthNo=5559
114
+ StatusDetail=0000 : The Authorisation was Successful.
115
+ VPSTxId=B8AE1CF6-9DEF-C876-1BB4-9B382E6CE520
116
+ SecurityKey=OHMETD7DFK
117
+ TxAuthNo=4193753
112
118
  AVSCV2=NO DATA MATCHES
113
119
  AddressResult=NOTMATCHED
114
120
  PostCodeResult=MATCHED
115
121
  CV2Result=NOTMATCHED
122
+ 3DSecureStatus=NOTCHECKED
116
123
  RESP
117
124
  end
118
125
 
119
126
  def unsuccessful_purchase_response
120
- "VPSProtocol=2.22\r\nStatus=NOTAUTHED\r\nStatusDetail=VSP Direct transaction from VSP Simulator.\r\nVPSTxId={7BBA9078-8489-48CD-BF0D-10B0E6B0EF30}\r\nSecurityKey=DKDYLDYLXV\r\nAVSCV2=ALL MATCH\r\nAddressResult=MATCHED\r\nPostCodeResult=MATCHED\r\nCV2Result=MATCHED\r\n"
127
+ <<-RESP
128
+ VPSProtocol=2.23
129
+ Status=NOTAUTHED
130
+ StatusDetail=VSP Direct transaction from VSP Simulator.
131
+ VPSTxId=7BBA9078-8489-48CD-BF0D-10B0E6B0EF30
132
+ SecurityKey=DKDYLDYLXV
133
+ AVSCV2=ALL MATCH
134
+ AddressResult=MATCHED
135
+ PostCodeResult=MATCHED
136
+ CV2Result=MATCHED
137
+ RESP
121
138
  end
122
139
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class SageVirtualCheckTest < Test::Unit::TestCase
4
4
  def setup
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+
3
+ class SallieMaeTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = SallieMaeGateway.new(
6
+ :login => 'FAKEACCOUNT'
7
+ )
8
+
9
+ @credit_card = credit_card
10
+ @amount = 100
11
+
12
+ @options = {
13
+ :order_id => '1',
14
+ :billing_address => address,
15
+ :description => 'Store Purchase'
16
+ }
17
+ end
18
+
19
+ def test_successful_purchase
20
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
21
+
22
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
23
+ assert_success response
24
+ end
25
+
26
+ def test_unsuccessful_request
27
+ @gateway.expects(:ssl_post).returns(failed_purcahse_response)
28
+
29
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
30
+ assert_failure response
31
+ end
32
+
33
+ def test_non_test_account
34
+ assert !@gateway.test?
35
+ end
36
+
37
+ def test_test_account
38
+ gateway = SallieMaeGateway.new(:login => "TEST0")
39
+ assert !@gateway.test?
40
+ end
41
+
42
+ private
43
+
44
+ # Place raw successful response from gateway here
45
+ def successful_purchase_response
46
+ "Status=Accepted"
47
+ end
48
+
49
+ # Place raw failed response from gateway here
50
+ def failed_purcahse_response
51
+ "Status=Declined"
52
+ end
53
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class SecurePayAuTest < Test::Unit::TestCase
4
4
  def setup
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class SecurePayTechTest < Test::Unit::TestCase
4
4
  def setup
@@ -1,13 +1,13 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
-
1
+ require 'test_helper'
2
+
3
3
  class SecurePayTest < Test::Unit::TestCase
4
-
4
+
5
5
  def setup
6
6
  @gateway = SecurePayGateway.new(
7
7
  :login => 'X',
8
8
  :password => 'Y'
9
9
  )
10
-
10
+
11
11
  @credit_card = credit_card
12
12
 
13
13
  @options = {
@@ -18,7 +18,7 @@ class SecurePayTest < Test::Unit::TestCase
18
18
 
19
19
  @amount = 100
20
20
  end
21
-
21
+
22
22
  def test_failed_purchase
23
23
  @gateway.stubs(:ssl_post).returns(failure_response)
24
24
 
@@ -29,6 +29,16 @@ class SecurePayTest < Test::Unit::TestCase
29
29
  assert_equal '3377475', response.authorization
30
30
  end
31
31
 
32
+ def test_failed_production_purchase
33
+ @gateway.stubs(:ssl_post).returns(failed_production_response)
34
+
35
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
36
+ assert_failure response
37
+ assert response.test?
38
+ assert_equal 'This transaction has been declined', response.message
39
+ assert_equal '7416654', response.authorization
40
+ end
41
+
32
42
  def test_successful_purchase
33
43
  @gateway.stubs(:ssl_post).returns(successful_purchase_response)
34
44
 
@@ -74,14 +84,18 @@ class SecurePayTest < Test::Unit::TestCase
74
84
  private
75
85
 
76
86
  def successful_purchase_response
77
- '1%%1%This transaction has been approved.%100721%X%3377575%f6af895031c07d88399ed9fdb48c8476%Store+purchase%0.01%%AUTH_CAPTURE%%Cody%Fauser%%100+Example+St.%Ottawa%ON%K2A5P7%Canada%%%%%%%%%%%%%%%%%%%'
87
+ '1,,1,This transaction has been approved.,100721,X,3377575,f6af895031c07d88399ed9fdb48c8476,Store+purchase,0.01,,AUTH_CAPTURE,,Cody,Fauser,,100+Example+St.%Ottawa,ON,K2A5P7,Canada,,,,,,,,,,,,,,,,,,,'
78
88
  end
79
-
89
+
80
90
  def failure_response
81
- '2%%2%This transaction has been declined.%NOT APPROVED%U%3377475%55adbbaed13aa7e2526846d672fdb594%Store+purchase%1.00%%AUTH_CAPTURE%%Longbob%Longsen%%1234+Test+St.%Ottawa%ON%K1N5P8%Canada%%%%%%%%%%%%%%%%%%%'
91
+ '2,,2,This transaction has been declined.,NOT APPROVED,U,3377475,55adbbaed13aa7e2526846d672fdb594,Store+purchase,1.00,,AUTH_CAPTURE,,Longbob,Longsen,,1234+Test+St.,Ottawa,ON,K1N5P8,Canada,,,,,,,,,,,,,,,,,,,'
82
92
  end
83
93
 
84
94
  def failed_capture_response
85
- '3%%6%The credit card number is invalid.%%%%%%0.01%%PRIOR_AUTH_CAPTURE%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
95
+ '3,,6,The credit card number is invalid.,,,,,,0.01,,PRIOR_AUTH_CAPTURE,,,,,,,,,,,,,,,,,,,,,,,,,,,,'
96
+ end
97
+
98
+ def failed_production_response
99
+ '2,,2,This transaction has been declined.,NOT APPROVED,U,7416654,%231014.11,,7.95,,AUTH_CAPTURE,321hunter%40comcast.net,David,Hunter,,260+Windsor+Ave,Haddonfield,NJ,08033,US,856+795+7941,,321hunter%40comcast.net,,,,260+Windsor+Ave,Haddonfield,Haddonfield,NJ,08033,,,,,,,,'
86
100
  end
87
- end
101
+ end