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,30 +1,20 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemoteCyberSourceTest < Test::Unit::TestCase
4
- # Amount in cents
5
- AMOUNT = 100
6
-
7
4
  def setup
8
5
  Base.gateway_mode = :test
9
6
 
10
7
  @gateway = CyberSourceGateway.new(fixtures(:cyber_source))
11
8
 
12
- @creditcard = credit_card('4111111111111111', :type => 'visa')
9
+ @credit_card = credit_card('4111111111111111', :type => 'visa')
13
10
  @declined_card = credit_card('801111111111111', :type => 'visa')
14
11
 
12
+ @amount = 100
13
+
15
14
  @options = {
16
- :address => {
17
- :address1 => '1234 My Street',
18
- :address2 => 'Apt 1',
19
- :company => 'Widgets Inc',
20
- :city => 'Ottawa',
21
- :state => 'ON',
22
- :zip => 'K1C2N6',
23
- :country => 'Canada',
24
- :phone => '(555)555-5555'
25
- },
15
+ :billing_address => address,
26
16
 
27
- :order_id => generate_order_id,
17
+ :order_id => generate_unique_id,
28
18
  :line_items => [
29
19
  {
30
20
  :declared_value => 100,
@@ -49,7 +39,7 @@ class RemoteCyberSourceTest < Test::Unit::TestCase
49
39
  end
50
40
 
51
41
  def test_successful_authorization
52
- assert response = @gateway.authorize(AMOUNT, @creditcard, @options)
42
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
53
43
  assert_equal 'Successful transaction', response.message
54
44
  assert_success response
55
45
  assert response.test?
@@ -57,14 +47,14 @@ class RemoteCyberSourceTest < Test::Unit::TestCase
57
47
  end
58
48
 
59
49
  def test_unsuccessful_authorization
60
- assert response = @gateway.authorize(AMOUNT, @declined_card, @options)
50
+ assert response = @gateway.authorize(@amount, @declined_card, @options)
61
51
  assert response.test?
62
52
  assert_equal 'Invalid account number', response.message
63
53
  assert_equal false, response.success?
64
54
  end
65
55
 
66
56
  def test_successful_tax_calculation
67
- assert response = @gateway.calculate_tax(@creditcard, @options)
57
+ assert response = @gateway.calculate_tax(@credit_card, @options)
68
58
  assert_equal 'Successful transaction', response.message
69
59
  assert response.params['totalTaxAmount']
70
60
  assert_not_equal "0", response.params['totalTaxAmount']
@@ -74,7 +64,7 @@ class RemoteCyberSourceTest < Test::Unit::TestCase
74
64
 
75
65
  def test_successful_tax_calculation_with_nexus
76
66
  @gateway.options = @gateway.options.merge(:nexus => 'WI')
77
- assert response = @gateway.calculate_tax(@creditcard, @options)
67
+ assert response = @gateway.calculate_tax(@credit_card, @options)
78
68
  assert_equal 'Successful transaction', response.message
79
69
  assert response.params['totalTaxAmount']
80
70
  assert_equal "0", response.params['totalTaxAmount']
@@ -83,48 +73,47 @@ class RemoteCyberSourceTest < Test::Unit::TestCase
83
73
  end
84
74
 
85
75
  def test_successful_purchase
86
- assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
76
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
87
77
  assert_equal 'Successful transaction', response.message
88
78
  assert_success response
89
79
  assert response.test?
90
80
  end
91
81
 
92
82
  def test_unsuccessful_purchase
93
- assert response = @gateway.purchase(AMOUNT, @declined_card, @options)
83
+ assert response = @gateway.purchase(@amount, @declined_card, @options)
94
84
  assert_equal 'Invalid account number', response.message
95
85
  assert_failure response
96
86
  assert response.test?
97
87
  end
98
88
 
99
89
  def test_authorize_and_capture
100
- assert auth = @gateway.authorize(AMOUNT, @creditcard, @options)
90
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
101
91
  assert_success auth
102
92
  assert_equal 'Successful transaction', auth.message
103
93
 
104
- assert capture = @gateway.capture(AMOUNT, auth.authorization)
94
+ assert capture = @gateway.capture(@amount, auth.authorization)
105
95
  assert_success capture
106
96
  end
107
97
 
108
- def test_good_authorize_and_bad_capture
109
- assert auth = @gateway.authorize(AMOUNT, @creditcard, @options)
98
+ def test_successful_authorization_and_failed_capture
99
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
110
100
  assert_success auth
111
101
  assert_equal 'Successful transaction', auth.message
112
102
 
113
- assert capture = @gateway.capture(AMOUNT + 10, auth.authorization, @options)
103
+ assert capture = @gateway.capture(@amount + 10, auth.authorization, @options)
114
104
  assert_failure capture
115
- assert_equal "One or more fields contains invalid data", capture.message
116
105
  end
117
106
 
118
107
  def test_failed_capture_bad_auth_info
119
- assert auth = @gateway.authorize(AMOUNT, @creditcard, @options)
120
- assert capture = @gateway.capture(AMOUNT, "a;b;c", @options)
108
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
109
+ assert capture = @gateway.capture(@amount, "a;b;c", @options)
121
110
  assert_failure capture
122
111
  end
123
112
 
124
113
  def test_invalid_login
125
114
  gateway = CyberSourceGateway.new( :login => '', :password => '' )
126
- assert response = gateway.purchase(AMOUNT, @creditcard, @options)
127
- assert_equal "wsse:InvalidSecurity: \nSecurity Data : illegal null input\n", response.message
115
+ assert response = gateway.purchase(@amount, @credit_card, @options)
116
+ assert_match /wsse:InvalidSecurity/, response.message
128
117
  assert_failure response
129
118
  end
130
119
  end
@@ -1,5 +1,5 @@
1
1
  # Author:: MoneySpyder, www.moneyspyder.co.uk
2
- require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.dirname(__FILE__) + '/../../test_helper'
3
3
 
4
4
  class RemoteDataCashTest < Test::Unit::TestCase
5
5
  def setup
@@ -41,7 +41,7 @@ class RemoteDataCashTest < Test::Unit::TestCase
41
41
  }
42
42
 
43
43
  @params = {
44
- :order_id => generate_order_id,
44
+ :order_id => generate_unique_id,
45
45
  :billing_address => @address
46
46
  }
47
47
  end
@@ -1,92 +1,80 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemoteEfsnetTest < Test::Unit::TestCase
4
- AMOUNT = 100
5
- DECLINED_AMOUNT = 156
6
-
4
+
7
5
  def setup
8
6
  Base.gateway_mode = :test
9
7
 
10
8
  @gateway = EfsnetGateway.new(fixtures(:efsnet))
11
9
 
12
- @creditcard = credit_card('4000100011112224')
10
+ @credit_card = credit_card('4000100011112224')
11
+
12
+ @amount = 100
13
+ @declined_amount = 156
13
14
 
14
- @options = { :order_id => 0,
15
- :address => { :address1 => '1234 Shady Brook Lane',
16
- :zip => '90210'
17
- }
15
+ @options = { :order_id => generate_unique_id,
16
+ :billing_address => address
18
17
  }
19
18
  end
20
19
 
21
20
  def test_successful_purchase
22
- @options[:order_id] += 1
23
- assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
24
- assert_equal 'Approved', response.message
21
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
25
22
  assert_success response
23
+ assert_equal 'Approved', response.message
26
24
  assert response.test?
27
25
  end
28
26
 
29
27
  def test_successful_force
30
- @options[:order_id] += 1
31
- assert response = @gateway.force(AMOUNT, '123456', @creditcard, @options)
32
- assert_equal 'Approved', response.message
28
+ assert response = @gateway.force(@amount, '123456', @credit_card, @options)
33
29
  assert_success response
30
+ assert_equal 'Approved', response.message
34
31
  end
35
32
 
36
33
  def test_successful_voice_authorize
37
- @options[:order_id] += 1
38
- assert response = @gateway.voice_authorize(AMOUNT, '123456', @creditcard, @options)
39
- assert_equal 'Accepted', response.message
34
+ assert response = @gateway.voice_authorize(@amount, '123456', @credit_card, @options)
40
35
  assert_success response
36
+ assert_equal 'Accepted', response.message
41
37
  end
42
38
 
43
39
  def test_unsuccessful_purchase
44
- @options[:order_id] += 1
45
- assert response = @gateway.purchase(DECLINED_AMOUNT, @creditcard, @options)
46
- assert_equal 'Declined', response.message
40
+ assert response = @gateway.purchase(@declined_amount, @credit_card, @options)
47
41
  assert_failure response
42
+ assert_equal 'Declined', response.message
48
43
  end
49
44
 
50
45
  def test_authorize_and_capture
51
- @options[:order_id] += 1
52
-
53
- amount = AMOUNT
54
- assert auth = @gateway.authorize(amount, @creditcard, @options)
46
+ amount = @amount
47
+ assert auth = @gateway.authorize(amount, @credit_card, @options)
55
48
  assert_success auth
56
49
  assert_equal 'Approved', auth.message
57
50
  assert auth.authorization
58
51
 
59
- @options[:order_id] += 1
60
52
  assert capture = @gateway.capture(amount, auth.authorization, @options)
61
53
  assert_success capture
62
54
  end
63
55
 
64
56
  def test_purchase_and_void
65
- @options[:order_id] += 1
66
- amount = AMOUNT
67
- assert purchase = @gateway.purchase(amount, @creditcard, @options)
57
+ amount = @amount
58
+ assert purchase = @gateway.purchase(amount, @credit_card, @options)
68
59
  assert_success purchase
69
60
  assert_equal 'Approved', purchase.message
70
61
  assert purchase.authorization
71
- @options[:order_id] += 1
72
62
  assert void = @gateway.void(purchase.authorization, @options)
73
63
  assert_success void
74
64
  end
75
65
 
76
66
  def test_failed_capture
77
- @options[:order_id] += 1
78
- assert response = @gateway.capture(AMOUNT, '1;1', @options)
67
+ assert response = @gateway.capture(@amount, '1;1', @options)
79
68
  assert_failure response
80
69
  assert_equal 'Bad original transaction', response.message
81
70
  end
82
71
 
83
72
  def test_invalid_login
84
- @options[:order_id] += 1
85
73
  gateway = EfsnetGateway.new(
86
74
  :login => '',
87
75
  :password => ''
88
76
  )
89
- assert response = gateway.purchase(AMOUNT, @creditcard, @options)
77
+ assert response = gateway.purchase(@amount, @credit_card, @options)
90
78
  assert_equal 'Invalid credentials', response.message
91
79
  assert_failure response
92
80
  end
@@ -1,13 +1,13 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class EwayTest < Test::Unit::TestCase
4
4
  def setup
5
5
  Base.gateway_mode = :test
6
6
  @gateway = EwayGateway.new(fixtures(:eway))
7
7
 
8
- @creditcard_success = credit_card('4444333322221111')
8
+ @credit_card_success = credit_card('4444333322221111')
9
9
 
10
- @creditcard_fail = credit_card('1234567812345678',
10
+ @credit_card_fail = credit_card('1234567812345678',
11
11
  :month => Time.now.month,
12
12
  :year => Time.now.year
13
13
  )
@@ -15,22 +15,25 @@ class EwayTest < Test::Unit::TestCase
15
15
  @params = {
16
16
  :order_id => '1230123',
17
17
  :email => 'bob@testbob.com',
18
- :address => { :address1 => '47 Bobway, Bobville, WA, Australia',
19
- :zip => '2000'
20
- } ,
18
+ :billing_address => { :address1 => '47 Bobway',
19
+ :city => 'Bobville',
20
+ :state => 'WA',
21
+ :country => 'AU',
22
+ :zip => '2000'
23
+ } ,
21
24
  :description => 'purchased items'
22
25
  }
23
26
  end
24
27
 
25
28
  def test_invalid_amount
26
- assert response = @gateway.purchase(101, @creditcard_success, @params)
29
+ assert response = @gateway.purchase(101, @credit_card_success, @params)
27
30
  assert_failure response
28
31
  assert response.test?
29
32
  assert_equal EwayGateway::MESSAGES["01"], response.message
30
33
  end
31
34
 
32
35
  def test_purchase_success_with_verification_value
33
- assert response = @gateway.purchase(100, @creditcard_success, @params)
36
+ assert response = @gateway.purchase(100, @credit_card_success, @params)
34
37
  assert_equal '123456', response.authorization
35
38
  assert_success response
36
39
  assert response.test?
@@ -38,24 +41,24 @@ class EwayTest < Test::Unit::TestCase
38
41
  end
39
42
 
40
43
  def test_invalid_expiration_date
41
- @creditcard_success.year = 2005
42
- assert response = @gateway.purchase(100, @creditcard_success, @params)
44
+ @credit_card_success.year = 2005
45
+ assert response = @gateway.purchase(100, @credit_card_success, @params)
43
46
  assert_failure response
44
47
  assert response.test?
45
48
  end
46
49
 
47
50
  def test_purchase_with_invalid_verification_value
48
- @creditcard_success.verification_value = 'AAA'
49
- assert response = @gateway.purchase(100, @creditcard_success, @params)
51
+ @credit_card_success.verification_value = 'AAA'
52
+ assert response = @gateway.purchase(100, @credit_card_success, @params)
50
53
  assert_nil response.authorization
51
54
  assert_failure response
52
55
  assert response.test?
53
56
  end
54
57
 
55
58
  def test_purchase_success_without_verification_value
56
- @creditcard_success.verification_value = nil
59
+ @credit_card_success.verification_value = nil
57
60
 
58
- assert response = @gateway.purchase(100, @creditcard_success, @params)
61
+ assert response = @gateway.purchase(100, @credit_card_success, @params)
59
62
  assert_equal '123456', response.authorization
60
63
  assert_success response
61
64
  assert response.test?
@@ -63,7 +66,7 @@ class EwayTest < Test::Unit::TestCase
63
66
  end
64
67
 
65
68
  def test_purchase_error
66
- assert response = @gateway.purchase(100, @creditcard_fail, @params)
69
+ assert response = @gateway.purchase(100, @credit_card_fail, @params)
67
70
  assert_nil response.authorization
68
71
  assert_equal false, response.success?
69
72
  assert response.test?
@@ -1,50 +1,51 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemoteExactTest < Test::Unit::TestCase
4
+
4
5
  def setup
5
6
 
6
-
7
7
  @gateway = ExactGateway.new(fixtures(:exact))
8
-
9
- @credit_card = credit_card("4111111111111111")
10
-
11
- @options = { :address => { :address1 => "1234 Testing Ave.",
12
- :zip => "55555" } }
8
+ @credit_card = credit_card
9
+ @amount = 100
10
+ @options = {
11
+ :order_id => '1',
12
+ :billing_address => address,
13
+ :description => 'Store Purchase'
14
+ }
13
15
  end
14
16
 
15
17
  def test_successful_purchase
16
- assert response = @gateway.purchase(100, @credit_card, @options)
17
- assert_equal "Transaction Normal - VER UNAVAILABLE", response.message
18
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
19
+ assert_match /Transaction Normal/, response.message
18
20
  assert_success response
19
21
  end
20
22
 
21
23
  def test_unsuccessful_purchase
22
24
  # ask for error 13 response (Amount Error) via dollar amount 5,000 + error
23
- assert response = @gateway.purchase(501300, @credit_card, @options )
24
- assert_equal "Transaction Normal - AMOUNT ERR", response.message
25
+ @amount = 501300
26
+ assert response = @gateway.purchase(@amount, @credit_card, @options )
27
+ assert_match /Transaction Normal/, response.message
25
28
  assert_failure response
26
29
  end
27
30
 
28
31
  def test_purchase_and_credit
29
- amount = 100
30
- assert purchase = @gateway.purchase(amount, @credit_card, @options)
32
+ assert purchase = @gateway.purchase(@amount, @credit_card, @options)
31
33
  assert_success purchase
32
34
  assert purchase.authorization
33
- assert credit = @gateway.credit(amount, purchase.authorization)
35
+ assert credit = @gateway.credit(@amount, purchase.authorization)
34
36
  assert_success credit
35
37
  end
36
38
 
37
39
  def test_authorize_and_capture
38
- amount = 100
39
- assert auth = @gateway.authorize(amount, @credit_card, @options)
40
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
40
41
  assert_success auth
41
42
  assert auth.authorization
42
- assert capture = @gateway.capture(amount, auth.authorization)
43
+ assert capture = @gateway.capture(@amount, auth.authorization)
43
44
  assert_success capture
44
45
  end
45
46
 
46
47
  def test_failed_capture
47
- assert response = @gateway.capture(100, String.new)
48
+ assert response = @gateway.capture(@amount, '')
48
49
  assert_failure response
49
50
  assert_match /Precondition Failed/i, response.message
50
51
  end
@@ -52,7 +53,7 @@ class RemoteExactTest < Test::Unit::TestCase
52
53
  def test_invalid_login
53
54
  gateway = ExactGateway.new( :login => "NotARealUser",
54
55
  :password => "NotARealPassword" )
55
- assert response = gateway.purchase(100, @credit_card, @options)
56
+ assert response = gateway.purchase(@amount, @credit_card, @options)
56
57
  assert_equal "Invalid Logon", response.message
57
58
  assert_failure response
58
59
  end
@@ -14,12 +14,15 @@
14
14
  # LinkPoint Central. Then click "set lockout times" under Fraud Settings
15
15
  # You will want to set Duplicate lockout time to 0 so that you can run
16
16
  # the tests more than once without triggering this fraud detection.
17
+ #
18
+ # The LinkPoint staging server will also return different responses based
19
+ # on the cent amount of the purhcase. Complete details can be found at
20
+ require File.dirname(__FILE__) + '/../../test_helper'
17
21
 
18
- require File.dirname(__FILE__) + '/../test_helper'
19
-
22
+ # http://sgserror.com/staging.php
20
23
  class LinkpointTest < Test::Unit::TestCase
21
24
  def setup
22
- Base.gateway_mode = :test
25
+ Base.mode = :test
23
26
 
24
27
  @gateway = LinkpointGateway.new(fixtures(:linkpoint))
25
28
 
@@ -31,72 +34,47 @@ class LinkpointTest < Test::Unit::TestCase
31
34
  # MasterCard: 5419-8400-0000-0003
32
35
  # Visa: 4111-1111-1111-1111
33
36
 
34
- @creditcard = credit_card('4111111111111111')
35
-
36
- @address = {
37
- :address1 => '1313 lucky lane',
38
- :city => 'Lost Angeles',
39
- :state => 'ON',
40
- :zip => 'K2P2A6',
41
- :country => 'CA',
42
- :address2 => 'Apartment 1',
43
- :phone => '(555)555-5555'
44
- }
37
+ @amount = 100
38
+ @credit_card = credit_card('4111111111111111')
39
+ @options = { :order_id => generate_unique_id, :billing_address => address }
45
40
  end
46
41
 
47
42
  def test_successful_authorization
48
- assert response = @gateway.authorize(1000, @creditcard,
49
- :order_id => generate_order_id,
50
- :address => @address
51
- )
52
-
53
- assert_equal Response, response.class
54
- assert_equal true, response.success?
43
+ assert response = @gateway.authorize(1000, @credit_card, @options)
44
+
45
+ assert_instance_of Response, response
46
+ assert_success response
55
47
  assert_equal "APPROVED", response.params["approved"]
56
48
  end
57
49
 
58
50
  def test_successful_authorization_and_capture
59
- assert authorization = @gateway.authorize(100, @creditcard,
60
- :order_id => generate_order_id,
61
- :address => @address
62
- )
63
-
51
+ assert authorization = @gateway.authorize(@amount, @credit_card, @options)
64
52
  assert_success authorization
65
53
  assert authorization.test?
66
- assert capture = @gateway.capture(100, authorization.authorization)
54
+
55
+ assert capture = @gateway.capture(@amount, authorization.authorization)
67
56
  assert_success capture
68
57
  assert_equal 'ACCEPTED', capture.message
69
58
  end
70
59
 
71
60
  def test_successful_purchase_without_cvv2_code
72
- @creditcard.verification_value = nil
61
+ @credit_card.verification_value = nil
73
62
 
74
- assert response = @gateway.purchase(2400, @creditcard,
75
- :order_id => generate_order_id,
76
- :address => @address
77
- )
78
- assert_equal Response, response.class
79
- assert_equal true, response.success?
63
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
64
+ assert_success response
80
65
  assert_equal "APPROVED", response.params["approved"]
81
66
  assert_equal 'NNN', response.params["avs"]
82
67
  end
83
68
 
84
69
  def test_successful_purchase_with_cvv2_code
85
- assert response = @gateway.purchase(2400, @creditcard,
86
- :order_id => generate_order_id,
87
- :address => @address
88
- )
89
- assert_equal Response, response.class
90
- assert_equal true, response.success?
70
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
71
+ assert_success response
91
72
  assert_equal "APPROVED", response.params["approved"]
92
73
  assert_equal 'NNNM', response.params["avs"]
93
74
  end
94
75
 
95
76
  def test_successful_purchase_and_void
96
- purchase = @gateway.purchase(100, @creditcard,
97
- :order_id => generate_order_id,
98
- :address => @address
99
- )
77
+ purchase = @gateway.purchase(@amount, @credit_card, @options)
100
78
  assert_success purchase
101
79
 
102
80
  assert void = @gateway.void(purchase.authorization)
@@ -104,11 +82,8 @@ class LinkpointTest < Test::Unit::TestCase
104
82
  end
105
83
 
106
84
  def test_successfull_purchase_and_credit
107
- assert purchase = @gateway.purchase(2400, @creditcard,
108
- :order_id => generate_order_id,
109
- :address => @address
110
- )
111
- assert_equal true, purchase.success?
85
+ assert purchase = @gateway.purchase(2400, @credit_card, @options)
86
+ assert_success purchase
112
87
 
113
88
  assert credit = @gateway.credit(2400, purchase.authorization)
114
89
  assert_success credit
@@ -116,29 +91,22 @@ class LinkpointTest < Test::Unit::TestCase
116
91
 
117
92
 
118
93
  def test_successful_recurring_payment
119
- assert response = @gateway.recurring(2400, @creditcard,
120
- :order_id => generate_order_id,
94
+ assert response = @gateway.recurring(2400, @credit_card,
95
+ :order_id => generate_unique_id,
121
96
  :installments => 12,
122
97
  :startdate => "immediate",
123
98
  :periodicity => :monthly,
124
- :address => @address
99
+ :billing_address => address
125
100
  )
126
101
 
127
- assert_equal Response, response.class
128
- assert_equal true, response.success?
102
+ assert_success response
129
103
  assert_equal "APPROVED", response.params["approved"]
130
104
  end
131
105
 
132
-
133
106
  def test_declined_purchase_with_invalid_credit_card
134
- @creditcard.number = '1111111111111111'
135
- assert response = @gateway.purchase(100, @creditcard,
136
- :order_id => generate_order_id,
137
- :address => @address
138
- )
139
-
140
- assert_equal Response, response.class
141
- assert_equal false, response.success?
107
+ @credit_card.number = '1111111111111111'
108
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
109
+ assert_failure response
142
110
  assert_equal "DECLINED", response.params["approved"]
143
111
  end
144
112
  end