tomriley-active_merchant 1.4.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +442 -0
- data/CONTRIBUTERS +102 -0
- data/MIT-LICENSE +20 -0
- data/README +134 -0
- data/Rakefile +153 -0
- data/active_merchant.gemspec +15 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +4 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +159 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
- 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 +158 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +646 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +702 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +98 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +595 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
- data/lib/active_merchant/billing/gateways/eway.rb +272 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +396 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +205 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +325 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +108 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +130 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
- data/lib/active_merchant/billing/gateways/protx.rb +349 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +306 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
- data/lib/active_merchant/billing/gateways/realex.rb +200 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +442 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +254 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +26 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +165 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/gateways.rb +3 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +22 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +81 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +156 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +22 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +83 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +26 -0
- data/lib/active_merchant/billing/integrations/helper.rb +93 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +87 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +118 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +40 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +18 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations.rb +22 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/lib/connection.rb +170 -0
- data/lib/active_merchant/lib/country.rb +319 -0
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +47 -0
- data/lib/active_merchant/lib/requires_parameters.rb +16 -0
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +76 -0
- data/lib/active_merchant.rb +60 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/support/gateway_support.rb +58 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/fixtures.yml +330 -0
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
- data/test/remote/gateways/remote_beanstream_test.rb +150 -0
- data/test/remote/gateways/remote_braintree_test.rb +154 -0
- data/test/remote/gateways/remote_card_stream_test.rb +148 -0
- data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
- data/test/remote/gateways/remote_data_cash_test.rb +357 -0
- data/test/remote/gateways/remote_efsnet_test.rb +81 -0
- data/test/remote/gateways/remote_eway_test.rb +74 -0
- data/test/remote/gateways/remote_exact_test.rb +60 -0
- data/test/remote/gateways/remote_instapay_test.rb +61 -0
- data/test/remote/gateways/remote_linkpoint_test.rb +112 -0
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
- data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/remote/gateways/remote_net_registry_test.rb +85 -0
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
- data/test/remote/gateways/remote_payflow_test.rb +237 -0
- data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
- data/test/remote/gateways/remote_payment_express_test.rb +136 -0
- data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
- data/test/remote/gateways/remote_paypal_test.rb +167 -0
- data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
- data/test/remote/gateways/remote_protx_test.rb +219 -0
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/remote/gateways/remote_psl_card_test.rb +125 -0
- data/test/remote/gateways/remote_quickpay_test.rb +190 -0
- data/test/remote/gateways/remote_realex_test.rb +224 -0
- data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
- data/test/remote/gateways/remote_sage_test.rb +87 -0
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
- data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
- 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/gateways/remote_trans_first_test.rb +34 -0
- data/test/remote/gateways/remote_transax_test.rb +112 -0
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
- data/test/remote/gateways/remote_verifi_test.rb +107 -0
- data/test/remote/gateways/remote_viaklix_test.rb +43 -0
- data/test/remote/gateways/remote_wirecard_test.rb +111 -0
- data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
- data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
- data/test/test_helper.rb +182 -0
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +55 -0
- data/test/unit/check_test.rb +88 -0
- data/test/unit/connection_test.rb +129 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +19 -0
- data/test/unit/credit_card_methods_test.rb +170 -0
- data/test/unit/credit_card_test.rb +318 -0
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +21 -0
- data/test/unit/gateways/authorize_net_cim_test.rb +638 -0
- data/test/unit/gateways/authorize_net_test.rb +290 -0
- data/test/unit/gateways/beanstream_interac_test.rb +51 -0
- data/test/unit/gateways/beanstream_test.rb +108 -0
- data/test/unit/gateways/bogus_test.rb +46 -0
- data/test/unit/gateways/braintree_test.rb +126 -0
- data/test/unit/gateways/card_stream_test.rb +90 -0
- data/test/unit/gateways/cyber_source_test.rb +188 -0
- data/test/unit/gateways/data_cash_test.rb +133 -0
- data/test/unit/gateways/efsnet_test.rb +123 -0
- data/test/unit/gateways/eway_test.rb +118 -0
- data/test/unit/gateways/exact_test.rb +156 -0
- data/test/unit/gateways/gateway_test.rb +48 -0
- data/test/unit/gateways/instapay_test.rb +102 -0
- data/test/unit/gateways/linkpoint_test.rb +167 -0
- data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
- data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
- data/test/unit/gateways/moneris_test.rb +158 -0
- data/test/unit/gateways/net_registry_test.rb +416 -0
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/pay_junction_test.rb +123 -0
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +173 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
- data/test/unit/gateways/payflow_test.rb +305 -0
- data/test/unit/gateways/payflow_uk_test.rb +30 -0
- data/test/unit/gateways/payment_express_test.rb +195 -0
- data/test/unit/gateways/paypal_express_test.rb +382 -0
- data/test/unit/gateways/paypal_test.rb +520 -0
- data/test/unit/gateways/plugnpay_test.rb +86 -0
- data/test/unit/gateways/protx_test.rb +139 -0
- data/test/unit/gateways/psigate_test.rb +169 -0
- data/test/unit/gateways/psl_card_test.rb +64 -0
- data/test/unit/gateways/quickpay_test.rb +112 -0
- data/test/unit/gateways/realex_test.rb +151 -0
- data/test/unit/gateways/sage_bankcard_test.rb +162 -0
- data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
- data/test/unit/gateways/secure_pay_au_test.rb +207 -0
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +87 -0
- data/test/unit/gateways/skip_jack_test.rb +133 -0
- data/test/unit/gateways/trans_first_test.rb +112 -0
- data/test/unit/gateways/trust_commerce_test.rb +90 -0
- data/test/unit/gateways/usa_epay_test.rb +128 -0
- data/test/unit/gateways/verifi_test.rb +96 -0
- data/test/unit/gateways/viaklix_test.rb +78 -0
- data/test/unit/gateways/wirecard_test.rb +250 -0
- 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 +50 -0
- data/test/unit/integrations/bogus_module_test.rb +20 -0
- data/test/unit/integrations/chronopay_module_test.rb +13 -0
- data/test/unit/integrations/gestpay_module_test.rb +14 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +13 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +54 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +28 -0
- data/test/unit/integrations/quickpay_module_test.rb +9 -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 +13 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/posts_data_test.rb +48 -0
- data/test/unit/response_test.rb +28 -0
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +60 -0
- metadata +364 -0
@@ -0,0 +1,459 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
class AuthorizeNetCimTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Base.mode = :test
|
7
|
+
|
8
|
+
@gateway = AuthorizeNetCimGateway.new(fixtures(:authorize_net))
|
9
|
+
@amount = 100
|
10
|
+
@credit_card = credit_card('4242424242424242')
|
11
|
+
@payment = {
|
12
|
+
:credit_card => @credit_card
|
13
|
+
}
|
14
|
+
@profile = {
|
15
|
+
:merchant_customer_id => 'Up to 20 chars', # Optional
|
16
|
+
:description => 'Up to 255 Characters', # Optional
|
17
|
+
:email => 'Up to 255 Characters', # Optional
|
18
|
+
:payment_profiles => { # Optional
|
19
|
+
:customer_type => 'individual', # Optional
|
20
|
+
:bill_to => @address,
|
21
|
+
:payment => @payment
|
22
|
+
},
|
23
|
+
:ship_to_list => {
|
24
|
+
:first_name => 'John',
|
25
|
+
:last_name => 'Doe',
|
26
|
+
:company => 'Widgets, Inc',
|
27
|
+
:address1 => '1234 Fake Street',
|
28
|
+
:city => 'Anytown',
|
29
|
+
:state => 'MD',
|
30
|
+
:zip => '12345',
|
31
|
+
:country => 'USA',
|
32
|
+
:phone_number => '(123)123-1234', # Optional - Up to 25 digits (no letters)
|
33
|
+
:fax_number => '(123)123-1234' # Optional - Up to 25 digits (no letters)
|
34
|
+
}
|
35
|
+
}
|
36
|
+
@options = {
|
37
|
+
:ref_id => '1234', # Optional
|
38
|
+
:profile => @profile
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def teardown
|
43
|
+
if @customer_profile_id
|
44
|
+
assert response = @gateway.delete_customer_profile(:customer_profile_id => @customer_profile_id)
|
45
|
+
assert_success response
|
46
|
+
@customer_profile_id = nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_successful_profile_create_get_update_and_delete
|
51
|
+
assert response = @gateway.create_customer_profile(@options)
|
52
|
+
@customer_profile_id = response.authorization
|
53
|
+
|
54
|
+
assert_success response
|
55
|
+
assert response.test?
|
56
|
+
|
57
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
58
|
+
assert response.test?
|
59
|
+
assert_success response
|
60
|
+
assert_equal @customer_profile_id, response.authorization
|
61
|
+
assert_equal 'Successful.', response.message
|
62
|
+
assert response.params['profile']['payment_profiles']['customer_payment_profile_id'] =~ /\d+/, 'The customer_payment_profile_id should be a number'
|
63
|
+
assert_equal "XXXX#{@credit_card.last_digits}", response.params['profile']['payment_profiles']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in #{@credit_card.last_digits}"
|
64
|
+
assert_equal @profile[:merchant_customer_id], response.params['profile']['merchant_customer_id']
|
65
|
+
assert_equal @profile[:description], response.params['profile']['description']
|
66
|
+
assert_equal @profile[:email], response.params['profile']['email']
|
67
|
+
assert_equal @profile[:payment_profiles][:customer_type], response.params['profile']['payment_profiles']['customer_type']
|
68
|
+
assert_equal @profile[:ship_to_list][:phone_number], response.params['profile']['ship_to_list']['phone_number']
|
69
|
+
assert_equal @profile[:ship_to_list][:company], response.params['profile']['ship_to_list']['company']
|
70
|
+
|
71
|
+
assert response = @gateway.update_customer_profile(:profile => {:customer_profile_id => @customer_profile_id, :email => 'new email address'})
|
72
|
+
assert response.test?
|
73
|
+
assert_success response
|
74
|
+
assert_nil response.authorization
|
75
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
76
|
+
assert_nil response.params['profile']['merchant_customer_id']
|
77
|
+
assert_nil response.params['profile']['description']
|
78
|
+
assert_equal 'new email address', response.params['profile']['email']
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_successful_create_customer_profile_transaction_auth_only_and_then_capture_only_requests
|
82
|
+
assert response = @gateway.create_customer_profile(@options)
|
83
|
+
@customer_profile_id = response.authorization
|
84
|
+
|
85
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
86
|
+
@customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
87
|
+
|
88
|
+
assert response = @gateway.create_customer_profile_transaction(
|
89
|
+
:transaction => {
|
90
|
+
:customer_profile_id => @customer_profile_id,
|
91
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
92
|
+
:type => :auth_only,
|
93
|
+
:amount => @amount
|
94
|
+
}
|
95
|
+
)
|
96
|
+
|
97
|
+
assert response.test?
|
98
|
+
assert_success response
|
99
|
+
assert_nil response.authorization
|
100
|
+
assert_equal "This transaction has been approved.", response.params['direct_response']['message']
|
101
|
+
assert response.params['direct_response']['approval_code'] =~ /\w{6}/
|
102
|
+
assert_equal "auth_only", response.params['direct_response']['transaction_type']
|
103
|
+
assert_equal "100.00", response.params['direct_response']['amount']
|
104
|
+
|
105
|
+
approval_code = response.params['direct_response']['approval_code']
|
106
|
+
|
107
|
+
# Capture the previously authorized funds
|
108
|
+
|
109
|
+
assert response = @gateway.create_customer_profile_transaction(
|
110
|
+
:transaction => {
|
111
|
+
:customer_profile_id => @customer_profile_id,
|
112
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
113
|
+
:type => :capture_only,
|
114
|
+
:amount => @amount,
|
115
|
+
:approval_code => approval_code
|
116
|
+
}
|
117
|
+
)
|
118
|
+
|
119
|
+
assert response.test?
|
120
|
+
assert_success response
|
121
|
+
assert_nil response.authorization
|
122
|
+
assert_equal "This transaction has been approved.", response.params['direct_response']['message']
|
123
|
+
assert_equal approval_code, response.params['direct_response']['approval_code']
|
124
|
+
assert_equal "capture_only", response.params['direct_response']['transaction_type']
|
125
|
+
assert_equal "100.00", response.params['direct_response']['amount']
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_successful_create_customer_profile_transaction_auth_capture_request
|
129
|
+
assert response = @gateway.create_customer_profile(@options)
|
130
|
+
@customer_profile_id = response.authorization
|
131
|
+
|
132
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
133
|
+
@customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
134
|
+
|
135
|
+
assert response = @gateway.create_customer_profile_transaction(
|
136
|
+
:transaction => {
|
137
|
+
:customer_profile_id => @customer_profile_id,
|
138
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
139
|
+
:type => :auth_capture,
|
140
|
+
:order => {
|
141
|
+
:invoice_number => '1234',
|
142
|
+
:description => 'Test Order Description',
|
143
|
+
:purchase_order_number => '4321'
|
144
|
+
},
|
145
|
+
:amount => @amount
|
146
|
+
}
|
147
|
+
)
|
148
|
+
|
149
|
+
assert response.test?
|
150
|
+
assert_success response
|
151
|
+
assert_nil response.authorization
|
152
|
+
assert_equal "This transaction has been approved.", response.params['direct_response']['message']
|
153
|
+
assert response.params['direct_response']['approval_code'] =~ /\w{6}/
|
154
|
+
assert_equal "auth_capture", response.params['direct_response']['transaction_type']
|
155
|
+
assert_equal "100.00", response.params['direct_response']['amount']
|
156
|
+
assert_equal response.params['direct_response']['invoice_number'], '1234'
|
157
|
+
assert_equal response.params['direct_response']['order_description'], 'Test Order Description'
|
158
|
+
assert_equal response.params['direct_response']['purchase_order_number'], '4321'
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_successful_create_customer_payment_profile_request
|
162
|
+
payment_profile = @options[:profile].delete(:payment_profiles)
|
163
|
+
assert response = @gateway.create_customer_profile(@options)
|
164
|
+
@customer_profile_id = response.authorization
|
165
|
+
|
166
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
167
|
+
assert_nil response.params['profile']['payment_profiles']
|
168
|
+
|
169
|
+
assert response = @gateway.create_customer_payment_profile(
|
170
|
+
:customer_profile_id => @customer_profile_id,
|
171
|
+
:payment_profile => payment_profile
|
172
|
+
)
|
173
|
+
|
174
|
+
assert response.test?
|
175
|
+
assert_success response
|
176
|
+
assert_nil response.authorization
|
177
|
+
assert customer_payment_profile_id = response.params['customer_payment_profile_id']
|
178
|
+
assert customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{customer_payment_profile_id}"
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_successful_create_customer_payment_profile_request_with_bank_account
|
182
|
+
payment_profile = @options[:profile].delete(:payment_profiles)
|
183
|
+
assert response = @gateway.create_customer_profile(@options)
|
184
|
+
@customer_profile_id = response.authorization
|
185
|
+
|
186
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
187
|
+
assert_nil response.params['profile']['payment_profiles']
|
188
|
+
|
189
|
+
assert response = @gateway.create_customer_payment_profile(
|
190
|
+
:customer_profile_id => @customer_profile_id,
|
191
|
+
:payment_profile => {
|
192
|
+
:customer_type => 'individual', # Optional
|
193
|
+
:bill_to => @address,
|
194
|
+
:payment => {
|
195
|
+
:bank_account => {
|
196
|
+
:account_type => :checking,
|
197
|
+
:name_on_account => 'John Doe',
|
198
|
+
:echeck_type => :ccd,
|
199
|
+
:bank_name => 'Bank of America',
|
200
|
+
:routing_number => '123456789',
|
201
|
+
:account_number => '12345'
|
202
|
+
}
|
203
|
+
},
|
204
|
+
:drivers_license => {
|
205
|
+
:state => 'MD',
|
206
|
+
:number => '12345',
|
207
|
+
:date_of_birth => '1981-3-31'
|
208
|
+
},
|
209
|
+
:tax_id => '123456789'
|
210
|
+
}
|
211
|
+
)
|
212
|
+
|
213
|
+
assert response.test?
|
214
|
+
assert_success response
|
215
|
+
assert_nil response.authorization
|
216
|
+
assert customer_payment_profile_id = response.params['customer_payment_profile_id']
|
217
|
+
assert customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{customer_payment_profile_id}"
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_successful_create_customer_shipping_address_request
|
221
|
+
shipping_address = @options[:profile].delete(:ship_to_list)
|
222
|
+
assert response = @gateway.create_customer_profile(@options)
|
223
|
+
@customer_profile_id = response.authorization
|
224
|
+
|
225
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
226
|
+
assert_nil response.params['profile']['ship_to_list']
|
227
|
+
|
228
|
+
assert response = @gateway.create_customer_shipping_address(
|
229
|
+
:customer_profile_id => @customer_profile_id,
|
230
|
+
:address => shipping_address
|
231
|
+
)
|
232
|
+
|
233
|
+
assert response.test?
|
234
|
+
assert_success response
|
235
|
+
assert_nil response.authorization
|
236
|
+
assert customer_address_id = response.params['customer_address_id']
|
237
|
+
assert customer_address_id =~ /\d+/, "The customerAddressId should be numeric. It was #{customer_address_id}"
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_successful_get_customer_profile_with_multiple_payment_profiles
|
241
|
+
second_payment_profile = {
|
242
|
+
:customer_type => 'individual',
|
243
|
+
:bill_to => @address,
|
244
|
+
:payment => {
|
245
|
+
:credit_card => credit_card('1234123412341234')
|
246
|
+
}
|
247
|
+
}
|
248
|
+
assert response = @gateway.create_customer_profile(@options)
|
249
|
+
@customer_profile_id = response.authorization
|
250
|
+
|
251
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
252
|
+
|
253
|
+
assert response = @gateway.create_customer_payment_profile(
|
254
|
+
:customer_profile_id => @customer_profile_id,
|
255
|
+
:payment_profile => second_payment_profile
|
256
|
+
)
|
257
|
+
|
258
|
+
assert response.test?
|
259
|
+
assert_success response
|
260
|
+
assert_nil response.authorization
|
261
|
+
assert customer_payment_profile_id = response.params['customer_payment_profile_id']
|
262
|
+
assert customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{customer_payment_profile_id}"
|
263
|
+
|
264
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
265
|
+
assert_equal 2, response.params['profile']['payment_profiles'].size
|
266
|
+
assert_equal 'XXXX4242', response.params['profile']['payment_profiles'][0]['payment']['credit_card']['card_number']
|
267
|
+
assert_equal 'XXXX1234', response.params['profile']['payment_profiles'][1]['payment']['credit_card']['card_number']
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_successful_delete_customer_payment_profile_request
|
271
|
+
assert response = @gateway.create_customer_profile(@options)
|
272
|
+
@customer_profile_id = response.authorization
|
273
|
+
|
274
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
275
|
+
assert customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
276
|
+
|
277
|
+
assert response = @gateway.delete_customer_payment_profile(
|
278
|
+
:customer_profile_id => @customer_profile_id,
|
279
|
+
:customer_payment_profile_id => customer_payment_profile_id
|
280
|
+
)
|
281
|
+
|
282
|
+
assert response.test?
|
283
|
+
assert_success response
|
284
|
+
assert_nil response.authorization
|
285
|
+
|
286
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
287
|
+
assert_nil response.params['profile']['payment_profiles']
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_successful_delete_customer_shipping_address_request
|
291
|
+
assert response = @gateway.create_customer_profile(@options)
|
292
|
+
@customer_profile_id = response.authorization
|
293
|
+
|
294
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
295
|
+
assert customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
|
296
|
+
|
297
|
+
assert response = @gateway.delete_customer_shipping_address(
|
298
|
+
:customer_profile_id => @customer_profile_id,
|
299
|
+
:customer_address_id => customer_address_id
|
300
|
+
)
|
301
|
+
|
302
|
+
assert response.test?
|
303
|
+
assert_success response
|
304
|
+
assert_nil response.authorization
|
305
|
+
|
306
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
307
|
+
assert_nil response.params['profile']['ship_to_list']
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_successful_get_customer_payment_profile_request
|
311
|
+
assert response = @gateway.create_customer_profile(@options)
|
312
|
+
@customer_profile_id = response.authorization
|
313
|
+
|
314
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
315
|
+
assert customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
316
|
+
|
317
|
+
assert response = @gateway.get_customer_payment_profile(
|
318
|
+
:customer_profile_id => @customer_profile_id,
|
319
|
+
:customer_payment_profile_id => customer_payment_profile_id
|
320
|
+
)
|
321
|
+
|
322
|
+
assert response.test?
|
323
|
+
assert_success response
|
324
|
+
assert_nil response.authorization
|
325
|
+
assert response.params['payment_profile']['customer_payment_profile_id'] =~ /\d+/, 'The customer_payment_profile_id should be a number'
|
326
|
+
assert_equal "XXXX#{@credit_card.last_digits}", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in #{@credit_card.last_digits}"
|
327
|
+
assert_equal @profile[:payment_profiles][:customer_type], response.params['payment_profile']['customer_type']
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_successful_get_customer_shipping_address_request
|
331
|
+
assert response = @gateway.create_customer_profile(@options)
|
332
|
+
@customer_profile_id = response.authorization
|
333
|
+
|
334
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
335
|
+
assert customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
|
336
|
+
|
337
|
+
assert response = @gateway.get_customer_shipping_address(
|
338
|
+
:customer_profile_id => @customer_profile_id,
|
339
|
+
:customer_address_id => customer_address_id
|
340
|
+
)
|
341
|
+
|
342
|
+
assert response.test?
|
343
|
+
assert_success response
|
344
|
+
assert_nil response.authorization
|
345
|
+
assert response.params['address']['customer_address_id'] =~ /\d+/, 'The customer_address_id should be a number'
|
346
|
+
assert_equal @profile[:ship_to_list][:city], response.params['address']['city']
|
347
|
+
end
|
348
|
+
|
349
|
+
def test_successful_update_customer_payment_profile_request
|
350
|
+
# Create a new Customer Profile with Payment Profile
|
351
|
+
assert response = @gateway.create_customer_profile(@options)
|
352
|
+
@customer_profile_id = response.authorization
|
353
|
+
|
354
|
+
# Get the customerPaymentProfileId
|
355
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
356
|
+
assert customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
357
|
+
|
358
|
+
# Get the customerPaymentProfile
|
359
|
+
assert response = @gateway.get_customer_payment_profile(
|
360
|
+
:customer_profile_id => @customer_profile_id,
|
361
|
+
:customer_payment_profile_id => customer_payment_profile_id
|
362
|
+
)
|
363
|
+
|
364
|
+
# The value before updating
|
365
|
+
assert_equal "XXXX4242", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in 4242"
|
366
|
+
|
367
|
+
#Update the payment profile
|
368
|
+
assert response = @gateway.update_customer_payment_profile(
|
369
|
+
:customer_profile_id => @customer_profile_id,
|
370
|
+
:payment_profile => {
|
371
|
+
:customer_payment_profile_id => customer_payment_profile_id,
|
372
|
+
:payment => {
|
373
|
+
:credit_card => credit_card('1234123412341234')
|
374
|
+
}
|
375
|
+
}
|
376
|
+
)
|
377
|
+
assert response.test?
|
378
|
+
assert_success response
|
379
|
+
assert_nil response.authorization
|
380
|
+
|
381
|
+
# Get the updated payment profile
|
382
|
+
assert response = @gateway.get_customer_payment_profile(
|
383
|
+
:customer_profile_id => @customer_profile_id,
|
384
|
+
:customer_payment_profile_id => customer_payment_profile_id
|
385
|
+
)
|
386
|
+
|
387
|
+
# Show that the payment profile was updated
|
388
|
+
assert_equal "XXXX1234", response.params['payment_profile']['payment']['credit_card']['card_number'], "The card number should contain the last 4 digits of the card we passed in: 1234"
|
389
|
+
# Show that fields that were left out of the update were cleared
|
390
|
+
assert_nil response.params['payment_profile']['customer_type']
|
391
|
+
end
|
392
|
+
|
393
|
+
def test_successful_update_customer_shipping_address_request
|
394
|
+
# Create a new Customer Profile with Shipping Address
|
395
|
+
assert response = @gateway.create_customer_profile(@options)
|
396
|
+
@customer_profile_id = response.authorization
|
397
|
+
|
398
|
+
# Get the customerAddressId
|
399
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
400
|
+
assert customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
|
401
|
+
|
402
|
+
# Get the customerShippingAddress
|
403
|
+
assert response = @gateway.get_customer_shipping_address(
|
404
|
+
:customer_profile_id => @customer_profile_id,
|
405
|
+
:customer_address_id => customer_address_id
|
406
|
+
)
|
407
|
+
|
408
|
+
assert address = response.params['address']
|
409
|
+
# The value before updating
|
410
|
+
assert_equal "1234 Fake Street", address['address']
|
411
|
+
|
412
|
+
# Update the address and remove the phone_number
|
413
|
+
new_address = address.symbolize_keys.merge!(
|
414
|
+
:address => '5678 Fake Street'
|
415
|
+
)
|
416
|
+
new_address.delete(:phone_number)
|
417
|
+
|
418
|
+
#Update the shipping address
|
419
|
+
assert response = @gateway.update_customer_shipping_address(
|
420
|
+
:customer_profile_id => @customer_profile_id,
|
421
|
+
:address => new_address
|
422
|
+
)
|
423
|
+
assert response.test?
|
424
|
+
assert_success response
|
425
|
+
assert_nil response.authorization
|
426
|
+
|
427
|
+
# Get the updated shipping address
|
428
|
+
assert response = @gateway.get_customer_shipping_address(
|
429
|
+
:customer_profile_id => @customer_profile_id,
|
430
|
+
:customer_address_id => customer_address_id
|
431
|
+
)
|
432
|
+
|
433
|
+
# Show that the shipping address was updated
|
434
|
+
assert_equal "5678 Fake Street", response.params['address']['address']
|
435
|
+
# Show that fields that were left out of the update were cleared
|
436
|
+
assert_nil response.params['address']['phone_number']
|
437
|
+
end
|
438
|
+
|
439
|
+
def test_successful_validate_customer_payment_profile_request
|
440
|
+
assert response = @gateway.create_customer_profile(@options)
|
441
|
+
@customer_profile_id = response.authorization
|
442
|
+
|
443
|
+
assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
|
444
|
+
assert @customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
|
445
|
+
assert @customer_address_id = response.params['profile']['ship_to_list']['customer_address_id']
|
446
|
+
|
447
|
+
assert response = @gateway.validate_customer_payment_profile(
|
448
|
+
:customer_profile_id => @customer_profile_id,
|
449
|
+
:customer_payment_profile_id => @customer_payment_profile_id,
|
450
|
+
:customer_address_id => @customer_address_id,
|
451
|
+
:validation_mode => :live
|
452
|
+
)
|
453
|
+
|
454
|
+
assert response.test?
|
455
|
+
assert_success response
|
456
|
+
assert_nil response.authorization
|
457
|
+
assert_equal "This transaction has been approved.", response.params['direct_response']['message']
|
458
|
+
end
|
459
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require '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
|
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,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteBeanstreamInteracTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@gateway = BeanstreamInteracGateway.new(fixtures(:beanstream_interac))
|
7
|
+
|
8
|
+
@amount = 100
|
9
|
+
|
10
|
+
@options = {
|
11
|
+
:order_id => generate_unique_id,
|
12
|
+
:billing_address => {
|
13
|
+
:name => 'xiaobo zzz',
|
14
|
+
:phone => '555-555-5555',
|
15
|
+
:address1 => '1234 Levesque St.',
|
16
|
+
:address2 => 'Apt B',
|
17
|
+
:city => 'Montreal',
|
18
|
+
:state => 'QC',
|
19
|
+
:country => 'CA',
|
20
|
+
:zip => 'H2C1X8'
|
21
|
+
},
|
22
|
+
:email => 'xiaobozzz@example.com',
|
23
|
+
:subtotal => 800,
|
24
|
+
:shipping => 100,
|
25
|
+
:tax1 => 100,
|
26
|
+
:tax2 => 100,
|
27
|
+
:custom => 'reference one'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_successful_purchase
|
32
|
+
assert response = @gateway.purchase(@amount, @options)
|
33
|
+
assert_success response
|
34
|
+
assert_equal "R", response.params["responseType"]
|
35
|
+
assert_false response.redirect.blank?
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_failed_confirmation
|
39
|
+
assert response = @gateway.confirm("")
|
40
|
+
assert_failure response
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_invalid_login
|
44
|
+
gateway = BeanstreamInteracGateway.new(
|
45
|
+
:merchant_id => '',
|
46
|
+
:login => '',
|
47
|
+
:password => ''
|
48
|
+
)
|
49
|
+
assert response = gateway.purchase(@amount, @options)
|
50
|
+
assert_failure response
|
51
|
+
assert_equal 'Invalid merchant id (merchant_id = 0)', response.message
|
52
|
+
end
|
53
|
+
end
|