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
data/test/fixtures.yml CHANGED
@@ -58,6 +58,11 @@ linkpoint:
58
58
  moneris:
59
59
  login: store1
60
60
  password: yesguy
61
+
62
+ # Working credentials, no need to replace
63
+ # Contact Netbilling for login info to the admin area
64
+ netbilling:
65
+ login: '104901072025'
61
66
 
62
67
  net_registry:
63
68
  login: X
@@ -83,13 +88,21 @@ payment_express:
83
88
  password: PASSWORD
84
89
 
85
90
  # You can use either your API PEM file or API signature with PayPal.
86
- paypal:
91
+ paypal_certificate:
87
92
  login: LOGIN
88
93
  password: PASSWORD
89
94
  subject:
90
- signature:
91
95
  pem: |--
92
96
  PASTE YOUR PEM FILE HERE
97
+
98
+ paypal_signature:
99
+ login: LOGIN
100
+ password: PASSWORD
101
+ signature: SIGNATURE
102
+
103
+ pay_secure:
104
+ login: LOGIN
105
+ password: PASSWORD
93
106
 
94
107
  plugnpay:
95
108
  login: LOGIN
@@ -226,7 +239,16 @@ realex_mastercard_coms_error:
226
239
  secure_pay:
227
240
  login: LOGIN
228
241
  password: PASSWORD
229
-
242
+
243
+ secure_pay_tech:
244
+ login: TESTDIGISPL1
245
+ password: d557591484cb2cd12bba445aba420d2c69cd6a88
246
+
247
+ # Replace with your serial numbers for the skipjack test environment
248
+ skipjack:
249
+ login: X
250
+ password: Y
251
+
230
252
  trans_first:
231
253
  login: LOGIN
232
254
  password: PASSWORD
@@ -0,0 +1,145 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class AuthorizeNetTest < Test::Unit::TestCase
4
+ def setup
5
+ Base.mode = :test
6
+
7
+ @gateway = AuthorizeNetGateway.new(fixtures(:authorize_net))
8
+ @amount = 100
9
+ @credit_card = credit_card('4242424242424242')
10
+ @options = {
11
+ :order_id => generate_unique_id,
12
+ :billing_address => address,
13
+ :description => 'Store purchase'
14
+ }
15
+
16
+ @recurring_options = {
17
+ :amount => 100,
18
+ :subscription_name => 'Test Subscription 1',
19
+ :credit_card => @credit_card,
20
+ :billing_address => address.merge(:first_name => 'Jim', :last_name => 'Smith'),
21
+ :interval => {
22
+ :length => 1,
23
+ :unit => :months
24
+ },
25
+ :duration => {
26
+ :start_date => Date.today,
27
+ :occurrences => 1
28
+ }
29
+ }
30
+ end
31
+
32
+ def test_successful_purchase
33
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
34
+ assert_success response
35
+ assert response.test?
36
+ assert_equal 'This transaction has been approved', response.message
37
+ assert response.authorization
38
+ end
39
+
40
+ def test_expired_credit_card
41
+ @credit_card.year = 2004
42
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
43
+ assert_failure response
44
+ assert response.test?
45
+ assert_equal 'The credit card has expired', response.message
46
+ end
47
+
48
+ def test_forced_test_mode_purchase
49
+ gateway = AuthorizeNetGateway.new(fixtures(:authorize_net).update(:test => true))
50
+ assert response = gateway.purchase(@amount, @credit_card, @options)
51
+ assert_success response
52
+ assert response.test?
53
+ assert_match(/TESTMODE/, response.message)
54
+ assert response.authorization
55
+ end
56
+
57
+ def test_successful_authorization
58
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
59
+ assert_success response
60
+ assert_equal 'This transaction has been approved', response.message
61
+ assert response.authorization
62
+ end
63
+
64
+ def test_authorization_and_capture
65
+ assert authorization = @gateway.authorize(@amount, @credit_card, @options)
66
+ assert_success authorization
67
+
68
+ assert capture = @gateway.capture(@amount, authorization.authorization)
69
+ assert_success capture
70
+ assert_equal 'This transaction has been approved', capture.message
71
+ end
72
+
73
+ def test_authorization_and_void
74
+ assert authorization = @gateway.authorize(@amount, @credit_card, @options)
75
+ assert_success authorization
76
+
77
+ assert void = @gateway.void(authorization.authorization)
78
+ assert_success void
79
+ assert_equal 'This transaction has been approved', void.message
80
+ end
81
+
82
+ def test_bad_login
83
+ gateway = AuthorizeNetGateway.new(
84
+ :login => 'X',
85
+ :password => 'Y'
86
+ )
87
+
88
+ assert response = gateway.purchase(@amount, @credit_card)
89
+
90
+ assert_equal Response, response.class
91
+ assert_equal ["avs_result_code",
92
+ "card_code",
93
+ "response_code",
94
+ "response_reason_code",
95
+ "response_reason_text",
96
+ "transaction_id"], response.params.keys.sort
97
+
98
+ assert_match(/The merchant login ID or password is invalid/, response.message)
99
+
100
+ assert_equal false, response.success?
101
+ end
102
+
103
+ def test_using_test_request
104
+ gateway = AuthorizeNetGateway.new(
105
+ :login => 'X',
106
+ :password => 'Y'
107
+ )
108
+
109
+ assert response = gateway.purchase(@amount, @credit_card)
110
+
111
+ assert_equal Response, response.class
112
+ assert_equal ["avs_result_code",
113
+ "card_code",
114
+ "response_code",
115
+ "response_reason_code",
116
+ "response_reason_text",
117
+ "transaction_id"], response.params.keys.sort
118
+
119
+ assert_match(/The merchant login ID or password is invalid/, response.message)
120
+
121
+ assert_equal false, response.success?
122
+ end
123
+
124
+ def test_successful_recurring
125
+ assert response = @gateway.recurring(@amount, @credit_card, @recurring_options)
126
+ assert_success response
127
+ assert response.test?
128
+
129
+ subscription_id = response.authorization
130
+
131
+ assert response = @gateway.update_recurring(:subscription_id => subscription_id, :amount => @amount * 2)
132
+ assert_success response.success?
133
+
134
+ assert response = @gateway.cancel_recurring(subscription_id)
135
+ assert_success response
136
+ end
137
+
138
+ def test_recurring_should_fail_expired_credit_card
139
+ @credit_card.year = 2004
140
+ assert response = @gateway.recurring(@amount, @credit_card, @recurring_options)
141
+ assert_failure response
142
+ assert response.test?
143
+ assert_equal 'E00018', response.params['code']
144
+ end
145
+ end
@@ -0,0 +1,118 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class RemoteBrainTreeTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = BrainTreeGateway.new(fixtures(:brain_tree))
6
+
7
+ @amount = rand(10000) + 1001
8
+ @credit_card = credit_card('4111111111111111', :type => 'visa')
9
+ @declined_amount = rand(99)
10
+ @options = { :order_id => generate_unique_id,
11
+ :billing_address => address
12
+ }
13
+ end
14
+
15
+ def test_successful_purchase
16
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
17
+ assert_equal 'This transaction has been approved', response.message
18
+ assert_success response
19
+ end
20
+
21
+ def test_successful_purchase_with_echeck
22
+ check = ActiveMerchant::Billing::Check.new(
23
+ :name => 'Fredd Bloggs',
24
+ :routing_number => '111000025', # Valid ABA # - Bank of America, TX
25
+ :account_number => '999999999999',
26
+ :account_holder_type => 'personal',
27
+ :account_type => 'checking'
28
+ )
29
+ assert response = @gateway.purchase(@amount, check, @options)
30
+ assert_equal 'This transaction has been approved', response.message
31
+ assert_success response
32
+ end
33
+
34
+ def test_successful_add_to_vault
35
+ @options[:store] = true
36
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
37
+ assert_equal 'This transaction has been approved', response.message
38
+ assert_success response
39
+ assert_not_nil response.params["customer_vault_id"]
40
+ end
41
+
42
+ def test_successful_add_to_vault_and_use
43
+ @options[:store] = true
44
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
45
+ assert_equal 'This transaction has been approved', response.message
46
+ assert_success response
47
+ assert_not_nil customer_id = response.params["customer_vault_id"]
48
+
49
+ assert second_response = @gateway.purchase(@amount*2, customer_id, @options)
50
+ assert_equal 'This transaction has been approved', second_response.message
51
+ assert second_response.success?
52
+ end
53
+
54
+ def test_add_to_vault_with_custom_vault_id
55
+ @options[:store] = rand(100000)+10001
56
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
57
+ assert_equal 'This transaction has been approved', response.message
58
+ assert_success response
59
+ assert_equal @options[:store], response.params["customer_vault_id"].to_i
60
+ end
61
+
62
+ def test_update_vault
63
+ test_add_to_vault_with_custom_vault_id
64
+ @credit_card = credit_card('4111111111111111', :month => 10)
65
+ assert response = @gateway.update(@options[:store], @credit_card)
66
+ assert_success response
67
+ assert_equal 'Customer Update Successful', response.message
68
+ end
69
+
70
+ def test_delete_from_vault
71
+ test_add_to_vault_with_custom_vault_id
72
+ assert response = @gateway.delete(@options[:store])
73
+ assert_success response
74
+ assert_equal 'Customer Deleted', response.message
75
+ end
76
+
77
+ def test_declined_purchase
78
+ assert response = @gateway.purchase(@declined_amount, @credit_card, @options)
79
+ assert_equal 'This transaction has been declined', response.message
80
+ assert_failure response
81
+ end
82
+
83
+ def test_authorize_and_capture
84
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
85
+ assert_success auth
86
+ assert_equal 'This transaction has been approved', auth.message
87
+ assert auth.authorization
88
+ assert capture = @gateway.capture(@amount, auth.authorization)
89
+ assert_equal 'This transaction has been approved', capture.message
90
+ assert_success capture
91
+ end
92
+
93
+ def test_authorize_and_void
94
+ assert auth = @gateway.authorize(@amount, @credit_card, @options)
95
+ assert_success auth
96
+ assert_equal 'This transaction has been approved', auth.message
97
+ assert auth.authorization
98
+ assert void = @gateway.void(auth.authorization)
99
+ assert_equal 'Transaction Void Successful', void.message
100
+ assert_success void
101
+ end
102
+
103
+ def test_failed_capture
104
+ assert response = @gateway.capture(@amount, '')
105
+ assert_failure response
106
+ assert response.message.match(/Invalid Transaction ID \/ Object ID specified:/)
107
+ end
108
+
109
+ def test_invalid_login
110
+ gateway = BrainTreeGateway.new(
111
+ :login => '',
112
+ :password => ''
113
+ )
114
+ assert response = gateway.purchase(@amount, @credit_card, @options)
115
+ assert_equal 'Invalid Username', response.message
116
+ assert_failure response
117
+ end
118
+ end
@@ -1,89 +1,77 @@
1
- # Portions of the Cardstream gateway by Jonah Fox and Thomas Nichols
2
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require File.dirname(__FILE__) + '/../../test_helper'
3
2
 
4
3
  class RemoteCardStreamTest < Test::Unit::TestCase
5
4
  def setup
5
+ Base.mode = :test
6
+
6
7
  @gateway = CardStreamGateway.new(fixtures(:card_stream))
7
8
 
8
- @amex = CreditCard.new(
9
- :number => '374245455400001',
10
- :month => 12,
11
- :year => 2009,
12
- :verification_value => 4887,
13
- :first_name => 'Longbob',
14
- :last_name => 'Longsen',
15
- :type => :american_express
16
- )
9
+ @amex = credit_card('374245455400001',
10
+ :month => 12,
11
+ :year => 2009,
12
+ :verification_value => 4887,
13
+ :type => :american_express
14
+ )
17
15
 
18
- @maestro = CreditCard.new(
19
- :number => '6759016800000120097',
20
- :month => 6,
21
- :year => 2009,
22
- :issue_number => 1,
23
- :verification_value => 701,
24
- :first_name => 'Longbob',
25
- :last_name => 'Longsen',
26
- :type => :maestro
27
- )
16
+ @uk_maestro = credit_card('6759016800000120097',
17
+ :month => 6,
18
+ :year => 2009,
19
+ :issue_number => 1,
20
+ :verification_value => 701,
21
+ :type => :switch
22
+ )
28
23
 
29
- @solo = CreditCard.new(
30
- :number => '6334960300099354',
31
- :month => 6,
32
- :year => 2008,
33
- :issue_number => 1,
34
- :verification_value => 227,
35
- :first_name => 'Longbob',
36
- :last_name => 'Longsen',
37
- :type => :solo
38
- )
24
+ @solo = credit_card('6334960300099354',
25
+ :month => 6,
26
+ :year => 2008,
27
+ :issue_number => 1,
28
+ :verification_value => 227,
29
+ :type => :solo
30
+ )
39
31
 
40
- @mastercard = CreditCard.new(
41
- :number => '5301250070000191',
42
- :month => 12,
43
- :year => 2009,
44
- :verification_value => 419,
45
- :first_name => 'Longbob',
46
- :last_name => 'Longsen',
47
- :type => :master
48
- )
32
+ @mastercard = credit_card('5301250070000191',
33
+ :month => 12,
34
+ :year => 2009,
35
+ :verification_value => 419,
36
+ :type => :master
37
+ )
49
38
 
50
- @declined_card = CreditCard.new(
51
- :number => '4000300011112220',
52
- :month => 9,
53
- :year => 2009,
54
- :first_name => 'Longbob',
55
- :last_name => 'Longsen'
56
- )
39
+ @declined_card = credit_card('4000300011112220',
40
+ :month => 9,
41
+ :year => 2009
42
+ )
57
43
 
58
44
  @mastercard_options = {
59
- :address => { :address1 => '25 The Larches',
60
- :city => "Narborough",
61
- :state => "Leicester",
62
- :zip => 'LE10 2RT'
63
- },
64
- :order_id => generate_order_id,
45
+ :billing_address => {
46
+ :address1 => '25 The Larches',
47
+ :city => "Narborough",
48
+ :state => "Leicester",
49
+ :zip => 'LE10 2RT'
50
+ },
51
+ :order_id => generate_unique_id,
65
52
  :description => 'Store purchase'
66
53
  }
67
54
 
68
- @maestro_options = {
69
- :address => { :address1 => 'The Parkway',
70
- :address2 => "Larches Approach",
71
- :city => "Hull",
72
- :state => "North Humberside",
73
- :zip => 'HU7 9OP'
74
- },
75
- :order_id => generate_order_id,
55
+ @uk_maestro_options = {
56
+ :billing_address => {
57
+ :address1 => 'The Parkway',
58
+ :address2 => "Larches Approach",
59
+ :city => "Hull",
60
+ :state => "North Humberside",
61
+ :zip => 'HU7 9OP'
62
+ },
63
+ :order_id => generate_unique_id,
76
64
  :description => 'Store purchase'
77
65
  }
78
66
 
79
67
  @solo_options = {
80
- :address => {
68
+ :billing_address => {
81
69
  :address1 => '5 Zigzag Road',
82
70
  :city => 'Isleworth',
83
71
  :state => 'Middlesex',
84
72
  :zip => 'TW7 8FF'
85
73
  },
86
- :order_id => generate_order_id,
74
+ :order_id => generate_unique_id,
87
75
  :description => 'Store purchase'
88
76
  }
89
77
  end
@@ -112,7 +100,7 @@ class RemoteCardStreamTest < Test::Unit::TestCase
112
100
  end
113
101
 
114
102
  def test_successful_maestro_purchase
115
- assert response = @gateway.purchase(100, @maestro, @maestro_options)
103
+ assert response = @gateway.purchase(100, @uk_maestro, @uk_maestro_options)
116
104
  assert_equal 'APPROVED', response.message
117
105
  assert_success response
118
106
  end
@@ -126,7 +114,7 @@ class RemoteCardStreamTest < Test::Unit::TestCase
126
114
  end
127
115
 
128
116
  def test_successful_amex_purchase
129
- assert response = @gateway.purchase(100, @amex, :order_id => generate_order_id)
117
+ assert response = @gateway.purchase(100, @amex, :order_id => generate_unique_id)
130
118
  assert_equal 'APPROVED', response.message
131
119
  assert_success response
132
120
  assert response.test?
@@ -134,8 +122,8 @@ class RemoteCardStreamTest < Test::Unit::TestCase
134
122
  end
135
123
 
136
124
  def test_maestro_missing_start_date_and_issue_date
137
- @maestro.issue_number = nil
138
- assert response = @gateway.purchase(100, @maestro, @maestro_options)
125
+ @uk_maestro.issue_number = nil
126
+ assert response = @gateway.purchase(100, @uk_maestro, @uk_maestro_options)
139
127
  assert_equal 'ISSUE NUMBER MISSING', response.message
140
128
  assert_failure response
141
129
  assert response.test?
@@ -152,7 +140,7 @@ class RemoteCardStreamTest < Test::Unit::TestCase
152
140
  end
153
141
 
154
142
  def test_unsupported_merchant_currency
155
- assert response = @gateway.purchase(100, @mastercard, @mastercard_options)
143
+ assert response = @gateway.purchase(100, @mastercard, @mastercard_options.update(:currency => 'USD'))
156
144
  assert_equal "ERROR 5456:CURRENCY NOT SUPPORTED FOR THIS MERCHANT ACCOUNT", response.message
157
145
  assert_failure response
158
146
  assert response.test?