activemerchant 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +310 -294
- data/CONTRIBUTERS +13 -0
- data/README +55 -31
- data/Rakefile +21 -13
- data/lib/active_merchant.rb +7 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +8 -3
- data/lib/active_merchant/billing/check.rb +61 -0
- data/lib/active_merchant/billing/credit_card.rb +104 -80
- data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
- data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +28 -0
- data/lib/active_merchant/billing/gateway.rb +47 -111
- data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
- data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
- data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
- data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
- data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
- data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
- data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
- data/lib/active_merchant/billing/gateways/eway.rb +8 -19
- data/lib/active_merchant/billing/gateways/exact.rb +17 -25
- data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
- data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
- data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
- data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
- data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
- data/lib/active_merchant/billing/gateways/protx.rb +24 -25
- data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
- data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
- data/lib/active_merchant/billing/gateways/realex.rb +7 -19
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
- data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
- data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
- data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
- data/lib/active_merchant/billing/integrations.rb +2 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +12 -8
- data/lib/active_merchant/lib/posts_data.rb +39 -7
- data/lib/active_merchant/lib/requires_parameters.rb +2 -3
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +3 -3
- data/lib/support/gateway_support.rb +22 -9
- data/script/destroy +14 -0
- data/script/generate +7 -7
- data/test/fixtures.yml +25 -3
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
- data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
- data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
- data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
- data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
- data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
- data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
- data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
- data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
- data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
- data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
- data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
- data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
- data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
- data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
- data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
- data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
- data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
- data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +102 -61
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +33 -39
- data/test/unit/check_test.rb +76 -0
- data/test/unit/credit_card_formatting_test.rb +10 -15
- data/test/unit/credit_card_methods_test.rb +132 -17
- data/test/unit/credit_card_test.rb +157 -228
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +21 -0
- data/test/unit/gateways/authorize_net_test.rb +180 -40
- data/test/unit/gateways/bogus_test.rb +2 -3
- data/test/unit/gateways/brain_tree_test.rb +63 -29
- data/test/unit/gateways/card_stream_test.rb +59 -6
- data/test/unit/gateways/cyber_source_test.rb +59 -40
- data/test/unit/gateways/data_cash_test.rb +82 -1
- data/test/unit/gateways/efsnet_test.rb +97 -44
- data/test/unit/gateways/eway_test.rb +55 -42
- data/test/unit/gateways/exact_test.rb +93 -55
- data/test/unit/gateways/gateway_test.rb +7 -0
- data/test/unit/gateways/linkpoint_test.rb +60 -58
- data/test/unit/gateways/moneris_test.rb +67 -76
- data/test/unit/gateways/net_registry_test.rb +351 -419
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/pay_junction_test.rb +108 -46
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +0 -8
- data/test/unit/gateways/payflow_test.rb +136 -65
- data/test/unit/gateways/payflow_uk_test.rb +0 -38
- data/test/unit/gateways/payment_express_test.rb +31 -51
- data/test/unit/gateways/paypal_express_test.rb +8 -2
- data/test/unit/gateways/paypal_test.rb +213 -54
- data/test/unit/gateways/plugnpay_test.rb +39 -32
- data/test/unit/gateways/protx_test.rb +45 -33
- data/test/unit/gateways/psigate_test.rb +146 -87
- data/test/unit/gateways/psl_card_test.rb +37 -24
- data/test/unit/gateways/quickpay_test.rb +33 -46
- data/test/unit/gateways/realex_test.rb +32 -31
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +35 -26
- data/test/unit/gateways/skip_jack_test.rb +125 -0
- data/test/unit/gateways/trans_first_test.rb +24 -37
- data/test/unit/gateways/trust_commerce_test.rb +47 -26
- data/test/unit/gateways/usa_epay_test.rb +52 -41
- data/test/unit/gateways/verifi_test.rb +41 -35
- data/test/unit/gateways/viaklix_test.rb +38 -32
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +7 -14
- data/test/unit/integrations/bogus_module_test.rb +4 -0
- data/test/unit/integrations/chronopay_module_test.rb +4 -0
- data/test/unit/integrations/gestpay_module_test.rb +4 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +4 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
- data/test/unit/integrations/paypal_module_test.rb +4 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +4 -0
- data/test/unit/posts_data_test.rb +86 -0
- data/test/unit/response_test.rb +15 -1
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +10 -6
- metadata +180 -142
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
- data/script/generator/base.rb +0 -45
- data/script/generator/generator.rb +0 -24
- data/script/generator/generators/gateway/gateway_generator.rb +0 -14
- data/script/generator/generators/gateway/templates/gateway.rb +0 -73
- data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
- data/script/generator/generators/integration/integration_generator.rb +0 -25
- data/script/generator/generators/integration/templates/helper.rb +0 -34
- data/script/generator/generators/integration/templates/helper_test.rb +0 -54
- data/script/generator/generators/integration/templates/integration.rb +0 -18
- data/script/generator/generators/integration/templates/module_test.rb +0 -9
- data/script/generator/generators/integration/templates/notification.rb +0 -100
- data/script/generator/generators/integration/templates/notification_test.rb +0 -41
- data/script/generator/manifest.rb +0 -20
- data/test/remote_tests/remote_authorize_net_test.rb +0 -113
- data/test/remote_tests/remote_brain_tree_test.rb +0 -78
- data/test/remote_tests/remote_moneris_test.rb +0 -110
- data/test/remote_tests/remote_psigate_test.rb +0 -87
- data/test/remote_tests/remote_secure_pay_test.rb +0 -36
- data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class CVVResultTest < Test::Unit::TestCase
|
4
|
+
def test_nil_data
|
5
|
+
result = CVVResult.new(nil)
|
6
|
+
assert_nil result.code
|
7
|
+
assert_nil result.message
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_blank_data
|
11
|
+
result = CVVResult.new('')
|
12
|
+
assert_nil result.code
|
13
|
+
assert_nil result.message
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_successful_match
|
17
|
+
result = CVVResult.new('M')
|
18
|
+
assert_equal 'M', result.code
|
19
|
+
assert_equal CVVResult.messages['M'], result.message
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_failed_match
|
23
|
+
result = CVVResult.new('N')
|
24
|
+
assert_equal 'N', result.code
|
25
|
+
assert_equal CVVResult.messages['N'], result.message
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_to_hash
|
29
|
+
result = CVVResult.new('M').to_hash
|
30
|
+
assert_equal 'M', result['code']
|
31
|
+
assert_equal CVVResult.messages['M'], result['message']
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class ExpiryDateTest < Test::Unit::TestCase
|
4
|
+
def test_should_be_expired
|
5
|
+
last_month = 2.months.ago
|
6
|
+
date = CreditCard::ExpiryDate.new(last_month.month, last_month.year)
|
7
|
+
assert date.expired?
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_today_should_not_be_expired
|
11
|
+
today = Time.now
|
12
|
+
date = CreditCard::ExpiryDate.new(today.month, today.year)
|
13
|
+
assert_false date.expired?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_dates_in_the_future_should_not_be_expired
|
17
|
+
next_month = 1.month.from_now
|
18
|
+
date = CreditCard::ExpiryDate.new(next_month.month, next_month.year)
|
19
|
+
assert_false date.expired?
|
20
|
+
end
|
21
|
+
end
|
@@ -6,43 +6,36 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
6
6
|
:login => 'X',
|
7
7
|
:password => 'Y'
|
8
8
|
)
|
9
|
-
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
def test_purchase_success
|
14
|
-
@creditcard.number = 1
|
15
|
-
|
16
|
-
assert response = @gateway.purchase(100, @creditcard)
|
17
|
-
assert_equal Response, response.class
|
18
|
-
assert_equal '#0001', response.params['receiptid']
|
19
|
-
assert_equal true, response.success?
|
9
|
+
@amount = 100
|
10
|
+
@credit_card = credit_card
|
11
|
+
@subscription_id = '100748'
|
20
12
|
end
|
21
13
|
|
22
|
-
def
|
23
|
-
@
|
24
|
-
|
25
|
-
assert response = @gateway.
|
26
|
-
|
27
|
-
|
28
|
-
assert_equal
|
29
|
-
|
14
|
+
def test_successful_authorization
|
15
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
16
|
+
|
17
|
+
assert response = @gateway.authorize(@amount, @credit_card)
|
18
|
+
assert_instance_of Response, response
|
19
|
+
assert_success response
|
20
|
+
assert_equal '508141794', response.authorization
|
30
21
|
end
|
31
22
|
|
32
|
-
def
|
33
|
-
@
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
23
|
+
def test_successful_purchase
|
24
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
25
|
+
|
26
|
+
assert response = @gateway.purchase(@amount, @credit_card)
|
27
|
+
assert_instance_of Response, response
|
28
|
+
assert_success response
|
29
|
+
assert_equal '508141795', response.authorization
|
38
30
|
end
|
39
31
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
32
|
+
def test_failed_authorization
|
33
|
+
@gateway.expects(:ssl_post).returns(failed_authorization_response)
|
34
|
+
|
35
|
+
assert response = @gateway.authorize(@amount, @credit_card)
|
36
|
+
assert_instance_of Response, response
|
37
|
+
assert_failure response
|
38
|
+
assert_equal '508141794', response.authorization
|
46
39
|
end
|
47
40
|
|
48
41
|
def test_add_address_outsite_north_america
|
@@ -53,8 +46,7 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
53
46
|
assert_equal ["address", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort
|
54
47
|
assert_equal 'n/a', result[:state]
|
55
48
|
assert_equal '164 Waverley Street', result[:address]
|
56
|
-
assert_equal 'DE', result[:country]
|
57
|
-
|
49
|
+
assert_equal 'DE', result[:country]
|
58
50
|
end
|
59
51
|
|
60
52
|
def test_add_address
|
@@ -84,7 +76,7 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
84
76
|
def test_purchase_is_valid_csv
|
85
77
|
params = { :amount => '1.01' }
|
86
78
|
|
87
|
-
@gateway.send(:add_creditcard, params, @
|
79
|
+
@gateway.send(:add_creditcard, params, @credit_card)
|
88
80
|
|
89
81
|
assert data = @gateway.send(:post_data, 'AUTH_ONLY', params)
|
90
82
|
assert_equal post_data_fixture.size, data.size
|
@@ -95,7 +87,7 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
95
87
|
:amount => "1.01",
|
96
88
|
}
|
97
89
|
|
98
|
-
@gateway.send(:add_creditcard, params, @
|
90
|
+
@gateway.send(:add_creditcard, params, @credit_card)
|
99
91
|
|
100
92
|
assert data = @gateway.send(:post_data, 'AUTH_ONLY', params)
|
101
93
|
minimum_requirements.each do |key|
|
@@ -103,14 +95,19 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
103
95
|
end
|
104
96
|
end
|
105
97
|
|
106
|
-
def
|
107
|
-
|
98
|
+
def test_successful_credit
|
99
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
100
|
+
assert response = @gateway.credit(@amount, '123456789', :card_number => @credit_card.number)
|
108
101
|
assert_success response
|
102
|
+
assert_equal 'This transaction has been approved', response.message
|
109
103
|
end
|
110
104
|
|
111
|
-
def
|
112
|
-
|
105
|
+
def test_failed_credit
|
106
|
+
@gateway.expects(:ssl_post).returns(failed_credit_response)
|
107
|
+
|
108
|
+
assert response = @gateway.credit(@amount, '123456789', :card_number => @credit_card.number)
|
113
109
|
assert_failure response
|
110
|
+
assert_equal 'The referenced transaction does not meet the criteria for issuing a credit', response.message
|
114
111
|
end
|
115
112
|
|
116
113
|
def test_supported_countries
|
@@ -126,6 +123,82 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
126
123
|
assert_equal '', @gateway.send(:message_from, {})
|
127
124
|
end
|
128
125
|
end
|
126
|
+
|
127
|
+
def test_response_under_review_by_fraud_service
|
128
|
+
@gateway.expects(:ssl_post).returns(fraud_review_response)
|
129
|
+
|
130
|
+
response = @gateway.purchase(@amount, @credit_card)
|
131
|
+
assert_failure response
|
132
|
+
assert response.fraud_review?
|
133
|
+
assert_equal "Thank you! For security reasons your order is currently being reviewed", response.message
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_avs_result
|
137
|
+
@gateway.expects(:ssl_post).returns(fraud_review_response)
|
138
|
+
|
139
|
+
response = @gateway.purchase(@amount, @credit_card)
|
140
|
+
assert_equal 'X', response.avs_result['code']
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_cvv_result
|
144
|
+
@gateway.expects(:ssl_post).returns(fraud_review_response)
|
145
|
+
|
146
|
+
response = @gateway.purchase(@amount, @credit_card)
|
147
|
+
assert_equal 'M', response.cvv_result['code']
|
148
|
+
end
|
149
|
+
|
150
|
+
# ARB Unit Tests
|
151
|
+
|
152
|
+
def test_successful_recurring
|
153
|
+
@gateway.expects(:ssl_post).returns(successful_recurring_response)
|
154
|
+
|
155
|
+
response = @gateway.recurring(@amount, @credit_card,
|
156
|
+
:billing_address => address.merge(:first_name => 'Jim', :last_name => 'Smith'),
|
157
|
+
:interval => {
|
158
|
+
:length => 10,
|
159
|
+
:unit => :days
|
160
|
+
},
|
161
|
+
:duration => {
|
162
|
+
:start_date => Time.now.strftime("%Y-%m-%d"),
|
163
|
+
:occurrences => 30
|
164
|
+
}
|
165
|
+
)
|
166
|
+
|
167
|
+
assert_instance_of Response, response
|
168
|
+
assert response.success?
|
169
|
+
assert response.test?
|
170
|
+
assert_equal @subscription_id, response.authorization
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_successful_update_recurring
|
174
|
+
@gateway.expects(:ssl_post).returns(successful_update_recurring_response)
|
175
|
+
|
176
|
+
response = @gateway.update_recurring(:subscription_id => @subscription_id, :amount => @amount * 2)
|
177
|
+
|
178
|
+
assert_instance_of Response, response
|
179
|
+
assert response.success?
|
180
|
+
assert response.test?
|
181
|
+
assert_equal @subscription_id, response.authorization
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_successful_cancel_recurring
|
185
|
+
@gateway.expects(:ssl_post).returns(successful_cancel_recurring_response)
|
186
|
+
|
187
|
+
response = @gateway.cancel_recurring(@subscription_id)
|
188
|
+
|
189
|
+
assert_instance_of Response, response
|
190
|
+
assert response.success?
|
191
|
+
assert response.test?
|
192
|
+
assert_equal @subscription_id, response.authorization
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_expdate_formatting
|
196
|
+
assert_equal '2009-09', @gateway.send(:arb_expdate, @credit_card)
|
197
|
+
|
198
|
+
assert_equal '2013-11', @gateway.send(:arb_expdate, credit_card('4111111111111111',
|
199
|
+
:month => 11,
|
200
|
+
:year => 2013))
|
201
|
+
end
|
129
202
|
|
130
203
|
private
|
131
204
|
|
@@ -133,8 +206,75 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
133
206
|
'x_encap_char=%24&x_card_num=4242424242424242&x_exp_date=0806&x_card_code=123&x_type=AUTH_ONLY&x_first_name=Longbob&x_version=3.1&x_login=X&x_last_name=Longsen&x_tran_key=Y&x_relay_response=FALSE&x_delim_data=TRUE&x_delim_char=%2C&x_amount=1.01'
|
134
207
|
end
|
135
208
|
|
136
|
-
|
209
|
+
def minimum_requirements
|
137
210
|
%w(version delim_data relay_response login tran_key amount card_num exp_date type)
|
138
211
|
end
|
212
|
+
|
213
|
+
def failed_credit_response
|
214
|
+
'$3$,$2$,$54$,$The referenced transaction does not meet the criteria for issuing a credit.$,$$,$P$,$0$,$$,$$,$1.00$,$CC$,$credit$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$39265D8BA0CDD4F045B5F4129B2AAA01$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$'
|
215
|
+
end
|
216
|
+
|
217
|
+
def successful_authorization_response
|
218
|
+
'$1$,$1$,$1$,$This transaction has been approved.$,$advE7f$,$Y$,$508141794$,$5b3fe66005f3da0ebe51$,$$,$1.00$,$CC$,$auth_only$,$$,$Longbob$,$Longsen$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$2860A297E0FE804BCB9EF8738599645C$,$P$,$2$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$'
|
219
|
+
end
|
220
|
+
|
221
|
+
def successful_purchase_response
|
222
|
+
'$1$,$1$,$1$,$This transaction has been approved.$,$d1GENk$,$Y$,$508141795$,$32968c18334f16525227$,$Store purchase$,$1.00$,$CC$,$auth_capture$,$$,$Longbob$,$Longsen$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$269862C030129C1173727CC10B1935ED$,$P$,$2$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$'
|
223
|
+
end
|
224
|
+
|
225
|
+
def failed_authorization_response
|
226
|
+
'$2$,$1$,$1$,$This transaction was declined.$,$advE7f$,$Y$,$508141794$,$5b3fe66005f3da0ebe51$,$$,$1.00$,$CC$,$auth_only$,$$,$Longbob$,$Longsen$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$2860A297E0FE804BCB9EF8738599645C$,$P$,$2$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$'
|
227
|
+
end
|
228
|
+
|
229
|
+
def fraud_review_response
|
230
|
+
"$4$,$$,$253$,$Thank you! For security reasons your order is currently being reviewed.$,$$,$X$,$0$,$$,$$,$1.00$,$$,$auth_capture$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$207BCBBF78E85CF174C87AE286B472D2$,$M$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$,$$"
|
231
|
+
end
|
232
|
+
|
233
|
+
def successful_recurring_response
|
234
|
+
<<-XML
|
235
|
+
<ARBCreateSubscriptionResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
236
|
+
<refId>Sample</refId>
|
237
|
+
<messages>
|
238
|
+
<resultCode>Ok</resultCode>
|
239
|
+
<message>
|
240
|
+
<code>I00001</code>
|
241
|
+
<text>Successful.</text>
|
242
|
+
</message>
|
243
|
+
</messages>
|
244
|
+
<subscriptionId>#{@subscription_id}</subscriptionId>
|
245
|
+
</ARBCreateSubscriptionResponse>
|
246
|
+
XML
|
247
|
+
end
|
139
248
|
|
249
|
+
def successful_update_recurring_response
|
250
|
+
<<-XML
|
251
|
+
<ARBUpdateSubscriptionResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
252
|
+
<refId>Sample</refId>
|
253
|
+
<messages>
|
254
|
+
<resultCode>Ok</resultCode>
|
255
|
+
<message>
|
256
|
+
<code>I00001</code>
|
257
|
+
<text>Successful.</text>
|
258
|
+
</message>
|
259
|
+
</messages>
|
260
|
+
<subscriptionId>#{@subscription_id}</subscriptionId>
|
261
|
+
</ARBUpdateSubscriptionResponse>
|
262
|
+
XML
|
263
|
+
end
|
264
|
+
|
265
|
+
def successful_cancel_recurring_response
|
266
|
+
<<-XML
|
267
|
+
<ARBCancelSubscriptionResponse xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
|
268
|
+
<refId>Sample</refId>
|
269
|
+
<messages>
|
270
|
+
<resultCode>Ok</resultCode>
|
271
|
+
<message>
|
272
|
+
<code>I00001</code>
|
273
|
+
<text>Successful.</text>
|
274
|
+
</message>
|
275
|
+
</messages>
|
276
|
+
<subscriptionId>#{@subscription_id}</subscriptionId>
|
277
|
+
</ARBCancelSubscriptionResponse>
|
278
|
+
XML
|
279
|
+
end
|
140
280
|
end
|
@@ -4,13 +4,12 @@ class BogusTest < Test::Unit::TestCase
|
|
4
4
|
def setup
|
5
5
|
@gateway = BogusGateway.new(
|
6
6
|
:login => 'bogus',
|
7
|
-
:password => 'bogus'
|
8
|
-
:test => true
|
7
|
+
:password => 'bogus'
|
9
8
|
)
|
10
9
|
|
11
10
|
@creditcard = credit_card('1')
|
12
11
|
|
13
|
-
@response = ActiveMerchant::Billing::Response.new(true, "Transaction successful", :transid =>
|
12
|
+
@response = ActiveMerchant::Billing::Response.new(true, "Transaction successful", :transid => BogusGateway::AUTHORIZATION)
|
14
13
|
end
|
15
14
|
|
16
15
|
def test_authorize
|
@@ -8,41 +8,36 @@ class BrainTreeTest < Test::Unit::TestCase
|
|
8
8
|
:password => 'PASSWORD'
|
9
9
|
)
|
10
10
|
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
:zip => 'K1C2N6',
|
19
|
-
:country => 'Canada',
|
20
|
-
:phone => '(555)555-5555'
|
21
|
-
}
|
11
|
+
@credit_card = credit_card('4242424242424242',
|
12
|
+
:type => 'visa'
|
13
|
+
)
|
14
|
+
|
15
|
+
@amount = 100
|
16
|
+
|
17
|
+
@options = { :billing_address => address }
|
22
18
|
end
|
23
19
|
|
24
|
-
def
|
25
|
-
@
|
26
|
-
|
20
|
+
def test_successful_purchase
|
21
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
22
|
+
|
23
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
24
|
+
assert_instance_of Response, response
|
27
25
|
assert_success response
|
28
|
-
assert_equal '
|
26
|
+
assert_equal '510695343', response.authorization
|
29
27
|
end
|
30
28
|
|
31
|
-
def
|
32
|
-
@
|
33
|
-
|
29
|
+
def test_failed_purchase
|
30
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
31
|
+
|
32
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
33
|
+
assert_instance_of Response, response
|
34
34
|
assert_failure response
|
35
35
|
end
|
36
|
-
|
37
|
-
def test_request_error
|
38
|
-
@creditcard.number = 3
|
39
|
-
assert_raise(Error){ @gateway.purchase(@amount, @creditcard, {}) }
|
40
|
-
end
|
41
36
|
|
42
37
|
def test_add_address
|
43
38
|
result = {}
|
44
39
|
|
45
|
-
@gateway.send(:add_address, result,nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
|
40
|
+
@gateway.send(:add_address, result, nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
|
46
41
|
assert_equal ["address1", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort
|
47
42
|
assert_equal 'CO', result[:state]
|
48
43
|
assert_equal '164 Waverley Street', result[:address1]
|
@@ -51,27 +46,66 @@ class BrainTreeTest < Test::Unit::TestCase
|
|
51
46
|
end
|
52
47
|
|
53
48
|
def test_supported_countries
|
54
|
-
assert_equal ['US'],
|
49
|
+
assert_equal ['US'], BrainTreeGateway.supported_countries
|
55
50
|
end
|
56
51
|
|
57
52
|
def test_supported_card_types
|
58
|
-
assert_equal [:visa, :master, :american_express
|
53
|
+
assert_equal [:visa, :master, :american_express], BrainTreeGateway.supported_cardtypes
|
59
54
|
end
|
60
55
|
|
61
56
|
def test_adding_store_adds_vault_id_flag
|
62
57
|
result = {}
|
63
58
|
|
64
|
-
@gateway.send(:add_creditcard, result
|
59
|
+
@gateway.send(:add_creditcard, result, @credit_card, :store => true)
|
65
60
|
assert_equal ["ccexp", "ccnumber", "customer_vault", "cvv", "firstname", "lastname"], result.stringify_keys.keys.sort
|
66
61
|
assert_equal 'add_customer', result[:customer_vault]
|
67
|
-
|
68
62
|
end
|
63
|
+
|
69
64
|
def test_blank_store_doesnt_add_vault_flag
|
70
65
|
result = {}
|
71
66
|
|
72
|
-
@gateway.send(:add_creditcard, result
|
67
|
+
@gateway.send(:add_creditcard, result, @credit_card, {} )
|
73
68
|
assert_equal ["ccexp", "ccnumber", "cvv", "firstname", "lastname"], result.stringify_keys.keys.sort
|
74
69
|
assert_nil result[:customer_vault]
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_accept_check
|
73
|
+
post = {}
|
74
|
+
check = Check.new(:name => 'Fred Bloggs',
|
75
|
+
:routing_number => '111000025',
|
76
|
+
:account_number => '123456789012',
|
77
|
+
:account_holder_type => 'personal',
|
78
|
+
:account_type => 'checking')
|
79
|
+
@gateway.send(:add_check, post, check)
|
80
|
+
assert_equal %w[account_holder_type account_type checkaba checkaccount checkname payment], post.stringify_keys.keys.sort
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_funding_source
|
84
|
+
assert_equal :check, @gateway.send(:determine_funding_source, Check.new)
|
85
|
+
assert_equal :credit_card, @gateway.send(:determine_funding_source, @credit_card)
|
86
|
+
assert_equal :vault, @gateway.send(:determine_funding_source, '12345')
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_avs_result
|
90
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
91
|
+
|
92
|
+
response = @gateway.purchase(@amount, @credit_card)
|
93
|
+
assert_equal 'N', response.avs_result['code']
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_cvv_result
|
97
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
75
98
|
|
99
|
+
response = @gateway.purchase(@amount, @credit_card)
|
100
|
+
assert_equal 'N', response.cvv_result['code']
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
def successful_purchase_response
|
105
|
+
'response=1&responsetext=SUCCESS&authcode=123456&transactionid=510695343&avsresponse=N&cvvresponse=N&orderid=ea1e0d50dcc8cfc6e4b55650c592097e&type=sale&response_code=100'
|
106
|
+
end
|
107
|
+
|
108
|
+
def failed_purchase_response
|
109
|
+
'response=2&responsetext=DECLINE&authcode=&transactionid=510695919&avsresponse=N&cvvresponse=N&orderid=50357660b0b3ef16f72a3d3b83c46983&type=sale&response_code=200'
|
76
110
|
end
|
77
111
|
end
|