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.
- 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,82 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class MonerisRemoteTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = MonerisGateway.new(fixtures(:moneris))
|
|
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
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_successful_purchase
|
|
18
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
19
|
+
assert_success response
|
|
20
|
+
assert_equal 'Approved', response.message
|
|
21
|
+
assert_false response.authorization.blank?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_successful_authorization
|
|
25
|
+
response = @gateway.authorize(@amount, @credit_card, @options)
|
|
26
|
+
assert_success response
|
|
27
|
+
assert_false response.authorization.blank?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_failed_authorization
|
|
31
|
+
response = @gateway.authorize(105, @credit_card, @options)
|
|
32
|
+
assert_failure response
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_successful_authorization_and_capture
|
|
36
|
+
response = @gateway.authorize(@amount, @credit_card, @options)
|
|
37
|
+
assert_success response
|
|
38
|
+
assert response.authorization
|
|
39
|
+
|
|
40
|
+
response = @gateway.capture(@amount, response.authorization)
|
|
41
|
+
assert_success response
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_successful_authorization_and_void
|
|
45
|
+
response = @gateway.authorize(@amount, @credit_card, @options)
|
|
46
|
+
assert_success response
|
|
47
|
+
assert response.authorization
|
|
48
|
+
|
|
49
|
+
void = @gateway.void(response.authorization)
|
|
50
|
+
assert_success void
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_successful_purchase_and_void
|
|
54
|
+
purchase = @gateway.purchase(@amount, @credit_card, @options)
|
|
55
|
+
assert_success purchase
|
|
56
|
+
|
|
57
|
+
void = @gateway.void(purchase.authorization)
|
|
58
|
+
assert_success void
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_failed_purchase_and_void
|
|
62
|
+
purchase = @gateway.purchase(101, @credit_card, @options)
|
|
63
|
+
assert_failure purchase
|
|
64
|
+
|
|
65
|
+
void = @gateway.void(purchase.authorization)
|
|
66
|
+
assert_failure void
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_successful_purchase_and_credit
|
|
70
|
+
purchase = @gateway.purchase(@amount, @credit_card, @options)
|
|
71
|
+
assert_success purchase
|
|
72
|
+
|
|
73
|
+
credit = @gateway.credit(@amount, purchase.authorization)
|
|
74
|
+
assert_success credit
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_failed_purchase_from_error
|
|
78
|
+
assert response = @gateway.purchase(150, @credit_card, @options)
|
|
79
|
+
assert_failure response
|
|
80
|
+
assert_equal 'Declined', response.message
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
require 'test/unit'
|
|
2
|
-
require File.dirname(__FILE__) + '
|
|
2
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
3
3
|
|
|
4
|
-
######################################################################
|
|
5
|
-
#
|
|
6
4
|
# To run these tests, set the variables at the top of the class
|
|
7
5
|
# definition.
|
|
8
6
|
#
|
|
@@ -11,77 +9,42 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
|
11
9
|
# purchases through the NetRegistry console at www.netregistry.com .
|
|
12
10
|
# All purchases made in these tests are $1, so hopefully you won't be
|
|
13
11
|
# sent broke if you forget...
|
|
14
|
-
#
|
|
15
|
-
######################################################################
|
|
16
|
-
|
|
17
12
|
class NetRegistryTest < Test::Unit::TestCase
|
|
18
|
-
#
|
|
19
|
-
# Provide valid data here to run the tests.
|
|
20
|
-
#
|
|
21
|
-
# LOG_FILE_NAME may be nil, or a filename to write messages sent to
|
|
22
|
-
# and received from the gateway
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
LOG_FILE_NAME = nil
|
|
26
|
-
VALID_CARD_DETAILS = {
|
|
27
|
-
:number => '4111111111111111',
|
|
28
|
-
:month => 12,
|
|
29
|
-
:year => 2010,
|
|
30
|
-
:first_name => 'Longbob',
|
|
31
|
-
:last_name => 'Longsen',
|
|
32
|
-
:type => :visa,
|
|
33
|
-
}
|
|
34
13
|
|
|
35
14
|
def setup
|
|
36
|
-
if LOG_FILE_NAME
|
|
37
|
-
@log_file = open(LOG_FILE_NAME, 'a')
|
|
38
|
-
@logger = Logger.new(@log_file)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
15
|
@gateway = NetRegistryGateway.new(fixtures(:net_registry))
|
|
42
16
|
|
|
43
|
-
@
|
|
44
|
-
@
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
@
|
|
48
|
-
VALID_CARD_DETAILS.merge(:year => 2000)
|
|
49
|
-
)
|
|
50
|
-
@invalid_month_creditcard = CreditCard.new(
|
|
51
|
-
VALID_CARD_DETAILS.merge(:month => 13)
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def teardown
|
|
56
|
-
@log_file.close if @log_file
|
|
17
|
+
@amount = 100
|
|
18
|
+
@valid_creditcard = credit_card
|
|
19
|
+
@invalid_creditcard = credit_card('41111111111111111')
|
|
20
|
+
@expired_creditcard = credit_card('4111111111111111', :year => '2000')
|
|
21
|
+
@invalid_month_creditcard = credit_card('4111111111111111', :month => '13')
|
|
57
22
|
end
|
|
58
23
|
|
|
59
24
|
def test_successful_purchase_and_credit
|
|
60
|
-
response = @gateway.purchase(
|
|
25
|
+
response = @gateway.purchase(@amount, @valid_creditcard)
|
|
61
26
|
assert_equal 'approved', response.params['status']
|
|
62
27
|
assert_success response
|
|
63
28
|
assert_match(/\A\d{16}\z/, response.authorization)
|
|
64
29
|
|
|
65
|
-
response = @gateway.credit(
|
|
30
|
+
response = @gateway.credit(@amount, response.authorization)
|
|
66
31
|
assert_equal 'approved', response.params['status']
|
|
67
32
|
assert_success response
|
|
68
33
|
end
|
|
69
34
|
|
|
70
|
-
#
|
|
71
|
-
# # authorize and #capture haven't been tested because the author's
|
|
35
|
+
# #authorize and #capture haven't been tested because the author's
|
|
72
36
|
# account hasn't been setup to support these methods (see the
|
|
73
37
|
# documentation for the NetRegistry gateway class). There is no
|
|
74
38
|
# mention of a #void transaction in NetRegistry's documentation,
|
|
75
39
|
# either.
|
|
76
|
-
#
|
|
77
40
|
if ENV['TEST_AUTHORIZE_AND_CAPTURE']
|
|
78
41
|
def test_successful_authorization_and_capture
|
|
79
|
-
response = @gateway.authorize(
|
|
42
|
+
response = @gateway.authorize(@amount, @valid_creditcard)
|
|
80
43
|
assert_success response
|
|
81
44
|
assert_equal 'approved', response.params['status']
|
|
82
45
|
assert_match(/\A\d{6}\z/, response.authorization)
|
|
83
46
|
|
|
84
|
-
response = @gateway.capture(
|
|
47
|
+
response = @gateway.capture(@amount,
|
|
85
48
|
response.authorization,
|
|
86
49
|
:credit_card => @valid_creditcard)
|
|
87
50
|
assert_success response
|
|
@@ -90,30 +53,32 @@ class NetRegistryTest < Test::Unit::TestCase
|
|
|
90
53
|
end
|
|
91
54
|
|
|
92
55
|
def test_purchase_with_invalid_credit_card
|
|
93
|
-
response = @gateway.purchase(
|
|
56
|
+
response = @gateway.purchase(@amount, @invalid_creditcard)
|
|
94
57
|
assert_equal 'declined', response.params['status']
|
|
95
58
|
assert_equal 'INVALID CARD', response.message
|
|
96
59
|
assert_failure response
|
|
97
60
|
end
|
|
98
61
|
|
|
99
62
|
def test_purchase_with_expired_credit_card
|
|
100
|
-
response = @gateway.purchase(
|
|
63
|
+
response = @gateway.purchase(@amount, @expired_creditcard)
|
|
101
64
|
assert_equal 'failed', response.params['status']
|
|
102
65
|
assert_equal 'CARD EXPIRED', response.message
|
|
103
66
|
assert_failure response
|
|
104
67
|
end
|
|
105
68
|
|
|
106
69
|
def test_purchase_with_invalid_month
|
|
107
|
-
response = @gateway.purchase(
|
|
70
|
+
response = @gateway.purchase(@amount, @invalid_month_creditcard)
|
|
108
71
|
assert_equal 'failed', response.params['status']
|
|
109
72
|
assert_equal 'Invalid month', response.message
|
|
110
73
|
assert_failure response
|
|
111
74
|
end
|
|
112
75
|
|
|
113
76
|
def test_bad_login
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
77
|
+
gateway = NetRegistryGateway.new(
|
|
78
|
+
:login => 'bad-login',
|
|
79
|
+
:password => 'bad-login'
|
|
80
|
+
)
|
|
81
|
+
response = gateway.purchase(@amount, @valid_creditcard)
|
|
117
82
|
assert_equal 'failed', response.params['status']
|
|
118
83
|
assert_failure response
|
|
119
84
|
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteNetbillingTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@gateway = NetbillingGateway.new(fixtures(:netbilling))
|
|
7
|
+
|
|
8
|
+
@credit_card = credit_card('4444111111111119',
|
|
9
|
+
:month => '9',
|
|
10
|
+
:year => '2009',
|
|
11
|
+
:verification_value => nil
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
@address = { :address1 => '1600 Amphitheatre Parkway',
|
|
15
|
+
:city => 'Mountain View',
|
|
16
|
+
:state => 'CA',
|
|
17
|
+
:country => 'US',
|
|
18
|
+
:zip => '94043',
|
|
19
|
+
:phone => '650-253-0001'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@options = {
|
|
23
|
+
:billing_address => @address,
|
|
24
|
+
:description => 'Internet purchase'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@amount = 100
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_successful_purchase
|
|
31
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
32
|
+
assert_success response
|
|
33
|
+
assert_false response.authorization.blank?
|
|
34
|
+
assert_equal NetbillingGateway::SUCCESS_MESSAGE, response.message
|
|
35
|
+
assert response.test?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_unsuccessful_purchase
|
|
39
|
+
@credit_card.year = '2006'
|
|
40
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
41
|
+
assert_equal 'CARD EXPIRED', response.message
|
|
42
|
+
assert_failure response
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_authorize_and_capture
|
|
46
|
+
amount = @amount
|
|
47
|
+
assert auth = @gateway.authorize(amount, @credit_card, @options)
|
|
48
|
+
assert_success auth
|
|
49
|
+
assert_equal NetbillingGateway::SUCCESS_MESSAGE, auth.message
|
|
50
|
+
assert auth.authorization
|
|
51
|
+
assert capture = @gateway.capture(amount, auth.authorization)
|
|
52
|
+
assert_success capture
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_failed_capture
|
|
56
|
+
assert response = @gateway.capture(@amount, '1111')
|
|
57
|
+
assert_failure response
|
|
58
|
+
assert_equal NetbillingGateway::FAILURE_MESSAGE, response.message
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_invalid_login
|
|
62
|
+
gateway = NetbillingGateway.new(
|
|
63
|
+
:login => '',
|
|
64
|
+
:password => ''
|
|
65
|
+
)
|
|
66
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
|
67
|
+
assert_equal NetbillingGateway::FAILURE_MESSAGE, response.message
|
|
68
|
+
assert_failure response
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class PayJunctionTest < Test::Unit::TestCase
|
|
4
4
|
include ActiveMerchant::Billing
|
|
@@ -10,7 +10,7 @@ class PayJunctionTest < Test::Unit::TestCase
|
|
|
10
10
|
def setup
|
|
11
11
|
@gateway = PayJunctionGateway.new(fixtures(:pay_junction))
|
|
12
12
|
|
|
13
|
-
@
|
|
13
|
+
@credit_card = credit_card('4444333322221111', :verification_value => '123')
|
|
14
14
|
|
|
15
15
|
@valid_verification_value = '123'
|
|
16
16
|
@invalid_verification_value = '1234'
|
|
@@ -22,6 +22,7 @@ class PayJunctionTest < Test::Unit::TestCase
|
|
|
22
22
|
:state => 'CA',
|
|
23
23
|
:zip => '90001'
|
|
24
24
|
}
|
|
25
|
+
|
|
25
26
|
@invalid_address = {
|
|
26
27
|
:address1 => '187 Apple Tree Lane.',
|
|
27
28
|
:address2 => nil,
|
|
@@ -29,55 +30,45 @@ class PayJunctionTest < Test::Unit::TestCase
|
|
|
29
30
|
:state => 'CA',
|
|
30
31
|
:zip => '94062'
|
|
31
32
|
}
|
|
33
|
+
|
|
34
|
+
@options = { :billing_address => @valid_address, :order_id => generate_unique_id }
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
def test_successful_purchase
|
|
35
|
-
assert response = @gateway.purchase(AMOUNT,
|
|
36
|
-
|
|
37
|
-
:order_id => generate_order_id)
|
|
38
|
-
|
|
39
|
-
#p response
|
|
40
|
-
assert_equal Response, response.class
|
|
41
|
-
assert_match /APPROVAL/, response.message
|
|
38
|
+
assert response = @gateway.purchase(AMOUNT, @credit_card, @options)
|
|
39
|
+
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
|
|
42
40
|
assert_equal 'capture', response.params["posture"], 'Should be captured funds'
|
|
43
|
-
assert_equal 'charge', response.params["transaction_action"]
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
assert_equal 'charge', response.params["transaction_action"]
|
|
42
|
+
assert_success response
|
|
43
|
+
assert response.test?
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
def test_successful_purchase_with_cvv
|
|
49
|
-
@
|
|
50
|
-
assert response = @gateway.purchase(AMOUNT,
|
|
51
|
-
@creditcard,
|
|
52
|
-
:order_id => generate_order_id)
|
|
47
|
+
@credit_card.verification_value = @valid_verification_value
|
|
48
|
+
assert response = @gateway.purchase(AMOUNT, @credit_card, @options)
|
|
53
49
|
|
|
54
|
-
assert_equal
|
|
55
|
-
assert_match /APPROVAL/, response.message
|
|
50
|
+
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
|
|
56
51
|
assert_equal 'capture', response.params["posture"], 'Should be captured funds'
|
|
57
52
|
assert_equal 'charge', response.params["transaction_action"]
|
|
58
53
|
|
|
59
|
-
|
|
54
|
+
assert_success response
|
|
60
55
|
end
|
|
61
56
|
|
|
62
57
|
def test_successful_authorize
|
|
63
|
-
assert response = @gateway.authorize( AMOUNT,
|
|
64
|
-
@creditcard,
|
|
65
|
-
:order_id => generate_order_id)
|
|
58
|
+
assert response = @gateway.authorize( AMOUNT, @credit_card, @options)
|
|
66
59
|
|
|
67
|
-
assert_equal
|
|
68
|
-
assert_match /APPROVAL/, response.message
|
|
60
|
+
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
|
|
69
61
|
assert_equal 'hold', response.params["posture"], 'Should be a held charge'
|
|
70
62
|
assert_equal 'charge', response.params["transaction_action"]
|
|
71
63
|
|
|
72
|
-
|
|
64
|
+
assert_success response
|
|
73
65
|
end
|
|
74
66
|
|
|
75
67
|
def test_successful_capture
|
|
76
|
-
|
|
77
|
-
auth = @gateway.authorize(AMOUNT, @creditcard, :order_id => order_id)
|
|
68
|
+
auth = @gateway.authorize(AMOUNT, @credit_card, @options)
|
|
78
69
|
assert_success auth
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
|
|
71
|
+
response = @gateway.capture(AMOUNT, auth.authorization, @options)
|
|
81
72
|
assert_success response
|
|
82
73
|
assert_equal 'capture', response.params["posture"], 'Should be a capture'
|
|
83
74
|
assert_equal auth.authorization, response.authorization,
|
|
@@ -85,26 +76,22 @@ class PayJunctionTest < Test::Unit::TestCase
|
|
|
85
76
|
end
|
|
86
77
|
|
|
87
78
|
def test_successful_credit
|
|
88
|
-
purchase = @gateway.purchase(AMOUNT, @
|
|
79
|
+
purchase = @gateway.purchase(AMOUNT, @credit_card, @options)
|
|
89
80
|
assert_success purchase
|
|
90
81
|
|
|
91
82
|
assert response = @gateway.credit(success_price, purchase.authorization)
|
|
92
|
-
|
|
93
|
-
assert_equal Response, response.class
|
|
94
83
|
assert_equal 'refund', response.params["transaction_action"]
|
|
95
84
|
|
|
96
|
-
|
|
85
|
+
assert_success response
|
|
97
86
|
end
|
|
98
87
|
|
|
99
88
|
def test_successful_void
|
|
100
|
-
order_id =
|
|
101
|
-
purchase = @gateway.purchase(AMOUNT, @
|
|
89
|
+
order_id = generate_unique_id
|
|
90
|
+
purchase = @gateway.purchase(AMOUNT, @credit_card, @options)
|
|
102
91
|
assert_success purchase
|
|
103
92
|
|
|
104
|
-
assert response = @gateway.void(AMOUNT, purchase.authorization, :order_id => order_id)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
assert_equal true, response.success?
|
|
93
|
+
assert response = @gateway.void(AMOUNT, purchase.authorization, :order_id => order_id)
|
|
94
|
+
assert_success response
|
|
108
95
|
assert_equal 'void', response.params["posture"], 'Should be a capture'
|
|
109
96
|
assert_equal purchase.authorization, response.authorization,
|
|
110
97
|
"Should maintain transaction ID across request"
|
|
@@ -115,44 +102,38 @@ class PayJunctionTest < Test::Unit::TestCase
|
|
|
115
102
|
# transaction can be executed if you have the transaction ID of a
|
|
116
103
|
# previous successful transaction.
|
|
117
104
|
|
|
118
|
-
purchase = @gateway.purchase( AMOUNT,
|
|
119
|
-
@creditcard,
|
|
120
|
-
:order_id => generate_order_id)
|
|
105
|
+
purchase = @gateway.purchase( AMOUNT, @credit_card, @options)
|
|
121
106
|
assert_success purchase
|
|
122
107
|
|
|
123
|
-
assert response = @gateway.purchase(AMOUNT,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
assert_equal Response, response.class
|
|
128
|
-
assert_match /APPROVAL/, response.message
|
|
108
|
+
assert response = @gateway.purchase(AMOUNT, purchase.authorization, :order_id => generate_unique_id)
|
|
109
|
+
|
|
110
|
+
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
|
|
129
111
|
assert_equal 'capture', response.params["posture"], 'Should be captured funds'
|
|
130
112
|
assert_equal 'charge', response.params["transaction_action"]
|
|
131
113
|
assert_not_equal purchase.authorization, response.authorization,
|
|
132
114
|
'Should have recieved new transaction ID'
|
|
133
115
|
|
|
134
|
-
|
|
116
|
+
assert_success response
|
|
135
117
|
end
|
|
136
118
|
|
|
137
119
|
def test_successful_recurring
|
|
138
|
-
assert response = @gateway.recurring(AMOUNT, @
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
120
|
+
assert response = @gateway.recurring(AMOUNT, @credit_card,
|
|
121
|
+
:periodicity => :monthly,
|
|
122
|
+
:payments => 12,
|
|
123
|
+
:order_id => generate_unique_id
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
assert_equal PayJunctionGateway::SUCCESS_MESSAGE, response.message
|
|
144
127
|
assert_equal 'charge', response.params["transaction_action"]
|
|
145
128
|
|
|
146
|
-
|
|
129
|
+
assert_success response
|
|
147
130
|
end
|
|
148
131
|
|
|
149
132
|
def test_should_send_invoice
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
response = @gateway.purchase(AMOUNT, @creditcard, :order_id => order_id)
|
|
133
|
+
response = @gateway.purchase(AMOUNT, @credit_card, @options)
|
|
153
134
|
assert_success response
|
|
154
135
|
|
|
155
|
-
assert_equal order_id, response.params["invoice_number"], 'Should have set invoice'
|
|
136
|
+
assert_equal @options[:order_id], response.params["invoice_number"], 'Should have set invoice'
|
|
156
137
|
end
|
|
157
138
|
|
|
158
139
|
private
|