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
@@ -0,0 +1,39 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemotePaySecureTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @gateway = PaySecureGateway.new(fixtures(:pay_secure))
7
+
8
+ @credit_card = credit_card('4000100011112224')
9
+ @options = {
10
+ :billing_address => address,
11
+ :order_id => generate_unique_id
12
+ }
13
+ @amount = 100
14
+ end
15
+
16
+ def test_successful_purchase
17
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
18
+ assert_success response
19
+ assert_equal PaySecureGateway::SUCCESS_MESSAGE, response.message
20
+ assert response.test?
21
+ end
22
+
23
+ def test_unsuccessful_purchase
24
+ @credit_card.year = '2006'
25
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
26
+ assert_equal 'Declined, card expired', response.message
27
+ assert_failure response
28
+ end
29
+
30
+ def test_invalid_login
31
+ gateway = PaySecureGateway.new(
32
+ :login => '',
33
+ :password => ''
34
+ )
35
+ assert response = gateway.purchase(@amount, @credit_card, @options)
36
+ assert_equal "MissingField: 'MERCHANT_ID'", response.message
37
+ assert_failure response
38
+ end
39
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemotePayflowTest < Test::Unit::TestCase
4
4
  def setup
@@ -6,7 +6,7 @@ class RemotePayflowTest < Test::Unit::TestCase
6
6
 
7
7
  @gateway = PayflowExpressGateway.new(fixtures(:payflow))
8
8
 
9
- @options = { :address => {
9
+ @options = { :billing_address => {
10
10
  :name => 'Cody Fauser',
11
11
  :address1 => '1234 Shady Brook Lane',
12
12
  :city => 'Ottawa',
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemotePayflowTest < Test::Unit::TestCase
4
4
  def setup
@@ -6,25 +6,18 @@ class RemotePayflowTest < Test::Unit::TestCase
6
6
 
7
7
  @gateway = PayflowGateway.new(fixtures(:payflow))
8
8
 
9
- @creditcard = credit_card('5105105105105100',
9
+ @credit_card = credit_card('5105105105105100',
10
10
  :type => 'master'
11
11
  )
12
12
 
13
- @options = { :address => {
14
- :name => 'Cody Fauser',
15
- :address1 => '1234 Shady Brook Lane',
16
- :city => 'Ottawa',
17
- :state => 'ON',
18
- :country => 'CA',
19
- :zip => '90210',
20
- :phone => '555-555-5555'
21
- },
22
- :email => 'cody@example.com'
13
+ @options = { :billing_address => address,
14
+ :email => 'cody@example.com',
15
+ :customer => 'codyexample'
23
16
  }
24
17
  end
25
18
 
26
19
  def test_successful_purchase
27
- assert response = @gateway.purchase(100000, @creditcard, @options)
20
+ assert response = @gateway.purchase(100000, @credit_card, @options)
28
21
  assert_equal "Approved", response.message
29
22
  assert_success response
30
23
  assert response.test?
@@ -32,14 +25,14 @@ class RemotePayflowTest < Test::Unit::TestCase
32
25
  end
33
26
 
34
27
  def test_declined_purchase
35
- assert response = @gateway.purchase(210000, @creditcard, @options)
28
+ assert response = @gateway.purchase(210000, @credit_card, @options)
36
29
  assert_equal 'Declined', response.message
37
30
  assert_failure response
38
31
  assert response.test?
39
32
  end
40
33
 
41
34
  def test_successful_authorization
42
- assert response = @gateway.authorize(100, @creditcard, @options)
35
+ assert response = @gateway.authorize(100, @credit_card, @options)
43
36
  assert_equal "Approved", response.message
44
37
  assert_success response
45
38
  assert response.test?
@@ -47,7 +40,7 @@ class RemotePayflowTest < Test::Unit::TestCase
47
40
  end
48
41
 
49
42
  def test_authorize_and_capture
50
- assert auth = @gateway.authorize(100, @creditcard, @options)
43
+ assert auth = @gateway.authorize(100, @credit_card, @options)
51
44
  assert_success auth
52
45
  assert_equal 'Approved', auth.message
53
46
  assert auth.authorization
@@ -56,7 +49,7 @@ class RemotePayflowTest < Test::Unit::TestCase
56
49
  end
57
50
 
58
51
  def test_authorize_and_partial_capture
59
- assert auth = @gateway.authorize(100 * 2, @creditcard, @options)
52
+ assert auth = @gateway.authorize(100 * 2, @credit_card, @options)
60
53
  assert_success auth
61
54
  assert_equal 'Approved', auth.message
62
55
  assert auth.authorization
@@ -72,7 +65,7 @@ class RemotePayflowTest < Test::Unit::TestCase
72
65
  end
73
66
 
74
67
  def test_authorize_and_void
75
- assert auth = @gateway.authorize(100, @creditcard, @options)
68
+ assert auth = @gateway.authorize(100, @credit_card, @options)
76
69
  assert_success auth
77
70
  assert_equal 'Approved', auth.message
78
71
  assert auth.authorization
@@ -85,36 +78,33 @@ class RemotePayflowTest < Test::Unit::TestCase
85
78
  :login => '',
86
79
  :password => ''
87
80
  )
88
- assert response = gateway.purchase(100, @creditcard, @options)
81
+ assert response = gateway.purchase(100, @credit_card, @options)
89
82
  assert_equal 'Invalid vendor account', response.message
90
83
  assert_failure response
91
84
  end
92
85
 
93
86
  def test_duplicate_request_id
94
- gateway = PayflowGateway.new(
95
- :login => @login,
96
- :password => @password,
97
- :partner => @partner
98
- )
99
-
100
87
  request_id = Digest::MD5.hexdigest(rand.to_s)
101
- gateway.expects(:generate_unique_id).times(2).returns(request_id)
88
+ @gateway.expects(:generate_unique_id).times(2).returns(request_id)
102
89
 
103
- response1 = gateway.purchase(100, @creditcard, @options)
90
+ response1 = @gateway.purchase(100, @credit_card, @options)
91
+ assert response1.success?
104
92
  assert_nil response1.params['duplicate']
105
- response2 = gateway.purchase(100, @creditcard, @options)
93
+
94
+ response2 = @gateway.purchase(100, @credit_card, @options)
95
+ assert response2.success?
106
96
  assert response2.params['duplicate']
107
97
  end
108
98
 
109
99
  def test_create_recurring_profile
110
- response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly)
100
+ response = @gateway.recurring(1000, @credit_card, :periodicity => :monthly)
111
101
  assert_success response
112
102
  assert !response.params['profile_id'].blank?
113
103
  assert response.test?
114
104
  end
115
105
 
116
106
  def test_create_recurring_profile_with_invalid_date
117
- response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly, :starting_at => Time.now)
107
+ response = @gateway.recurring(1000, @credit_card, :periodicity => :monthly, :starting_at => Time.now)
118
108
  assert_failure response
119
109
  assert_equal 'Field format error: Start or next payment date must be a valid future date', response.message
120
110
  assert response.params['profile_id'].blank?
@@ -122,7 +112,7 @@ class RemotePayflowTest < Test::Unit::TestCase
122
112
  end
123
113
 
124
114
  def test_create_and_cancel_recurring_profile
125
- response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly)
115
+ response = @gateway.recurring(1000, @credit_card, :periodicity => :monthly)
126
116
  assert_success response
127
117
  assert !response.params['profile_id'].blank?
128
118
  assert response.test?
@@ -140,7 +130,7 @@ class RemotePayflowTest < Test::Unit::TestCase
140
130
  :starting_at => Time.now + 1.day,
141
131
  :comment => "Test Profile"
142
132
  )
143
- response = @gateway.recurring(100, @creditcard, @options)
133
+ response = @gateway.recurring(100, @credit_card, @options)
144
134
  assert_equal "Approved", response.params['message']
145
135
  assert_equal "0", response.params['result']
146
136
  assert_success response
@@ -155,7 +145,7 @@ class RemotePayflowTest < Test::Unit::TestCase
155
145
  :payments => '4',
156
146
  :profile_id => @recurring_profile_id
157
147
  )
158
- response = @gateway.recurring(400, @creditcard, @options)
148
+ response = @gateway.recurring(400, @credit_card, @options)
159
149
  assert_equal "Approved", response.params['message']
160
150
  assert_equal "0", response.params['result']
161
151
  assert_success response
@@ -167,6 +157,12 @@ class RemotePayflowTest < Test::Unit::TestCase
167
157
  assert_success response
168
158
  assert response.test?
169
159
 
160
+ # Test payment history inquiry
161
+ response = @gateway.recurring_inquiry(@recurring_profile_id, :history => true)
162
+ assert_equal '0', response.params['result']
163
+ assert_success response
164
+ assert response.test?
165
+
170
166
  # Test cancel
171
167
  response = @gateway.cancel_recurring(@recurring_profile_id)
172
168
  assert_equal "Approved", response.params['message']
@@ -177,7 +173,7 @@ class RemotePayflowTest < Test::Unit::TestCase
177
173
 
178
174
  # Note that this test will only work if you enable reference transactions!!
179
175
  def test_reference_purchase
180
- assert response = @gateway.purchase(10000, @creditcard, @options)
176
+ assert response = @gateway.purchase(10000, @credit_card, @options)
181
177
  assert_equal "Approved", response.message
182
178
  assert_success response
183
179
  assert response.test?
@@ -191,7 +187,7 @@ class RemotePayflowTest < Test::Unit::TestCase
191
187
  end
192
188
 
193
189
  def test_recurring_with_initial_authorization
194
- response = @gateway.recurring(1000, @creditcard,
190
+ response = @gateway.recurring(1000, @credit_card,
195
191
  :periodicity => :monthly,
196
192
  :initial_transaction => {
197
193
  :type => :authorization
@@ -204,7 +200,7 @@ class RemotePayflowTest < Test::Unit::TestCase
204
200
  end
205
201
 
206
202
  def test_recurring_with_initial_authorization
207
- response = @gateway.recurring(1000, @creditcard,
203
+ response = @gateway.recurring(1000, @credit_card,
208
204
  :periodicity => :monthly,
209
205
  :initial_transaction => {
210
206
  :type => :purchase,
@@ -220,7 +216,7 @@ class RemotePayflowTest < Test::Unit::TestCase
220
216
  def test_purchase_and_referenced_credit
221
217
  amount = 100
222
218
 
223
- assert purchase = @gateway.purchase(amount, @creditcard, @options)
219
+ assert purchase = @gateway.purchase(amount, @credit_card, @options)
224
220
  assert_success purchase
225
221
  assert_equal 'Approved', purchase.message
226
222
  assert !purchase.authorization.blank?
@@ -235,7 +231,7 @@ class RemotePayflowTest < Test::Unit::TestCase
235
231
  # Non-referenced credits will fail with Result code 117 (failed the security
236
232
  # check) unless Allow non-referenced credits = Yes in PayPal manager
237
233
  def test_purchase_and_non_referenced_credit
238
- assert credit = @gateway.credit(100, @creditcard, @options)
234
+ assert credit = @gateway.credit(100, @credit_card, @options)
239
235
  assert_success credit
240
236
  end
241
237
  end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemotePayflowUkTest < Test::Unit::TestCase
4
4
  def setup
@@ -37,17 +37,18 @@ class RemotePayflowUkTest < Test::Unit::TestCase
37
37
  :last_name => 'Brooks'
38
38
  )
39
39
 
40
- @options = { :address => {
41
- :name => 'Cody Fauser',
42
- :address1 => '1234 Shady Brook Lane',
43
- :city => 'Ottawa',
44
- :state => 'ON',
45
- :country => 'CA',
46
- :zip => '90210',
47
- :phone => '555-555-5555'
48
- },
49
- :email => 'cody@example.com'
50
- }
40
+ @options = {
41
+ :billing_address => {
42
+ :name => 'Cody Fauser',
43
+ :address1 => '1234 Shady Brook Lane',
44
+ :city => 'Ottawa',
45
+ :state => 'ON',
46
+ :country => 'CA',
47
+ :zip => '90210',
48
+ :phone => '555-555-5555'
49
+ },
50
+ :email => 'cody@example.com'
51
+ }
51
52
  end
52
53
 
53
54
  def test_successful_purchase
@@ -1,31 +1,24 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class RemotePaymentExpressTest < Test::Unit::TestCase
4
- LOGIN = 'LOGIN'
5
- PASSWORD = 'PASSWORD'
6
-
4
+
7
5
  def setup
8
6
  @gateway = PaymentExpressGateway.new(fixtures(:payment_express))
9
7
 
10
- @creditcard = credit_card('4111111111111111')
8
+ @credit_card = credit_card
11
9
 
12
10
  @options = {
13
- :address => {
14
- :name => 'Cody Fauser',
15
- :address1 => '1234 Shady Brook Lane',
16
- :city => 'Ottawa',
17
- :state => 'ON',
18
- :country => 'CA',
19
- :zip => '90210',
20
- :phone => '555-555-5555'
21
- },
22
- :email => 'cody@example.com',
23
- :description => 'Store purchase'
11
+ :order_id => generate_unique_id,
12
+ :billing_address => address,
13
+ :email => 'cody@example.com',
14
+ :description => 'Store purchase'
24
15
  }
16
+
17
+ @amount = 100
25
18
  end
26
19
 
27
20
  def test_successful_purchase
28
- assert response = @gateway.purchase(100, @creditcard, @options)
21
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
29
22
  assert_equal "APPROVED", response.message
30
23
  assert_success response
31
24
  assert response.test?
@@ -33,8 +26,7 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
33
26
  end
34
27
 
35
28
  def test_successful_purchase_with_reference_id
36
- @options[:order_id] = rand(100000)
37
- assert response = @gateway.purchase(100, @creditcard, @options)
29
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
38
30
  assert_equal "APPROVED", response.message
39
31
  assert_success response
40
32
  assert response.test?
@@ -42,14 +34,14 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
42
34
  end
43
35
 
44
36
  def test_declined_purchase
45
- assert response = @gateway.purchase(176, @creditcard, @options)
37
+ assert response = @gateway.purchase(176, @credit_card, @options)
46
38
  assert_equal 'DECLINED', response.message
47
39
  assert_failure response
48
40
  assert response.test?
49
41
  end
50
42
 
51
43
  def test_successful_authorization
52
- assert response = @gateway.authorize(100, @creditcard, @options)
44
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
53
45
  assert_equal "APPROVED", response.message
54
46
  assert_success response
55
47
  assert response.test?
@@ -57,18 +49,17 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
57
49
  end
58
50
 
59
51
  def test_authorize_and_capture
60
- amount = 100
61
- assert auth = @gateway.authorize(amount, @creditcard, @options)
52
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
62
53
  assert_success auth
63
54
  assert_equal 'APPROVED', auth.message
64
55
  assert auth.authorization
65
- assert capture = @gateway.capture(amount, auth.authorization)
56
+ assert capture = @gateway.capture(@amount, auth.authorization)
66
57
  assert_success capture
67
58
  end
68
59
 
69
60
  def test_purchase_and_credit
70
61
  amount = 10000
71
- assert purchase = @gateway.purchase(amount, @creditcard, @options)
62
+ assert purchase = @gateway.purchase(amount, @credit_card, @options)
72
63
  assert_success purchase
73
64
  assert_equal 'APPROVED', purchase.message
74
65
  assert !purchase.authorization.blank?
@@ -77,7 +68,7 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
77
68
  end
78
69
 
79
70
  def test_failed_capture
80
- assert response = @gateway.capture(100, '999')
71
+ assert response = @gateway.capture(@amount, '999')
81
72
  assert_failure response
82
73
  assert_equal 'IVL DPSTXNREF', response.message
83
74
  end
@@ -87,13 +78,13 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
87
78
  :login => '',
88
79
  :password => ''
89
80
  )
90
- assert response = gateway.purchase(100, @creditcard, @options)
81
+ assert response = gateway.purchase(@amount, @credit_card, @options)
91
82
  assert_equal 'Invalid Credentials', response.message
92
83
  assert_failure response
93
84
  end
94
85
 
95
86
  def test_store_credit_card
96
- assert response = @gateway.store(@creditcard)
87
+ assert response = @gateway.store(@credit_card)
97
88
  assert_success response
98
89
  assert_equal "APPROVED", response.message
99
90
  assert !response.token.blank?
@@ -102,7 +93,7 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
102
93
 
103
94
  def test_store_with_custom_token
104
95
  token = Time.now.to_i.to_s #hehe
105
- assert response = @gateway.store(@creditcard, :billing_id => token)
96
+ assert response = @gateway.store(@credit_card, :billing_id => token)
106
97
  assert_success response
107
98
  assert_equal "APPROVED", response.message
108
99
  assert !response.token.blank?
@@ -111,26 +102,25 @@ class RemotePaymentExpressTest < Test::Unit::TestCase
111
102
  end
112
103
 
113
104
  def test_store_invalid_credit_card
114
- original_number = @creditcard.number
115
- @creditcard.number = 2
105
+ original_number = @credit_card.number
106
+ @credit_card.number = 2
116
107
 
117
- assert response = @gateway.store(@creditcard)
108
+ assert response = @gateway.store(@credit_card)
118
109
  assert_failure response
119
110
  ensure
120
- @creditcard.number = original_number
111
+ @credit_card.number = original_number
121
112
  end
122
113
 
123
114
  def test_store_and_charge
124
- assert response = @gateway.store(@creditcard)
115
+ assert response = @gateway.store(@credit_card)
125
116
  assert_success response
126
117
  assert_equal "APPROVED", response.message
127
118
  assert (token = response.token)
128
119
 
129
- assert purchase = @gateway.purchase( 100, token)
120
+ assert purchase = @gateway.purchase( @amount, token)
130
121
  assert_equal "APPROVED", purchase.message
131
122
  assert_success purchase
132
123
  assert_not_nil purchase.authorization
133
124
  end
134
125
 
135
-
136
126
  end