activemerchant 1.1.0 → 1.2.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 +226 -0
- data/CONTRIBUTERS +52 -0
- data/README +34 -24
- data/Rakefile +152 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +3 -1
- data/lib/active_merchant/billing/credit_card.rb +21 -17
- data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
- data/lib/active_merchant/billing/gateway.rb +160 -44
- data/lib/active_merchant/billing/gateways.rb +2 -15
- data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
- data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
- data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
- data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
- data/lib/active_merchant/billing/gateways/eway.rb +77 -29
- data/lib/active_merchant/billing/gateways/exact.rb +230 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
- data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
- data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
- data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
- data/lib/active_merchant/billing/gateways/protx.rb +285 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
- data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
- data/lib/active_merchant/billing/gateways/realex.rb +212 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
- data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
- data/lib/active_merchant/billing/integrations/helper.rb +8 -1
- data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
- data/lib/active_merchant/billing/integrations/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
- 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 +23 -5
- data/lib/active_merchant/lib/requires_parameters.rb +2 -2
- data/lib/active_merchant/lib/validateable.rb +1 -1
- data/lib/support/gateway_support.rb +45 -0
- data/lib/tasks/cia.rb +1 -1
- data/script/generate +14 -0
- data/script/generator/base.rb +45 -0
- data/script/generator/generator.rb +24 -0
- data/script/generator/generators/gateway/gateway_generator.rb +14 -0
- data/script/generator/generators/gateway/templates/gateway.rb +73 -0
- data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
- data/script/generator/generators/integration/integration_generator.rb +25 -0
- data/script/generator/generators/integration/templates/helper.rb +34 -0
- data/script/generator/generators/integration/templates/helper_test.rb +54 -0
- data/script/generator/generators/integration/templates/integration.rb +18 -0
- data/script/generator/generators/integration/templates/module_test.rb +9 -0
- data/script/generator/generators/integration/templates/notification.rb +100 -0
- data/script/generator/generators/integration/templates/notification_test.rb +41 -0
- data/script/generator/manifest.rb +20 -0
- data/test/extra/binding_of_caller.rb +80 -0
- data/test/extra/breakpoint.rb +547 -0
- data/test/fixtures.yml +251 -0
- data/test/remote_tests/remote_authorize_net_test.rb +113 -0
- data/test/remote_tests/remote_brain_tree_test.rb +78 -0
- data/test/remote_tests/remote_card_stream_test.rb +160 -0
- data/test/remote_tests/remote_cyber_source_test.rb +130 -0
- data/test/remote_tests/remote_data_cash_test.rb +155 -0
- data/test/remote_tests/remote_efsnet_test.rb +93 -0
- data/test/remote_tests/remote_eway_test.rb +71 -0
- data/test/remote_tests/remote_exact_test.rb +59 -0
- data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
- data/test/remote_tests/remote_linkpoint_test.rb +144 -0
- data/test/remote_tests/remote_moneris_test.rb +110 -0
- data/test/remote_tests/remote_net_registry_test.rb +120 -0
- data/test/remote_tests/remote_pay_junction_test.rb +162 -0
- data/test/remote_tests/remote_payflow_express_test.rb +50 -0
- data/test/remote_tests/remote_payflow_test.rb +241 -0
- data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
- data/test/remote_tests/remote_payment_express_test.rb +136 -0
- data/test/remote_tests/remote_paypal_express_test.rb +49 -0
- data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
- data/test/remote_tests/remote_paypal_test.rb +163 -0
- data/test/remote_tests/remote_plugnpay_test.rb +70 -0
- data/test/remote_tests/remote_protx_test.rb +184 -0
- data/test/remote_tests/remote_psigate_test.rb +87 -0
- data/test/remote_tests/remote_psl_card_test.rb +105 -0
- data/test/remote_tests/remote_quickpay_test.rb +182 -0
- data/test/remote_tests/remote_realex_test.rb +227 -0
- data/test/remote_tests/remote_secure_pay_test.rb +36 -0
- data/test/remote_tests/remote_trans_first_test.rb +37 -0
- data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
- data/test/remote_tests/remote_usa_epay_test.rb +57 -0
- data/test/remote_tests/remote_verifi_test.rb +107 -0
- data/test/remote_tests/remote_viaklix_test.rb +53 -0
- data/test/test_helper.rb +132 -0
- data/test/unit/base_test.rb +61 -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 +24 -0
- data/test/unit/credit_card_methods_test.rb +37 -0
- data/test/unit/credit_card_test.rb +365 -0
- data/test/unit/gateways/authorize_net_test.rb +140 -0
- data/test/unit/gateways/bogus_test.rb +43 -0
- data/test/unit/gateways/brain_tree_test.rb +77 -0
- data/test/unit/gateways/card_stream_test.rb +37 -0
- data/test/unit/gateways/cyber_source_test.rb +151 -0
- data/test/unit/gateways/data_cash_test.rb +23 -0
- data/test/unit/gateways/efsnet_test.rb +70 -0
- data/test/unit/gateways/eway_test.rb +105 -0
- data/test/unit/gateways/exact_test.rb +118 -0
- data/test/unit/gateways/gateway_test.rb +24 -0
- data/test/unit/gateways/linkpoint_test.rb +165 -0
- data/test/unit/gateways/moneris_test.rb +167 -0
- data/test/unit/gateways/net_registry_test.rb +478 -0
- data/test/unit/gateways/pay_junction_test.rb +61 -0
- data/test/unit/gateways/payflow_express_test.rb +165 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
- data/test/unit/gateways/payflow_test.rb +230 -0
- data/test/unit/gateways/payflow_uk_test.rb +68 -0
- data/test/unit/gateways/payment_express_test.rb +215 -0
- data/test/unit/gateways/paypal_express_test.rb +222 -0
- data/test/unit/gateways/paypal_test.rb +241 -0
- data/test/unit/gateways/plugnpay_test.rb +79 -0
- data/test/unit/gateways/protx_test.rb +110 -0
- data/test/unit/gateways/psigate_test.rb +110 -0
- data/test/unit/gateways/psl_card_test.rb +51 -0
- data/test/unit/gateways/quickpay_test.rb +125 -0
- data/test/unit/gateways/realex_test.rb +150 -0
- data/test/unit/gateways/secure_pay_test.rb +78 -0
- data/test/unit/gateways/trans_first_test.rb +125 -0
- data/test/unit/gateways/trust_commerce_test.rb +57 -0
- data/test/unit/gateways/usa_epay_test.rb +117 -0
- data/test/unit/gateways/verifi_test.rb +91 -0
- data/test/unit/gateways/viaklix_test.rb +72 -0
- data/test/unit/integrations/action_view_helper_test.rb +54 -0
- data/test/unit/integrations/bogus_module_test.rb +16 -0
- data/test/unit/integrations/chronopay_module_test.rb +9 -0
- data/test/unit/integrations/gestpay_module_test.rb +10 -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/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/nochex_module_test.rb +9 -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/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +41 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +9 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/response_test.rb +14 -0
- data/test/unit/validateable_test.rb +56 -0
- metadata +160 -7
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class TrustCommerceTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
#TCLink rescue NameError assert false, 'Trust Commerce test cases require "tclink" library from http://www.trustcommerce.com/tclink.html'
|
|
6
|
+
|
|
7
|
+
@gateway = TrustCommerceGateway.new(
|
|
8
|
+
:login => 'TestMerchant',
|
|
9
|
+
:password => 'password'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@creditcard = credit_card('4111111111111111')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_purchase_success
|
|
16
|
+
@creditcard.number = '1'
|
|
17
|
+
|
|
18
|
+
assert response = @gateway.purchase(100, @creditcard, :demo => 'y')
|
|
19
|
+
assert_equal Response, response.class
|
|
20
|
+
assert_equal '#0001', response.params['receiptid']
|
|
21
|
+
assert_equal true, response.success?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_purchase_error
|
|
25
|
+
@creditcard.number = '2'
|
|
26
|
+
|
|
27
|
+
assert response = @gateway.purchase(100, @creditcard, :demo => 'y')
|
|
28
|
+
assert_equal Response, response.class
|
|
29
|
+
assert_equal '#0001', response.params['receiptid']
|
|
30
|
+
assert_equal false, response.success?
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_purchase_exceptions
|
|
35
|
+
@creditcard.number = '3'
|
|
36
|
+
|
|
37
|
+
assert_raise(Error) do
|
|
38
|
+
assert response = @gateway.purchase(100, @creditcard, :demo => 'y')
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_amount_style
|
|
43
|
+
assert_equal '1034', @gateway.send(:amount, 1034)
|
|
44
|
+
|
|
45
|
+
assert_raise(ArgumentError) do
|
|
46
|
+
@gateway.send(:amount, '10.34')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_supported_countries
|
|
51
|
+
assert_equal ['US'], TrustCommerceGateway.supported_countries
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_supported_card_types
|
|
55
|
+
assert_equal [:visa, :master, :discover, :american_express, :diners_club, :jcb], TrustCommerceGateway.supported_cardtypes
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class UsaEpayTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = UsaEpayGateway.new(
|
|
6
|
+
:login => 'LOGIN'
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
@creditcard = credit_card('4242424242424242')
|
|
10
|
+
|
|
11
|
+
@address = { :address1 => '1234 My Street',
|
|
12
|
+
:address2 => 'Apt 1',
|
|
13
|
+
:company => 'Widgets Inc',
|
|
14
|
+
:city => 'Ottawa',
|
|
15
|
+
:state => 'ON',
|
|
16
|
+
:zip => 'K1C2N6',
|
|
17
|
+
:country => 'Canada',
|
|
18
|
+
:phone => '(555)555-5555'
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_successful_request
|
|
23
|
+
@creditcard.number = 1
|
|
24
|
+
assert response = @gateway.purchase(100, @creditcard, {})
|
|
25
|
+
assert_success response
|
|
26
|
+
assert_equal '5555', response.authorization
|
|
27
|
+
assert response.test?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_unsuccessful_request
|
|
31
|
+
@creditcard.number = 2
|
|
32
|
+
assert response = @gateway.purchase(100, @creditcard, {})
|
|
33
|
+
assert_failure response
|
|
34
|
+
assert response.test?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_request_error
|
|
38
|
+
@creditcard.number = 3
|
|
39
|
+
assert_raise(Error){ @gateway.purchase(100, @creditcard, {}) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_address_key_prefix
|
|
43
|
+
assert_equal 'bill', @gateway.send(:address_key_prefix, :billing)
|
|
44
|
+
assert_equal 'ship', @gateway.send(:address_key_prefix, :shipping)
|
|
45
|
+
assert_nil @gateway.send(:address_key_prefix, :vacation)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_address_key
|
|
49
|
+
assert_equal :shipfname, @gateway.send(:address_key, 'ship', 'fname')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_add_address
|
|
53
|
+
post = {}
|
|
54
|
+
options = { :address => @address }
|
|
55
|
+
@gateway.send(:add_address, post, @creditcard, options)
|
|
56
|
+
assert_address(:shipping, post)
|
|
57
|
+
assert_equal 20, post.keys.size
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_add_billing_address
|
|
61
|
+
post = {}
|
|
62
|
+
options = { :billing_address => @address }
|
|
63
|
+
@gateway.send(:add_address, post, @creditcard, options)
|
|
64
|
+
assert_address(:billing, post)
|
|
65
|
+
assert_equal 20, post.keys.size
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_add_billing_and_shipping_addresses
|
|
69
|
+
post = {}
|
|
70
|
+
options = { :address => @address,
|
|
71
|
+
:billing_address => @address
|
|
72
|
+
}
|
|
73
|
+
@gateway.send(:add_address, post, @creditcard, options)
|
|
74
|
+
assert_address(:shipping, post)
|
|
75
|
+
assert_address(:billing, post)
|
|
76
|
+
assert_equal 20, post.keys.size
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_amount_style
|
|
80
|
+
assert_equal '10.34', @gateway.send(:amount, 1034)
|
|
81
|
+
|
|
82
|
+
assert_raise(ArgumentError) do
|
|
83
|
+
@gateway.send(:amount, '10.34')
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_supported_countries
|
|
88
|
+
assert_equal ['US'], UsaEpayGateway.supported_countries
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_supported_card_types
|
|
92
|
+
assert_equal [:visa, :master, :american_express], UsaEpayGateway.supported_cardtypes
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
def assert_address(type, post)
|
|
97
|
+
prefix = key_prefix(type)
|
|
98
|
+
assert_equal @creditcard.first_name, post[key(prefix, 'fname')]
|
|
99
|
+
assert_equal @creditcard.last_name, post[key(prefix, 'lname')]
|
|
100
|
+
assert_equal @address[:company], post[key(prefix, 'company')]
|
|
101
|
+
assert_equal @address[:address1], post[key(prefix, 'street')]
|
|
102
|
+
assert_equal @address[:address2], post[key(prefix, 'street2')]
|
|
103
|
+
assert_equal @address[:city], post[key(prefix, 'city')]
|
|
104
|
+
assert_equal @address[:state], post[key(prefix, 'state')]
|
|
105
|
+
assert_equal @address[:zip], post[key(prefix, 'zip')]
|
|
106
|
+
assert_equal @address[:country], post[key(prefix, 'country')]
|
|
107
|
+
assert_equal @address[:phone], post[key(prefix, 'phone')]
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def key_prefix(type)
|
|
111
|
+
@gateway.send(:address_key_prefix, type)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def key(prefix, key)
|
|
115
|
+
@gateway.send(:address_key, prefix, key)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class VerifiTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing
|
|
5
|
+
|
|
6
|
+
LOGIN = 'demo'
|
|
7
|
+
PASSWORD = 'password'
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
@gateway = VerifiGateway.new(
|
|
11
|
+
:login => LOGIN,
|
|
12
|
+
:password => PASSWORD
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
@creditcard = credit_card('4111111111111111')
|
|
16
|
+
|
|
17
|
+
@options = {
|
|
18
|
+
:order_id => 37,
|
|
19
|
+
:email => "paul@domain.com",
|
|
20
|
+
:address => {
|
|
21
|
+
:address1 => '164 Waverley Street',
|
|
22
|
+
:address2 => 'APT #7',
|
|
23
|
+
:country => 'US',
|
|
24
|
+
:city => 'Boulder',
|
|
25
|
+
:state => 'CO',
|
|
26
|
+
:zip => 12345
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_purchase_success
|
|
32
|
+
@creditcard.number = 1
|
|
33
|
+
|
|
34
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
35
|
+
assert_success response
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_purchase_error
|
|
39
|
+
@creditcard.number = 2
|
|
40
|
+
|
|
41
|
+
assert response = @gateway.purchase(10, @creditcard, @options)
|
|
42
|
+
assert_failure response
|
|
43
|
+
end
|
|
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
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_amount_style
|
|
54
|
+
assert_equal '10.34', @gateway.send(:amount, Money.new(1034))
|
|
55
|
+
assert_equal '10.34', @gateway.send(:amount, 1034)
|
|
56
|
+
|
|
57
|
+
assert_raise(ArgumentError) do
|
|
58
|
+
@gateway.send(:amount, '10.34')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_add_description
|
|
63
|
+
result = {}
|
|
64
|
+
@gateway.send(:add_invoice_data, result, :description => 'My Purchase is great')
|
|
65
|
+
assert_equal 'My Purchase is great', result[:orderdescription]
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_purchase_meets_minimum_requirements
|
|
70
|
+
post = VerifiGateway::VerifiPostData.new
|
|
71
|
+
post[:amount] = "1.01"
|
|
72
|
+
|
|
73
|
+
@gateway.send(:add_creditcard, post, @creditcard)
|
|
74
|
+
|
|
75
|
+
assert data = @gateway.send(:post_data, :authorization, post)
|
|
76
|
+
|
|
77
|
+
minimum_requirements.each do |key|
|
|
78
|
+
assert_not_nil(data =~ /#{key}=/)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def minimum_requirements
|
|
86
|
+
%w(type username password ccnumber ccexp amount)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
#EXAMPLE RESPONSE: response=3&responsetext=Invalid+Card&authcode=&transactionid=12345&avsresponse=&cvvresponse=
|
|
90
|
+
|
|
91
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
class ViaklixTest < Test::Unit::TestCase
|
|
3
|
+
include ActiveMerchant::Billing
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = ViaklixGateway.new(
|
|
6
|
+
:login => 'LOGIN',
|
|
7
|
+
:password => 'PIN'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
@creditcard = credit_card('4242424242424242')
|
|
11
|
+
|
|
12
|
+
@options = {
|
|
13
|
+
:order_id => '37',
|
|
14
|
+
:email => "paul@domain.com",
|
|
15
|
+
:description => 'Test Transaction',
|
|
16
|
+
:address => {
|
|
17
|
+
:address1 => '164 Waverley Street',
|
|
18
|
+
:address2 => 'APT #7',
|
|
19
|
+
:country => 'US',
|
|
20
|
+
:city => 'Boulder',
|
|
21
|
+
:state => 'CO',
|
|
22
|
+
:zip => '12345'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_purchase_success
|
|
28
|
+
@creditcard.number = 1
|
|
29
|
+
|
|
30
|
+
assert response = @gateway.purchase(100, @creditcard)
|
|
31
|
+
assert_equal Response, response.class
|
|
32
|
+
assert_equal '#0001', response.params['receiptid']
|
|
33
|
+
assert_equal true, response.success?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_purchase_error
|
|
37
|
+
@creditcard.number = 2
|
|
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
|
|
48
|
+
|
|
49
|
+
assert_raise(Error) do
|
|
50
|
+
assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_invalid_login
|
|
55
|
+
@gateway.expects(:ssl_post).returns(invalid_login_response)
|
|
56
|
+
|
|
57
|
+
assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
|
|
58
|
+
|
|
59
|
+
assert_equal '7000', response.params['result']
|
|
60
|
+
assert_equal 'The viaKLIX ID and/or User ID supplied in the authorization request is invalid.', response.params['result_message']
|
|
61
|
+
assert_failure response
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
def invalid_login_response
|
|
67
|
+
<<-RESPONSE
|
|
68
|
+
ssl_result=7000\r
|
|
69
|
+
ssl_result_message=The viaKLIX ID and/or User ID supplied in the authorization request is invalid.\r
|
|
70
|
+
RESPONSE
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
|
|
16
|
+
class ActionViewHelperTest < Test::Unit::TestCase
|
|
17
|
+
include ActiveMerchant::Billing::Integrations::ActionViewHelper
|
|
18
|
+
include ActionView::Helpers::FormHelper
|
|
19
|
+
include ActionView::Helpers::FormTagHelper
|
|
20
|
+
include ActionView::Helpers::UrlHelper
|
|
21
|
+
include ActionView::Helpers::TagHelper
|
|
22
|
+
include ActionView::Helpers::TextHelper
|
|
23
|
+
|
|
24
|
+
def setup
|
|
25
|
+
@controller = Class.new do
|
|
26
|
+
attr_reader :url_for_options
|
|
27
|
+
def url_for(options, *parameters_for_method_reference)
|
|
28
|
+
@url_for_options = options
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
@controller = @controller.new
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_basic_payment_service
|
|
35
|
+
_erbout = ''
|
|
36
|
+
|
|
37
|
+
payment_service_for('order-1','test', :service => :bogus){}
|
|
38
|
+
|
|
39
|
+
expected = [
|
|
40
|
+
'<form action="http://www.bogus.com" method="post">',
|
|
41
|
+
'<input id="order" name="order" type="hidden" value="order-1" />',
|
|
42
|
+
'<input id="account" name="account" type="hidden" value="test" />',
|
|
43
|
+
"</form>"
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
_erbout.each_line do |line|
|
|
47
|
+
assert expected.include?(line.chomp), "Failed to match #{line}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_payment_service_no_block_given
|
|
52
|
+
assert_raise(ArgumentError){ payment_service_for }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class BogusModuleTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def test_notification_method
|
|
7
|
+
assert_instance_of Bogus::Notification, Bogus.notification('name=cody')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_service_url
|
|
11
|
+
new = 'http://www.unbogus.com'
|
|
12
|
+
assert_equal 'http://www.bogus.com', Bogus.service_url
|
|
13
|
+
Bogus.service_url = new
|
|
14
|
+
assert_equal new, Bogus.service_url
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class ChronopayModuleTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def test_notification_method
|
|
7
|
+
assert_instance_of Chronopay::Notification, Chronopay.notification('name=cody')
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class GestpayModuleTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def test_notification_method
|
|
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
|
+
assert_instance_of Gestpay::Notification, Gestpay.notification('a=900000&b=F7DEB36478FD84760F9134F23C922697272D57DE6D4518EB9B4D468B769D9A3A8071B6EB160B35CB412FC1820C7CC12D17B3141855B1ED55468613702A2E213DDE9DE5B0209E13C416448AE833525959F05693172D7F0656')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
|
2
|
+
|
|
3
|
+
class BogusHelperTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@helper = Bogus::Helper.new('order-500','cfauser', :amount => 500, :currency => 'CAD')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_basic_helper_fields
|
|
11
|
+
assert_field 'order', 'order-500'
|
|
12
|
+
assert_field 'account', 'cfauser'
|
|
13
|
+
assert_field 'amount', '500'
|
|
14
|
+
assert_field 'currency', 'CAD'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_customer_fields
|
|
18
|
+
@helper.customer :first_name => 'Cody', :last_name => 'Fauser'
|
|
19
|
+
assert_field 'first_name', 'Cody'
|
|
20
|
+
assert_field 'last_name', 'Fauser'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_setting_unknown_field
|
|
24
|
+
fields = @helper.fields.dup
|
|
25
|
+
@helper.space_shuttle :name => 'Rockety'
|
|
26
|
+
assert_equal fields, @helper.fields
|
|
27
|
+
end
|
|
28
|
+
end
|