activemerchant 1.2.1 → 1.3.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 (206) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +310 -294
  3. data/CONTRIBUTERS +13 -0
  4. data/README +55 -31
  5. data/Rakefile +21 -13
  6. data/lib/active_merchant.rb +7 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +8 -3
  9. data/lib/active_merchant/billing/check.rb +61 -0
  10. data/lib/active_merchant/billing/credit_card.rb +104 -80
  11. data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
  12. data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
  13. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  14. data/lib/active_merchant/billing/expiry_date.rb +28 -0
  15. data/lib/active_merchant/billing/gateway.rb +47 -111
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
  17. data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
  18. data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
  19. data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
  20. data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
  21. data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
  22. data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
  23. data/lib/active_merchant/billing/gateways/eway.rb +8 -19
  24. data/lib/active_merchant/billing/gateways/exact.rb +17 -25
  25. data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
  26. data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
  27. data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
  28. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  29. data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
  30. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  31. data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
  32. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
  33. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
  34. data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
  35. data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
  36. data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
  37. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
  38. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
  39. data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
  40. data/lib/active_merchant/billing/gateways/protx.rb +24 -25
  41. data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
  42. data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
  43. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
  44. data/lib/active_merchant/billing/gateways/realex.rb +7 -19
  45. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  46. data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
  47. data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
  48. data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
  49. data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
  50. data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
  51. data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
  52. data/lib/active_merchant/billing/integrations.rb +2 -0
  53. data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
  54. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  55. data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
  56. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  57. data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
  58. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  59. data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
  60. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  61. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
  62. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  63. data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
  64. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  65. data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
  66. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  67. data/lib/active_merchant/billing/integrations/return.rb +35 -0
  68. data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
  69. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  70. data/lib/active_merchant/billing/response.rb +12 -8
  71. data/lib/active_merchant/lib/posts_data.rb +39 -7
  72. data/lib/active_merchant/lib/requires_parameters.rb +2 -3
  73. data/lib/active_merchant/lib/utils.rb +18 -0
  74. data/lib/active_merchant/lib/validateable.rb +3 -3
  75. data/lib/support/gateway_support.rb +22 -9
  76. data/script/destroy +14 -0
  77. data/script/generate +7 -7
  78. data/test/fixtures.yml +25 -3
  79. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  80. data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
  81. data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
  82. data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
  83. data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
  84. data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
  85. data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
  86. data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
  87. data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
  88. data/test/remote/gateways/remote_moneris_test.rb +82 -0
  89. data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
  90. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  91. data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
  92. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  93. data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
  94. data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
  95. data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
  96. data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
  97. data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
  98. data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
  99. data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
  100. data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
  101. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  102. data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
  103. data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
  104. data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
  105. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  106. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  107. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  108. data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
  109. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  110. data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
  111. data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
  112. data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
  113. data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
  114. data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
  115. data/test/test_helper.rb +102 -61
  116. data/test/unit/avs_result_test.rb +59 -0
  117. data/test/unit/base_test.rb +33 -39
  118. data/test/unit/check_test.rb +76 -0
  119. data/test/unit/credit_card_formatting_test.rb +10 -15
  120. data/test/unit/credit_card_methods_test.rb +132 -17
  121. data/test/unit/credit_card_test.rb +157 -228
  122. data/test/unit/cvv_result_test.rb +33 -0
  123. data/test/unit/expiry_date_test.rb +21 -0
  124. data/test/unit/gateways/authorize_net_test.rb +180 -40
  125. data/test/unit/gateways/bogus_test.rb +2 -3
  126. data/test/unit/gateways/brain_tree_test.rb +63 -29
  127. data/test/unit/gateways/card_stream_test.rb +59 -6
  128. data/test/unit/gateways/cyber_source_test.rb +59 -40
  129. data/test/unit/gateways/data_cash_test.rb +82 -1
  130. data/test/unit/gateways/efsnet_test.rb +97 -44
  131. data/test/unit/gateways/eway_test.rb +55 -42
  132. data/test/unit/gateways/exact_test.rb +93 -55
  133. data/test/unit/gateways/gateway_test.rb +7 -0
  134. data/test/unit/gateways/linkpoint_test.rb +60 -58
  135. data/test/unit/gateways/moneris_test.rb +67 -76
  136. data/test/unit/gateways/net_registry_test.rb +351 -419
  137. data/test/unit/gateways/netbilling_test.rb +54 -0
  138. data/test/unit/gateways/pay_junction_test.rb +108 -46
  139. data/test/unit/gateways/pay_secure_test.rb +71 -0
  140. data/test/unit/gateways/payflow_express_test.rb +0 -8
  141. data/test/unit/gateways/payflow_test.rb +136 -65
  142. data/test/unit/gateways/payflow_uk_test.rb +0 -38
  143. data/test/unit/gateways/payment_express_test.rb +31 -51
  144. data/test/unit/gateways/paypal_express_test.rb +8 -2
  145. data/test/unit/gateways/paypal_test.rb +213 -54
  146. data/test/unit/gateways/plugnpay_test.rb +39 -32
  147. data/test/unit/gateways/protx_test.rb +45 -33
  148. data/test/unit/gateways/psigate_test.rb +146 -87
  149. data/test/unit/gateways/psl_card_test.rb +37 -24
  150. data/test/unit/gateways/quickpay_test.rb +33 -46
  151. data/test/unit/gateways/realex_test.rb +32 -31
  152. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  153. data/test/unit/gateways/secure_pay_test.rb +35 -26
  154. data/test/unit/gateways/skip_jack_test.rb +125 -0
  155. data/test/unit/gateways/trans_first_test.rb +24 -37
  156. data/test/unit/gateways/trust_commerce_test.rb +47 -26
  157. data/test/unit/gateways/usa_epay_test.rb +52 -41
  158. data/test/unit/gateways/verifi_test.rb +41 -35
  159. data/test/unit/gateways/viaklix_test.rb +38 -32
  160. data/test/unit/generators/test_gateway_generator.rb +46 -0
  161. data/test/unit/generators/test_generator_helper.rb +20 -0
  162. data/test/unit/generators/test_integration_generator.rb +53 -0
  163. data/test/unit/integrations/action_view_helper_test.rb +7 -14
  164. data/test/unit/integrations/bogus_module_test.rb +4 -0
  165. data/test/unit/integrations/chronopay_module_test.rb +4 -0
  166. data/test/unit/integrations/gestpay_module_test.rb +4 -0
  167. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  168. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  169. data/test/unit/integrations/nochex_module_test.rb +4 -0
  170. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
  171. data/test/unit/integrations/paypal_module_test.rb +4 -0
  172. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  173. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  174. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  175. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  176. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  177. data/test/unit/integrations/returns/return_test.rb +11 -0
  178. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  179. data/test/unit/integrations/two_checkout_module_test.rb +4 -0
  180. data/test/unit/posts_data_test.rb +86 -0
  181. data/test/unit/response_test.rb +15 -1
  182. data/test/unit/utils_test.rb +7 -0
  183. data/test/unit/validateable_test.rb +10 -6
  184. metadata +180 -142
  185. metadata.gz.sig +0 -0
  186. data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
  187. data/script/generator/base.rb +0 -45
  188. data/script/generator/generator.rb +0 -24
  189. data/script/generator/generators/gateway/gateway_generator.rb +0 -14
  190. data/script/generator/generators/gateway/templates/gateway.rb +0 -73
  191. data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
  192. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
  193. data/script/generator/generators/integration/integration_generator.rb +0 -25
  194. data/script/generator/generators/integration/templates/helper.rb +0 -34
  195. data/script/generator/generators/integration/templates/helper_test.rb +0 -54
  196. data/script/generator/generators/integration/templates/integration.rb +0 -18
  197. data/script/generator/generators/integration/templates/module_test.rb +0 -9
  198. data/script/generator/generators/integration/templates/notification.rb +0 -100
  199. data/script/generator/generators/integration/templates/notification_test.rb +0 -41
  200. data/script/generator/manifest.rb +0 -20
  201. data/test/remote_tests/remote_authorize_net_test.rb +0 -113
  202. data/test/remote_tests/remote_brain_tree_test.rb +0 -78
  203. data/test/remote_tests/remote_moneris_test.rb +0 -110
  204. data/test/remote_tests/remote_psigate_test.rb +0 -87
  205. data/test/remote_tests/remote_secure_pay_test.rb +0 -36
  206. data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
@@ -1,53 +1,38 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class PlugnpayTest < Test::Unit::TestCase
4
- include ActiveMerchant::Billing
5
4
 
6
5
  def setup
7
- ActiveMerchant::Billing::Base.mode = :test
8
-
9
- @login = 'X'
10
- @password = 'Y'
6
+ Base.gateway_mode = :test
11
7
 
12
8
  @gateway = PlugnpayGateway.new(
13
- :login => @login,
14
- :password => @password,
15
- :debug => true )
9
+ :login => 'X',
10
+ :password => 'Y'
11
+ )
16
12
 
17
- @creditcard = credit_card('4242424242424242')
13
+ @credit_card = credit_card
14
+ @options = {
15
+ :billing_address => address,
16
+ :description => 'Store purchase'
17
+ }
18
+ @amount = 100
18
19
  end
19
20
 
20
21
  def test_purchase_success
21
- @creditcard.number = 1
22
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
22
23
 
23
- assert response = @gateway.purchase(1000, @creditcard)
24
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
24
25
  assert_equal Response, response.class
25
- assert_equal true, response.success?
26
+ assert_success response
27
+ assert_equal '2008012522252119738', response.authorization
26
28
  end
27
29
 
28
30
  def test_purchase_error
29
- @creditcard.number = 2
31
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
30
32
 
31
- assert response = @gateway.purchase(1000, @creditcard)
33
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
32
34
  assert_equal Response, response.class
33
- assert_equal false, response.success?
34
- end
35
-
36
- def test_purchase_exceptions
37
- @creditcard.number = 3
38
-
39
- assert_raise(Error) do
40
- assert response = @gateway.purchase(1000, @creditcard, :order_id => 1)
41
- end
42
- end
43
-
44
- def test_amount_style
45
- assert_equal '10.34', @gateway.send(:amount, Money.new(1034))
46
- assert_equal '10.34', @gateway.send(:amount, 1034)
47
-
48
- assert_raise(ArgumentError) do
49
- @gateway.send(:amount, '10.34')
50
- end
35
+ assert_failure response
51
36
  end
52
37
 
53
38
  def test_add_address_outsite_north_america
@@ -74,6 +59,28 @@ class PlugnpayTest < Test::Unit::TestCase
74
59
  assert_equal result[:card_state], 'CO'
75
60
  assert_equal result[:card_address1], '164 Waverley Street'
76
61
  assert_equal result[:card_country], 'US'
62
+ end
63
+
64
+ def test_avs_result
65
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
77
66
 
67
+ response = @gateway.purchase(@amount, @credit_card, @options)
68
+ assert_equal 'X', response.avs_result['code']
69
+ end
70
+
71
+ def test_cvv_result
72
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
73
+
74
+ response = @gateway.purchase(@amount, @credit_card, @options)
75
+ assert_equal 'M', response.cvv_result['code']
76
+ end
77
+
78
+ private
79
+ def successful_purchase_response
80
+ "FinalStatus=success&IPaddress=72%2e138%2e32%2e216&MStatus=success&User_Agent=&acct_code3=newcard&address1=1234%20My%20Street&address2=Apt%201&app_level=5&auth_code=TSTAUT&auth_date=20080125&auth_msg=%20&authtype=authpostauth&avs_code=X&card_address1=1234%20My%20Street&card_amount=1%2e00&card_city=Ottawa&card_country=CA&card_name=Longbob%20Longsen&card_state=ON&card_type=VISA&card_zip=K1C2N6&city=Ottawa&convert=underscores&country=CA&currency=usd&cvvresp=M&dontsndmail=yes&easycart=0&merchant=pnpdemo2&merchfraudlev=&mode=auth&orderID=2008012522252119738&phone=555%2d555%2d5555&publisher_email=trash%40plugnpay%2ecom&publisher_name=pnpdemo2&publisher_password=pnpdemo222&resp_code=00&shipinfo=0&shipname=Jim%20Smith&sresp=A&state=ON&success=yes&zip=K1C2N6&a=b\n"
81
+ end
82
+
83
+ def unsuccessful_purchase_response
84
+ "FinalStatus=fraud&IPaddress=72%2e138%2e32%2e216&MStatus=badcard&User_Agent=&address1=1234%20My%20Street&address2=Apt%201&app_level=5&auth_code=&auth_date=20080125&auth_msg=%20Invalid%20Credit%20Card%20Number%2e%7c&authtype=authonly&card_address1=1234%20My%20Street&card_amount=1%2e00&card_city=Ottawa&card_country=CA&card_name=Longbob%20Longsen&card_state=ON&card_type=failure&card_zip=K1C2N6&city=Ottawa&convert=underscores&country=CA&currency=usd&dontsndmail=yes&easycart=0&errdetails=card%2dnumber%7cCard%20Number%20fails%20LUHN%20%2d%2010%20check%2e%7c&errlevel=1&merchant=pnpdemo2&mode=auth&orderID=2008012522275901541&phone=555%2d555%2d5555&publisher_email=trash%40plugnpay%2ecom&publisher_name=pnpdemo2&publisher_password=pnpdemo222&resp_code=P55&shipinfo=0&shipname=Jim%20Smith&sresp=E&state=ON&success=no&zip=K1C2N6&MErrMsg=Invalid%20Credit%20Card%20Number%2e%7c&a=b\n"
78
85
  end
79
86
  end
@@ -6,50 +6,43 @@ class ProtxTest < Test::Unit::TestCase
6
6
  :login => 'X'
7
7
  )
8
8
 
9
- @creditcard = credit_card('4242424242424242', :type => 'visa')
9
+ @credit_card = credit_card('4242424242424242', :type => 'visa')
10
+ @options = {
11
+ :billing_address => {
12
+ :address1 => '25 The Larches',
13
+ :city => "Narborough",
14
+ :state => "Leicester",
15
+ :zip => 'LE10 2RT'
16
+ },
17
+ :order_id => '1',
18
+ :description => 'Store purchase'
19
+ }
20
+ @amount = 100
10
21
  end
11
22
 
12
- def test_purchase_success
13
- @creditcard.number = 1
14
-
15
- assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
16
- assert_equal Response, response.class
17
- assert_equal '#0001', response.params['receiptid']
23
+ def test_successful_purchase
24
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
25
+
26
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
27
+ assert_instance_of Response, response
28
+ assert_equal "1;{7307C8A9-766E-4BD1-AC41-3C34BB83F7E5};5559;WIUMDJS607", response.authorization
18
29
  assert_success response
19
30
  end
20
31
 
21
- def test_purchase_error
22
- @creditcard.number = 2
23
-
24
- assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
25
- assert_equal Response, response.class
26
- assert_equal '#0001', response.params['receiptid']
27
- assert_failure response
28
- end
29
-
30
- def test_purchase_exceptions
31
- @creditcard.number = 3
32
-
33
- assert_raise(Error) do
34
- assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
35
- end
36
- end
37
-
38
- def test_authorization_format
39
- @gateway.expects(:ssl_post).returns(successful_response)
32
+ def test_unsuccessful_purchase
33
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
40
34
 
41
- assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
42
- assert_success response
43
-
44
- assert_equal "1;{7307C8A9-766E-4BD1-AC41-3C34BB83F7E5};5559;WIUMDJS607", response.authorization
35
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
36
+ assert_instance_of Response, response
37
+ assert_failure response
45
38
  end
46
39
 
47
40
  def test_purchase_url
48
- assert_equal 'https://ukvpstest.protx.com/vspgateway/service/vspdirect-register.vsp', @gateway.send(:build_endpoint_url, :purchase)
41
+ assert_equal 'https://ukvpstest.protx.com/vspgateway/service/vspdirect-register.vsp', @gateway.send(:url_for, :purchase)
49
42
  end
50
43
 
51
44
  def test_capture_url
52
- assert_equal 'https://ukvpstest.protx.com/vspgateway/service/release.vsp', @gateway.send(:build_endpoint_url, :capture)
45
+ assert_equal 'https://ukvpstest.protx.com/vspgateway/service/release.vsp', @gateway.send(:url_for, :capture)
53
46
  end
54
47
 
55
48
  def test_electron_cards
@@ -90,10 +83,25 @@ class ProtxTest < Test::Unit::TestCase
90
83
  # 20 PAN length
91
84
  assert_no_match ProtxGateway::ELECTRON, '42496200000000000'
92
85
  end
86
+
87
+ def test_avs_result
88
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
89
+
90
+ response = @gateway.purchase(@amount, @credit_card, @options)
91
+ assert_equal 'Y', response.avs_result['postal_match']
92
+ assert_equal 'N', response.avs_result['street_match']
93
+ end
94
+
95
+ def test_cvv_result
96
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
97
+
98
+ response = @gateway.purchase(@amount, @credit_card, @options)
99
+ assert_equal 'N', response.cvv_result['code']
100
+ end
93
101
 
94
102
  private
95
103
 
96
- def successful_response
104
+ def successful_purchase_response
97
105
  <<-RESP
98
106
  VPSProtocol=2.22
99
107
  Status=OK
@@ -107,4 +115,8 @@ PostCodeResult=MATCHED
107
115
  CV2Result=NOTMATCHED
108
116
  RESP
109
117
  end
118
+
119
+ 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"
121
+ end
110
122
  end
@@ -7,104 +7,163 @@ class PsigateTest < Test::Unit::TestCase
7
7
  :password => 'psigate1234'
8
8
  )
9
9
 
10
- @creditcard = credit_card('4111111111111111')
10
+ @amount = 100
11
+ @credit_card = credit_card('4111111111111111')
12
+ @options = { :order_id => 1, :billing_address => address }
11
13
  end
12
14
 
13
-
14
- def test_authorize_success
15
- @creditcard.number = '1'
15
+ def test_successful_authorization
16
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
16
17
 
17
- assert response = @gateway.authorize(2400, @creditcard, :order_id => 1)
18
- assert_equal Response, response.class
19
- assert_equal true, response.success?
18
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
19
+ assert_instance_of Response, response
20
+ assert_success response
21
+ assert_equal '1000', response.authorization
20
22
  end
21
23
 
22
- def test_purchase_success
23
- @creditcard.number = 1
24
-
25
- assert response = @gateway.purchase(2400, @creditcard, :order_id => 1)
26
- assert_equal Response, response.class
27
- assert_equal '#0001', response.params['receiptid']
28
- assert_equal true, response.success?
24
+ def test_successful_purchase
25
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
26
+
27
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
28
+ assert_instance_of Response, response
29
+ assert_success response
30
+ assert_equal '1000', response.authorization
29
31
  end
30
32
 
31
-
32
- def test_purchase_error
33
- @creditcard.number = 2
34
-
35
- assert response = @gateway.purchase(2400, @creditcard, :order_id => 1)
36
- assert_equal Response, response.class
37
- assert_equal '#0001', response.params['receiptid']
38
- assert_equal false, response.success?
39
- end
33
+ def test_failed_purchase
34
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
35
+
36
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
37
+ assert_failure response
38
+ end
40
39
 
41
- def test_purchase_exceptions
42
- @creditcard.number = 3
43
-
44
- assert_raise(Error) do
45
- assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
46
- end
40
+ def test_amount_style
41
+ assert_equal '10.34', @gateway.send(:amount, 1034)
42
+
43
+ assert_raise(ArgumentError) do
44
+ @gateway.send(:amount, '10.34')
47
45
  end
46
+ end
48
47
 
49
- def test_amount_style
50
- assert_equal '10.34', @gateway.send(:amount, 1034)
51
-
52
- assert_raise(ArgumentError) do
53
- @gateway.send(:amount, '10.34')
54
- end
55
- end
56
- end
57
-
58
- class PsigateRequestTest < Test::Unit::TestCase
59
- def setup
60
- @gateway = PsigateGateway.new(
61
- :login => 'teststore',
62
- :password => 'psigate1234'
63
- )
48
+ def test_supported_countries
49
+ assert_equal ['CA'], PsigateGateway.supported_countries
50
+ end
51
+
52
+ def test_supported_card_types
53
+ assert_equal [:visa, :master, :american_express], PsigateGateway.supported_cardtypes
54
+ end
55
+
56
+ def test_avs_result
57
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
64
58
 
65
- @creditcard = credit_card('4111111111111111')
59
+ response = @gateway.purchase(@amount, @credit_card, @options)
60
+ assert_equal 'X', response.avs_result['code']
66
61
  end
67
62
 
68
- def test_purchase_is_valid_xml
69
- parameters = @gateway.send(:parameters, 2000, @creditcard, {:order_id => 1004,
70
- :billing_address => {
71
- :address1 => '123 fairweather Lane',
72
- :address2 => 'Apt B',
73
- :city => 'New York',
74
- :state => 'NY',
75
- :country => 'U.S.A.',
76
- :zip => '10010'},
77
- :email => 'jack@yahoo.com',
78
- :CardAction => 0 } )
79
- assert data = @gateway.send(:post_data, parameters)
80
- assert_nothing_raised{ REXML::Document.new(data) }
81
- end
82
-
83
- def test_capture_is_valid_xml
84
- parameters = @gateway.send(:parameters, 2000, CreditCard.new({}), {:order_id => 1004,
85
- :CardAction => 2 } )
86
-
87
- assert data = @gateway.send(:post_data, parameters)
88
- assert REXML::Document.new(data)
89
- assert_equal xml_capture_fixture.size, data.size
90
- end
91
-
92
- def test_supported_countries
93
- assert_equal ['CA'], PsigateGateway.supported_countries
94
- end
95
-
96
- def test_supported_card_types
97
- assert_equal [:visa, :master, :american_express], PsigateGateway.supported_cardtypes
98
- end
99
-
100
- private
101
-
102
- def xml_purchase_fixture
103
- %q{<?xml version='1.0'?><Order><Bcity>New York</Bcity><OrderID>1004</OrderID><Bcountry>U.S.A.</Bcountry><CardAction>0</CardAction><Baddress1>123 fairweather Lane</Baddress1><StoreID>teststore</StoreID><Bprovince>NY</Bprovince><CardNumber>4111111111111111</CardNumber><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase><CardExpMonth>08</CardExpMonth><Baddress2>Apt B</Baddress2><Bpostalcode>10010</Bpostalcode><Bname>Longbob Longsen</Bname><CardExpYear>07</CardExpYear><Email>jack@yahoo.com</Email></Order>}
104
- end
105
-
106
- def xml_capture_fixture
107
- %q{<?xml version='1.0'?><Order><OrderID>1004</OrderID><CardAction>2</CardAction><StoreID>teststore</StoreID><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase></Order>}
108
- end
109
-
63
+ def test_cvv_result
64
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
65
+
66
+ response = @gateway.purchase(@amount, @credit_card, @options)
67
+ assert_equal 'M', response.cvv_result['code']
68
+ end
69
+
70
+ private
71
+
72
+ def successful_authorization_response
73
+ <<-RESPONSE
74
+ <?xml version="1.0" encoding="UTF-8"?>
75
+ <Result>
76
+ <TransTime>Sun Jan 06 23:10:53 EST 2008</TransTime>
77
+ <OrderID>1000</OrderID>
78
+ <TransactionType>PREAUTH</TransactionType>
79
+ <Approved>APPROVED</Approved>
80
+ <ReturnCode>Y:123456:0abcdef:M:X:NNN</ReturnCode>
81
+ <ErrMsg/>
82
+ <TaxTotal>0.00</TaxTotal>
83
+ <ShipTotal>0.00</ShipTotal>
84
+ <SubTotal>24.00</SubTotal>
85
+ <FullTotal>24.00</FullTotal>
86
+ <PaymentType>CC</PaymentType>
87
+ <CardNumber>......4242</CardNumber>
88
+ <TransRefNumber>1bdde305d7658367</TransRefNumber>
89
+ <CardIDResult>M</CardIDResult>
90
+ <AVSResult>X</AVSResult>
91
+ <CardAuthNumber>123456</CardAuthNumber>
92
+ <CardRefNumber>0abcdef</CardRefNumber>
93
+ <CardType>VISA</CardType>
94
+ <IPResult>NNN</IPResult>
95
+ <IPCountry>UN</IPCountry>
96
+ <IPRegion>UNKNOWN</IPRegion>
97
+ <IPCity>UNKNOWN</IPCity>
98
+ </Result>
99
+ RESPONSE
100
+ end
101
+
102
+ def successful_purchase_response
103
+ <<-RESPONSE
104
+ <?xml version="1.0" encoding="UTF-8"?>
105
+ <Result>
106
+ <TransTime>Sun Jan 06 23:15:30 EST 2008</TransTime>
107
+ <OrderID>1000</OrderID>
108
+ <TransactionType>SALE</TransactionType>
109
+ <Approved>APPROVED</Approved>
110
+ <ReturnCode>Y:123456:0abcdef:M:X:NNN</ReturnCode>
111
+ <ErrMsg/>
112
+ <TaxTotal>0.00</TaxTotal>
113
+ <ShipTotal>0.00</ShipTotal>
114
+ <SubTotal>24.00</SubTotal>
115
+ <FullTotal>24.00</FullTotal>
116
+ <PaymentType>CC</PaymentType>
117
+ <CardNumber>......4242</CardNumber>
118
+ <TransRefNumber>1bdde305da3ee234</TransRefNumber>
119
+ <CardIDResult>M</CardIDResult>
120
+ <AVSResult>X</AVSResult>
121
+ <CardAuthNumber>123456</CardAuthNumber>
122
+ <CardRefNumber>0abcdef</CardRefNumber>
123
+ <CardType>VISA</CardType>
124
+ <IPResult>NNN</IPResult>
125
+ <IPCountry>UN</IPCountry>
126
+ <IPRegion>UNKNOWN</IPRegion>
127
+ <IPCity>UNKNOWN</IPCity>
128
+ </Result>
129
+ RESPONSE
130
+ end
131
+
132
+ def failed_purchase_response
133
+ <<-RESPONSE
134
+ <?xml version="1.0" encoding="UTF-8"?>
135
+ <Result>
136
+ <TransTime>Sun Jan 06 23:24:29 EST 2008</TransTime>
137
+ <OrderID>b3dca49e3ec77e42ab80a0f0f590fff0</OrderID>
138
+ <TransactionType>SALE</TransactionType>
139
+ <Approved>DECLINED</Approved>
140
+ <ReturnCode>N:TESTDECLINE</ReturnCode>
141
+ <ErrMsg/>
142
+ <TaxTotal>0.00</TaxTotal>
143
+ <ShipTotal>0.00</ShipTotal>
144
+ <SubTotal>24.00</SubTotal>
145
+ <FullTotal>24.00</FullTotal>
146
+ <PaymentType>CC</PaymentType>
147
+ <CardNumber>......4242</CardNumber>
148
+ <TransRefNumber>1bdde305df991f89</TransRefNumber>
149
+ <CardIDResult>M</CardIDResult>
150
+ <AVSResult>X</AVSResult>
151
+ <CardAuthNumber>TEST</CardAuthNumber>
152
+ <CardRefNumber>TESTTRANS</CardRefNumber>
153
+ <CardType>VISA</CardType>
154
+ <IPResult>NNN</IPResult>
155
+ <IPCountry>UN</IPCountry>
156
+ <IPRegion>UNKNOWN</IPRegion>
157
+ <IPCity>UNKNOWN</IPCity>
158
+ </Result>
159
+ RESPONSE
160
+ end
161
+
162
+ def xml_purchase_fixture
163
+ '<?xml version="1.0"?><Order><Bcity>New York</Bcity><OrderID>1004</OrderID><Bcountry>U.S.A.</Bcountry><CardAction>0</CardAction><Baddress1>123 fairweather Lane</Baddress1><StoreID>teststore</StoreID><Bprovince>NY</Bprovince><CardNumber>4111111111111111</CardNumber><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase><CardExpMonth>08</CardExpMonth><Baddress2>Apt B</Baddress2><Bpostalcode>10010</Bpostalcode><Bname>Longbob Longsen</Bname><CardExpYear>07</CardExpYear><Email>jack@yahoo.com</Email></Order>'
164
+ end
165
+
166
+ def xml_capture_fixture
167
+ '<?xml version="1.0"?><Order><OrderID>1004</OrderID><CardAction>2</CardAction><StoreID>teststore</StoreID><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase></Order>'
168
+ end
110
169
  end