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
|
@@ -3,51 +3,38 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
|
3
3
|
class VerifiTest < Test::Unit::TestCase
|
|
4
4
|
include ActiveMerchant::Billing
|
|
5
5
|
|
|
6
|
-
LOGIN = 'demo'
|
|
7
|
-
PASSWORD = 'password'
|
|
8
|
-
|
|
9
6
|
def setup
|
|
10
7
|
@gateway = VerifiGateway.new(
|
|
11
|
-
:login =>
|
|
12
|
-
:password =>
|
|
8
|
+
:login => 'l',
|
|
9
|
+
:password => 'p'
|
|
13
10
|
)
|
|
14
11
|
|
|
15
|
-
@
|
|
12
|
+
@credit_card = credit_card('4111111111111111')
|
|
16
13
|
|
|
17
14
|
@options = {
|
|
18
|
-
:order_id => 37,
|
|
19
|
-
:email => "paul@
|
|
20
|
-
:
|
|
21
|
-
:address1 => '164 Waverley Street',
|
|
22
|
-
:address2 => 'APT #7',
|
|
23
|
-
:country => 'US',
|
|
24
|
-
:city => 'Boulder',
|
|
25
|
-
:state => 'CO',
|
|
26
|
-
:zip => 12345
|
|
27
|
-
}
|
|
15
|
+
:order_id => '37',
|
|
16
|
+
:email => "paul@example.com",
|
|
17
|
+
:billing_address => address
|
|
28
18
|
}
|
|
19
|
+
|
|
20
|
+
@amount = 100
|
|
29
21
|
end
|
|
30
22
|
|
|
31
|
-
def
|
|
32
|
-
@
|
|
33
|
-
|
|
34
|
-
assert response = @gateway.purchase(
|
|
35
|
-
assert_success response
|
|
23
|
+
def test_successful_request
|
|
24
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
25
|
+
|
|
26
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
27
|
+
assert_success response
|
|
28
|
+
assert_equal '546061538', response.authorization
|
|
29
|
+
assert response.test?
|
|
36
30
|
end
|
|
37
31
|
|
|
38
|
-
def
|
|
39
|
-
@
|
|
40
|
-
|
|
41
|
-
assert response = @gateway.purchase(
|
|
32
|
+
def test_unsuccessful_request
|
|
33
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
34
|
+
|
|
35
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
42
36
|
assert_failure response
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def test_purchase_exceptions
|
|
46
|
-
@creditcard.number = 3
|
|
47
|
-
|
|
48
|
-
assert_raise(Error) do
|
|
49
|
-
assert response = @gateway.purchase(Money.new(100), @creditcard, { :order_id => 1 } )
|
|
50
|
-
end
|
|
37
|
+
assert response.test?
|
|
51
38
|
end
|
|
52
39
|
|
|
53
40
|
def test_amount_style
|
|
@@ -70,7 +57,7 @@ class VerifiTest < Test::Unit::TestCase
|
|
|
70
57
|
post = VerifiGateway::VerifiPostData.new
|
|
71
58
|
post[:amount] = "1.01"
|
|
72
59
|
|
|
73
|
-
@gateway.send(:
|
|
60
|
+
@gateway.send(:add_credit_card, post, @credit_card)
|
|
74
61
|
|
|
75
62
|
assert data = @gateway.send(:post_data, :authorization, post)
|
|
76
63
|
|
|
@@ -79,6 +66,20 @@ class VerifiTest < Test::Unit::TestCase
|
|
|
79
66
|
end
|
|
80
67
|
|
|
81
68
|
end
|
|
69
|
+
|
|
70
|
+
def test_avs_result
|
|
71
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
72
|
+
|
|
73
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
74
|
+
assert_equal 'N', response.avs_result['code']
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_cvv_result
|
|
78
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
79
|
+
|
|
80
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
81
|
+
assert_equal 'N', response.cvv_result['code']
|
|
82
|
+
end
|
|
82
83
|
|
|
83
84
|
private
|
|
84
85
|
|
|
@@ -86,6 +87,11 @@ class VerifiTest < Test::Unit::TestCase
|
|
|
86
87
|
%w(type username password ccnumber ccexp amount)
|
|
87
88
|
end
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
def successful_purchase_response
|
|
91
|
+
"response=1&responsetext=SUCCESS&authcode=123456&transactionid=546061538&avsresponse=N&cvvresponse=N&orderid=37&type=sale&response_code=100"
|
|
92
|
+
end
|
|
90
93
|
|
|
94
|
+
def unsuccessful_purchase_response
|
|
95
|
+
"response=3&responsetext=Field required: ccnumber REFID:12109909&authcode=&transactionid=0&avsresponse=&cvvresponse=&orderid=37&type=sale&response_code=300"
|
|
96
|
+
end
|
|
91
97
|
end
|
|
@@ -1,68 +1,74 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
2
3
|
class ViaklixTest < Test::Unit::TestCase
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
def setup
|
|
5
6
|
@gateway = ViaklixGateway.new(
|
|
6
7
|
:login => 'LOGIN',
|
|
7
8
|
:password => 'PIN'
|
|
8
9
|
)
|
|
9
10
|
|
|
10
|
-
@
|
|
11
|
-
|
|
11
|
+
@credit_card = credit_card
|
|
12
12
|
@options = {
|
|
13
13
|
:order_id => '37',
|
|
14
14
|
:email => "paul@domain.com",
|
|
15
15
|
:description => 'Test Transaction',
|
|
16
|
-
:
|
|
17
|
-
:address1 => '164 Waverley Street',
|
|
18
|
-
:address2 => 'APT #7',
|
|
19
|
-
:country => 'US',
|
|
20
|
-
:city => 'Boulder',
|
|
21
|
-
:state => 'CO',
|
|
22
|
-
:zip => '12345'
|
|
23
|
-
}
|
|
16
|
+
:billing_address => address
|
|
24
17
|
}
|
|
18
|
+
@amount = 100
|
|
25
19
|
end
|
|
26
20
|
|
|
27
21
|
def test_purchase_success
|
|
28
|
-
@
|
|
29
|
-
|
|
30
|
-
assert response = @gateway.purchase(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
assert_equal
|
|
22
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
23
|
+
|
|
24
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
25
|
+
assert_instance_of Response, response
|
|
26
|
+
assert_success response
|
|
27
|
+
assert_equal '7E2419F7-2354-4766-BF5C-19C75A1F379A', response.authorization
|
|
34
28
|
end
|
|
35
29
|
|
|
36
30
|
def test_purchase_error
|
|
37
|
-
@
|
|
38
|
-
|
|
39
|
-
assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
|
|
40
|
-
assert_equal Response, response.class
|
|
41
|
-
assert_equal '#0001', response.params['receiptid']
|
|
42
|
-
assert_equal false, response.success?
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_purchase_exceptions
|
|
47
|
-
@creditcard.number = 3
|
|
31
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
48
32
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
34
|
+
assert_instance_of Response, response
|
|
35
|
+
assert_failure response
|
|
52
36
|
end
|
|
53
37
|
|
|
54
38
|
def test_invalid_login
|
|
55
39
|
@gateway.expects(:ssl_post).returns(invalid_login_response)
|
|
56
40
|
|
|
57
|
-
assert response = @gateway.purchase(
|
|
41
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
58
42
|
|
|
59
43
|
assert_equal '7000', response.params['result']
|
|
60
44
|
assert_equal 'The viaKLIX ID and/or User ID supplied in the authorization request is invalid.', response.params['result_message']
|
|
61
45
|
assert_failure response
|
|
62
46
|
end
|
|
63
47
|
|
|
48
|
+
def test_avs_result
|
|
49
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
50
|
+
|
|
51
|
+
response = @gateway.purchase(@amount, @credit_card)
|
|
52
|
+
assert_equal 'Y', response.avs_result['code']
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_cvv_result
|
|
56
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
57
|
+
|
|
58
|
+
response = @gateway.purchase(@amount, @credit_card)
|
|
59
|
+
assert_equal 'M', response.cvv_result['code']
|
|
60
|
+
end
|
|
61
|
+
|
|
64
62
|
private
|
|
65
63
|
|
|
64
|
+
def successful_purchase_response
|
|
65
|
+
"ssl_result=0\r\nssl_company=;\r\nssl_city=Herndon\r\nssl_avs_zip=90201\r\nssl_address2=\r\nssl_ship_to_last_name=Jacobs\r\nssl_ship_to_city=Herndon\r\nssl_approval_code=05737D\r\nssl_avs_response=Y\r\nssl_salestax=\r\nssl_ship_to_phone=\r\ncustomer_code=jacobsr1@cox.net\r\nship_to_country=US\r\ncountry=US\r\nssl_txn_id=7E2419F7-2354-4766-BF5C-19C75A1F379A\r\nssl_transaction_type=SALE\r\nssl_invoice_number=#1158.1\r\nssl_amount=243.95\r\nssl_card_number=43*******6820\r\nssl_description=\r\nssl_phone=703-404-9270\r\nssl_ship_to_avs_address=\r\nssl_first_name=Cody\r\nssl_avs_address=12213 Jonathons Glen Way\r\nssl_result_message=APPROVED\r\nssl_exp_date=1109\r\nssl_last_name=Fauser\r\nssl_ship_to_first_name=Robert\r\nssl_ship_to_address2=\r\nssl_ship_to_state=VA\r\nssl_ship_to_avs_zip=\r\nssl_cvv2_response=M\r\nssl_state=VA\r\nssl_email=cody@example.com\r\nssl_ship_to_company=\r\n"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def unsuccessful_purchase_response
|
|
69
|
+
"ssl_result=1\r\nssl_result_message=This transaction request has not been approved. You may elect to use another form of payment to complete this transaction or contact customer service for additional options."
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
def invalid_login_response
|
|
67
73
|
<<-RESPONSE
|
|
68
74
|
ssl_result=7000\r
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
|
2
|
+
|
|
3
|
+
class TestGatewayGenerator < Test::Unit::TestCase
|
|
4
|
+
include RubiGen::GeneratorTestHelper
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
bare_setup
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def teardown
|
|
11
|
+
bare_teardown
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Some generator-related assertions:
|
|
15
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
|
16
|
+
# assert_directory_exists(name)
|
|
17
|
+
# assert_generated_class(name, &block)
|
|
18
|
+
# assert_generated_module(name, &block)
|
|
19
|
+
# assert_generated_test_for(name, &block)
|
|
20
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
|
21
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
|
22
|
+
#
|
|
23
|
+
# Other helper methods are:
|
|
24
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
|
25
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
|
26
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
|
27
|
+
|
|
28
|
+
def test_generator_without_options
|
|
29
|
+
name = 'miracle'
|
|
30
|
+
|
|
31
|
+
run_generator('gateway', [ name ], sources)
|
|
32
|
+
assert_generated_file(GatewayGenerator::LIB_DIR + "#{name}.rb")
|
|
33
|
+
assert_generated_file(GatewayGenerator::UNIT_TEST_DIR + "#{name}_test.rb")
|
|
34
|
+
assert_generated_file(GatewayGenerator::REMOTE_TEST_DIR + "remote_#{name}_test.rb")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
def sources
|
|
39
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
|
40
|
+
]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def generator_path
|
|
44
|
+
"generators"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
# Must set before requiring generator libs.
|
|
5
|
+
TMP_ROOT = File.dirname(__FILE__) + "/tmp" unless defined?(TMP_ROOT)
|
|
6
|
+
PROJECT_NAME = "myproject" unless defined?(PROJECT_NAME)
|
|
7
|
+
app_root = File.join(TMP_ROOT, PROJECT_NAME)
|
|
8
|
+
if defined?(APP_ROOT)
|
|
9
|
+
APP_ROOT.replace(app_root)
|
|
10
|
+
else
|
|
11
|
+
APP_ROOT = app_root
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
begin
|
|
15
|
+
require 'rubigen'
|
|
16
|
+
rescue LoadError
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'rubigen'
|
|
19
|
+
end
|
|
20
|
+
require 'rubigen/helpers/generator_test_helper'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_generator_helper.rb")
|
|
2
|
+
|
|
3
|
+
class TestIntegrationGenerator < Test::Unit::TestCase
|
|
4
|
+
include RubiGen::GeneratorTestHelper
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
bare_setup
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def teardown
|
|
11
|
+
bare_teardown
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Some generator-related assertions:
|
|
15
|
+
# assert_generated_file(name, &block) # block passed the file contents
|
|
16
|
+
# assert_directory_exists(name)
|
|
17
|
+
# assert_generated_class(name, &block)
|
|
18
|
+
# assert_generated_module(name, &block)
|
|
19
|
+
# assert_generated_test_for(name, &block)
|
|
20
|
+
# The assert_generated_(class|module|test_for) &block is passed the body of the class/module within the file
|
|
21
|
+
# assert_has_method(body, *methods) # check that the body has a list of methods (methods with parentheses not supported yet)
|
|
22
|
+
#
|
|
23
|
+
# Other helper methods are:
|
|
24
|
+
# app_root_files - put this in teardown to show files generated by the test method (e.g. p app_root_files)
|
|
25
|
+
# bare_setup - place this in setup method to create the APP_ROOT folder for each test
|
|
26
|
+
# bare_teardown - place this in teardown method to destroy the TMP_ROOT or APP_ROOT folder after each test
|
|
27
|
+
|
|
28
|
+
def test_generator_without_options
|
|
29
|
+
name = 'miracle'
|
|
30
|
+
|
|
31
|
+
run_generator('integration', [ name ], sources)
|
|
32
|
+
|
|
33
|
+
lib_dir = IntegrationGenerator::BASE_DIR + name
|
|
34
|
+
test_dir = IntegrationGenerator::TEST_DIR
|
|
35
|
+
assert_generated_file("#{lib_dir}.rb")
|
|
36
|
+
assert_generated_file(lib_dir + "/helper.rb")
|
|
37
|
+
assert_generated_file(lib_dir + "/notification.rb")
|
|
38
|
+
|
|
39
|
+
assert_generated_file(test_dir + "#{name}_module_test.rb")
|
|
40
|
+
assert_generated_file(test_dir + "helpers/#{name}_helper_test.rb")
|
|
41
|
+
assert_generated_file(test_dir + "notifications/#{name}_notification_test.rb")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
def sources
|
|
46
|
+
[RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))
|
|
47
|
+
]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def generator_path
|
|
51
|
+
"generators"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
-
begin
|
|
3
|
-
if respond_to? :gem
|
|
4
|
-
gem 'actionpack'
|
|
5
|
-
else
|
|
6
|
-
require_gem 'actionpack'
|
|
7
|
-
end
|
|
8
|
-
rescue LoadError
|
|
9
|
-
raise StandardError, "This test needs ActionPack installed as gem to run"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
require 'action_controller'
|
|
13
|
-
require 'action_controller/test_process'
|
|
14
|
-
require 'active_merchant/billing/integrations/action_view_helper'
|
|
15
2
|
|
|
16
3
|
class ActionViewHelperTest < Test::Unit::TestCase
|
|
17
4
|
include ActiveMerchant::Billing::Integrations::ActionViewHelper
|
|
@@ -26,10 +13,11 @@ class ActionViewHelperTest < Test::Unit::TestCase
|
|
|
26
13
|
attr_reader :url_for_options
|
|
27
14
|
def url_for(options, *parameters_for_method_reference)
|
|
28
15
|
@url_for_options = options
|
|
29
|
-
end
|
|
16
|
+
end
|
|
30
17
|
end
|
|
31
18
|
@controller = @controller.new
|
|
32
19
|
end
|
|
20
|
+
|
|
33
21
|
|
|
34
22
|
def test_basic_payment_service
|
|
35
23
|
_erbout = ''
|
|
@@ -51,4 +39,9 @@ class ActionViewHelperTest < Test::Unit::TestCase
|
|
|
51
39
|
def test_payment_service_no_block_given
|
|
52
40
|
assert_raise(ArgumentError){ payment_service_for }
|
|
53
41
|
end
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
def protect_against_forgery?
|
|
45
|
+
false
|
|
46
|
+
end
|
|
54
47
|
end
|
|
@@ -6,4 +6,8 @@ class ChronopayModuleTest < Test::Unit::TestCase
|
|
|
6
6
|
def test_notification_method
|
|
7
7
|
assert_instance_of Chronopay::Notification, Chronopay.notification('name=cody')
|
|
8
8
|
end
|
|
9
|
+
|
|
10
|
+
def test_return_method
|
|
11
|
+
assert_instance_of Chronopay::Return, Chronopay.return('name=cody')
|
|
12
|
+
end
|
|
9
13
|
end
|
|
@@ -7,4 +7,8 @@ class GestpayModuleTest < Test::Unit::TestCase
|
|
|
7
7
|
Gestpay::Notification.any_instance.expects(:ssl_get).returns('#decryptstring#a=9000000&b=PAY1_UICCODE=242*P1*PAY1_AMOUNT=1234.56*P1*PAY1_TRANSACTIONRESULT=OK*P1*PAY1_BANKTRANSACTIONID=ABCD1234*P1*PAY1_SHOPTRANSACTIONID=1000#/decryptstring#')
|
|
8
8
|
assert_instance_of Gestpay::Notification, Gestpay.notification('a=900000&b=F7DEB36478FD84760F9134F23C922697272D57DE6D4518EB9B4D468B769D9A3A8071B6EB160B35CB412FC1820C7CC12D17B3141855B1ED55468613702A2E213DDE9DE5B0209E13C416448AE833525959F05693172D7F0656')
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
def test_return_method
|
|
12
|
+
assert_instance_of Gestpay::Return, Gestpay.return('name=cody')
|
|
13
|
+
end
|
|
10
14
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
|
2
|
+
|
|
3
|
+
class HiTrustHelperTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@helper = HiTrust::Helper.new('order-500','cody@example.com', :amount => 500, :currency => 'USD')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_basic_helper_fields
|
|
11
|
+
assert_field 'storeid', 'cody@example.com'
|
|
12
|
+
assert_field 'amount', '500'
|
|
13
|
+
assert_field 'ordernumber', 'order-500'
|
|
14
|
+
assert_field 'currency', 'USD'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class HiTrustModuleTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def test_notification_method
|
|
7
|
+
assert_instance_of HiTrust::Notification, HiTrust.notification('name=cody')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_return_method
|
|
11
|
+
assert_instance_of HiTrust::Return, HiTrust.return('name=cody')
|
|
12
|
+
end
|
|
13
|
+
end
|