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
data/test/test_helper.rb
CHANGED
|
@@ -17,76 +17,133 @@ require 'digest/md5'
|
|
|
17
17
|
|
|
18
18
|
require File.dirname(__FILE__) + '/../lib/active_merchant'
|
|
19
19
|
|
|
20
|
+
begin
|
|
21
|
+
if respond_to? :gem
|
|
22
|
+
gem 'actionpack'
|
|
23
|
+
else
|
|
24
|
+
require_gem 'actionpack'
|
|
25
|
+
end
|
|
26
|
+
rescue LoadError
|
|
27
|
+
raise StandardError, "The view tests need ActionPack installed as gem to run"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
require 'action_controller'
|
|
31
|
+
require 'action_controller/test_process'
|
|
32
|
+
require 'active_merchant/billing/integrations/action_view_helper'
|
|
33
|
+
|
|
20
34
|
ActiveMerchant::Billing::Base.mode = :test
|
|
21
35
|
|
|
22
|
-
module
|
|
23
|
-
module
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
module ActiveMerchant
|
|
37
|
+
module Assertions
|
|
38
|
+
def assert_field(field, value)
|
|
39
|
+
clean_backtrace do
|
|
40
|
+
assert_equal value, @helper.fields[field]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
29
43
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
# Allows the testing of you to check for negative assertions:
|
|
45
|
+
#
|
|
46
|
+
# # Instead of
|
|
47
|
+
# assert !something_that_is_false
|
|
48
|
+
#
|
|
49
|
+
# # Do this
|
|
50
|
+
# assert_false something_that_should_be_false
|
|
51
|
+
#
|
|
52
|
+
# An optional +msg+ parameter is available to help you debug.
|
|
53
|
+
def assert_false(boolean, message = nil)
|
|
54
|
+
message = build_message message, '<?> is not false or nil.', boolean
|
|
55
|
+
|
|
56
|
+
clean_backtrace do
|
|
41
57
|
assert_block message do
|
|
42
58
|
not boolean
|
|
43
59
|
end
|
|
44
60
|
end
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# A handy little assertion to check for a successful response:
|
|
64
|
+
#
|
|
65
|
+
# # Instead of
|
|
66
|
+
# assert_success response
|
|
67
|
+
#
|
|
68
|
+
# # DRY that up with
|
|
69
|
+
# assert_success response
|
|
70
|
+
#
|
|
71
|
+
# A message will automatically show the inspection of the response
|
|
72
|
+
# object if things go afoul.
|
|
73
|
+
def assert_success(response)
|
|
74
|
+
clean_backtrace do
|
|
57
75
|
assert response.success?, "Response failed: #{response.inspect}"
|
|
58
76
|
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# The negative of +assert_success+
|
|
80
|
+
def assert_failure(response)
|
|
81
|
+
clean_backtrace do
|
|
62
82
|
assert_false response.success?, "Response expected to fail: #{response.inspect}"
|
|
63
83
|
end
|
|
84
|
+
end
|
|
64
85
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
md5.hexdigest
|
|
86
|
+
def assert_valid(validateable)
|
|
87
|
+
clean_backtrace do
|
|
88
|
+
assert validateable.valid?, "Expected to be valid"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def assert_not_valid(validateable)
|
|
93
|
+
clean_backtrace do
|
|
94
|
+
assert_false validateable.valid?, "Expected to not be valid"
|
|
75
95
|
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
def clean_backtrace(&block)
|
|
100
|
+
yield
|
|
101
|
+
rescue Test::Unit::AssertionFailedError => e
|
|
102
|
+
path = File.expand_path(__FILE__)
|
|
103
|
+
raise Test::Unit::AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
module Test
|
|
109
|
+
module Unit
|
|
110
|
+
class TestCase
|
|
111
|
+
LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
|
|
112
|
+
DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
|
|
76
113
|
|
|
77
|
-
|
|
114
|
+
include ActiveMerchant::Billing
|
|
115
|
+
include ActiveMerchant::Assertions
|
|
116
|
+
include ActiveMerchant::Utils
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
def credit_card(number = '4242424242424242', options = {})
|
|
78
120
|
defaults = {
|
|
79
121
|
:number => number,
|
|
80
122
|
:month => 9,
|
|
81
123
|
:year => Time.now.year + 1,
|
|
82
124
|
:first_name => 'Longbob',
|
|
83
125
|
:last_name => 'Longsen',
|
|
84
|
-
:verification_value => '123'
|
|
126
|
+
:verification_value => '123',
|
|
127
|
+
:type => 'visa'
|
|
85
128
|
}.update(options)
|
|
86
129
|
|
|
87
130
|
ActiveMerchant::Billing::CreditCard.new(defaults)
|
|
88
131
|
end
|
|
89
132
|
|
|
133
|
+
def address(options = {})
|
|
134
|
+
{
|
|
135
|
+
:name => 'Jim Smith',
|
|
136
|
+
:address1 => '1234 My Street',
|
|
137
|
+
:address2 => 'Apt 1',
|
|
138
|
+
:company => 'Widgets Inc',
|
|
139
|
+
:city => 'Ottawa',
|
|
140
|
+
:state => 'ON',
|
|
141
|
+
:zip => 'K1C2N6',
|
|
142
|
+
:country => 'CA',
|
|
143
|
+
:phone => '(555)555-5555'
|
|
144
|
+
}.update(options)
|
|
145
|
+
end
|
|
146
|
+
|
|
90
147
|
def all_fixtures
|
|
91
148
|
@@fixtures ||= load_fixtures
|
|
92
149
|
end
|
|
@@ -112,21 +169,5 @@ module Test
|
|
|
112
169
|
hash.each{|k,v| symbolize_keys(v)}
|
|
113
170
|
end
|
|
114
171
|
end
|
|
115
|
-
|
|
116
|
-
module Assertions
|
|
117
|
-
def assert_field(field, value)
|
|
118
|
-
clean_backtrace do
|
|
119
|
-
assert_equal value, @helper.fields[field]
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
private
|
|
124
|
-
def clean_backtrace(&block)
|
|
125
|
-
yield
|
|
126
|
-
rescue AssertionFailedError => e
|
|
127
|
-
path = File.expand_path(__FILE__)
|
|
128
|
-
raise AssertionFailedError, e.message, e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
172
|
end
|
|
132
173
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class AVSResultTest < Test::Unit::TestCase
|
|
4
|
+
def test_nil
|
|
5
|
+
result = AVSResult.new(nil)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def test_no_match
|
|
9
|
+
result = AVSResult.new(:code => 'N')
|
|
10
|
+
assert_equal 'N', result.code
|
|
11
|
+
assert_equal 'N', result.street_match
|
|
12
|
+
assert_equal 'N', result.postal_match
|
|
13
|
+
assert_equal AVSResult.messages['N'], result.message
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_only_street_match
|
|
17
|
+
result = AVSResult.new(:code => 'A')
|
|
18
|
+
assert_equal 'A', result.code
|
|
19
|
+
assert_equal 'Y', result.street_match
|
|
20
|
+
assert_equal 'N', result.postal_match
|
|
21
|
+
assert_equal AVSResult.messages['A'], result.message
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_only_postal_match
|
|
25
|
+
result = AVSResult.new(:code => 'W')
|
|
26
|
+
assert_equal 'W', result.code
|
|
27
|
+
assert_equal 'N', result.street_match
|
|
28
|
+
assert_equal 'Y', result.postal_match
|
|
29
|
+
assert_equal AVSResult.messages['W'], result.message
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_nil_data
|
|
33
|
+
result = AVSResult.new(:code => nil)
|
|
34
|
+
assert_nil result.code
|
|
35
|
+
assert_nil result.message
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_empty_data
|
|
39
|
+
result = AVSResult.new(:code => '')
|
|
40
|
+
assert_nil result.code
|
|
41
|
+
assert_nil result.message
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_to_hash
|
|
45
|
+
avs_data = AVSResult.new(:code => 'X').to_hash
|
|
46
|
+
assert_equal 'X', avs_data['code']
|
|
47
|
+
assert_equal AVSResult.messages['X'], avs_data['message']
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_street_match
|
|
51
|
+
avs_data = AVSResult.new(:street_match => 'Y')
|
|
52
|
+
assert_equal 'Y', avs_data.street_match
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_postal_match
|
|
56
|
+
avs_data = AVSResult.new(:postal_match => 'Y')
|
|
57
|
+
assert_equal 'Y', avs_data.postal_match
|
|
58
|
+
end
|
|
59
|
+
end
|
data/test/unit/base_test.rb
CHANGED
|
@@ -8,54 +8,48 @@ class BaseTest < Test::Unit::TestCase
|
|
|
8
8
|
def teardown
|
|
9
9
|
ActiveMerchant::Billing::Base.mode = :test
|
|
10
10
|
end
|
|
11
|
-
|
|
12
|
-
def test_get_gateway_by_name
|
|
13
|
-
assert_equal BogusGateway, Base.gateway(:bogus)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_get_moneris_by_name
|
|
17
|
-
assert_equal MonerisGateway, Base.gateway(:moneris)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_get_authorize_net_by_name
|
|
21
|
-
assert_equal AuthorizeNetGateway, Base.gateway(:authorize_net)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def test_get_usay_epay_by_name
|
|
25
|
-
assert_equal UsaEpayGateway, Base.gateway(:usa_epay)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def test_get_linkpoint_by_name
|
|
29
|
-
assert_equal LinkpointGateway, Base.gateway(:linkpoint)
|
|
30
|
-
end
|
|
31
11
|
|
|
32
|
-
def
|
|
12
|
+
def test_should_return_a_new_gateway_specified_by_symbol_name
|
|
13
|
+
assert_equal BogusGateway, Base.gateway(:bogus)
|
|
14
|
+
assert_equal MonerisGateway, Base.gateway(:moneris)
|
|
15
|
+
assert_equal AuthorizeNetGateway, Base.gateway(:authorize_net)
|
|
16
|
+
assert_equal UsaEpayGateway, Base.gateway(:usa_epay)
|
|
17
|
+
assert_equal LinkpointGateway, Base.gateway(:linkpoint)
|
|
33
18
|
assert_equal AuthorizedNetGateway, Base.gateway(:authorized_net)
|
|
34
19
|
end
|
|
35
20
|
|
|
36
|
-
def
|
|
21
|
+
def test_should_return_an_integration_by_name
|
|
37
22
|
chronopay = Base.integration(:chronopay)
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
|
|
24
|
+
assert_equal Integrations::Chronopay, chronopay
|
|
25
|
+
assert_instance_of Integrations::Chronopay::Notification, chronopay.notification('name=cody')
|
|
40
26
|
end
|
|
41
27
|
|
|
42
|
-
def
|
|
43
|
-
|
|
44
|
-
assert_equal :test,
|
|
45
|
-
assert_equal :test,
|
|
46
|
-
assert_equal :test,
|
|
28
|
+
def test_should_set_modes
|
|
29
|
+
Base.mode = :test
|
|
30
|
+
assert_equal :test, Base.mode
|
|
31
|
+
assert_equal :test, Base.gateway_mode
|
|
32
|
+
assert_equal :test, Base.integration_mode
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
assert_equal :production,
|
|
50
|
-
assert_equal :production,
|
|
51
|
-
assert_equal :production,
|
|
34
|
+
Base.mode = :production
|
|
35
|
+
assert_equal :production, Base.mode
|
|
36
|
+
assert_equal :production, Base.gateway_mode
|
|
37
|
+
assert_equal :production, Base.integration_mode
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
assert_equal :development,
|
|
57
|
-
assert_equal :test,
|
|
58
|
-
assert_equal :staging,
|
|
39
|
+
Base.mode = :development
|
|
40
|
+
Base.gateway_mode = :test
|
|
41
|
+
Base.integration_mode = :staging
|
|
42
|
+
assert_equal :development, Base.mode
|
|
43
|
+
assert_equal :test, Base.gateway_mode
|
|
44
|
+
assert_equal :staging, Base.integration_mode
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_should_identify_if_test_mode
|
|
48
|
+
Base.gateway_mode = :test
|
|
49
|
+
assert Base.test?
|
|
50
|
+
|
|
51
|
+
Base.gateway_mode = :production
|
|
52
|
+
assert_false Base.test?
|
|
59
53
|
end
|
|
60
54
|
|
|
61
55
|
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class CheckTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing
|
|
5
|
+
|
|
6
|
+
VALID_ABA = '111000025'
|
|
7
|
+
INVALID_ABA = '999999999'
|
|
8
|
+
MALFORMED_ABA = 'I like fish'
|
|
9
|
+
|
|
10
|
+
ACCOUNT_NUMBER = '123456789012'
|
|
11
|
+
|
|
12
|
+
def test_validation
|
|
13
|
+
c = Check.new
|
|
14
|
+
assert !c.valid?
|
|
15
|
+
assert !c.errors.empty?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_valid
|
|
19
|
+
c = Check.new(:name => 'Fred Bloggs',
|
|
20
|
+
:routing_number => VALID_ABA,
|
|
21
|
+
:account_number => ACCOUNT_NUMBER,
|
|
22
|
+
:account_holder_type => 'personal',
|
|
23
|
+
:account_type => 'checking')
|
|
24
|
+
assert c.valid?
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_invalid_routing_number
|
|
28
|
+
c = Check.new(:routing_number => INVALID_ABA)
|
|
29
|
+
assert !c.valid?
|
|
30
|
+
assert_equal c.errors.on(:routing_number), "is invalid"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_malformed_routing_number
|
|
34
|
+
c = Check.new(:routing_number => MALFORMED_ABA)
|
|
35
|
+
assert !c.valid?
|
|
36
|
+
assert_equal c.errors.on(:routing_number), "is invalid"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_account_holder_type
|
|
40
|
+
c = Check.new
|
|
41
|
+
c.account_holder_type = 'business'
|
|
42
|
+
c.valid?
|
|
43
|
+
assert !c.errors.on(:account_holder_type)
|
|
44
|
+
|
|
45
|
+
c.account_holder_type = 'personal'
|
|
46
|
+
c.valid?
|
|
47
|
+
assert !c.errors.on(:account_holder_type)
|
|
48
|
+
|
|
49
|
+
c.account_holder_type = 'pleasure'
|
|
50
|
+
c.valid?
|
|
51
|
+
assert_equal c.errors.on(:account_holder_type), 'must be personal or business'
|
|
52
|
+
|
|
53
|
+
c.account_holder_type = nil
|
|
54
|
+
c.valid?
|
|
55
|
+
assert !c.errors.on(:account_holder_type)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_account_type
|
|
59
|
+
c = Check.new
|
|
60
|
+
c.account_type = 'checking'
|
|
61
|
+
c.valid?
|
|
62
|
+
assert !c.errors.on(:account_type)
|
|
63
|
+
|
|
64
|
+
c.account_type = 'savings'
|
|
65
|
+
c.valid?
|
|
66
|
+
assert !c.errors.on(:account_type)
|
|
67
|
+
|
|
68
|
+
c.account_type = 'moo'
|
|
69
|
+
c.valid?
|
|
70
|
+
assert_equal c.errors.on(:account_type), "must be checking or savings"
|
|
71
|
+
|
|
72
|
+
c.account_type = nil
|
|
73
|
+
c.valid?
|
|
74
|
+
assert !c.errors.on(:account_type)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -3,22 +3,17 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
|
3
3
|
class CreditCardFormattingTest < Test::Unit::TestCase
|
|
4
4
|
include ActiveMerchant::Billing::CreditCardFormatting
|
|
5
5
|
|
|
6
|
-
def
|
|
7
|
-
|
|
6
|
+
def test_should_format_number_by_rule
|
|
7
|
+
assert_equal 2005, format(2005, :steven_colbert)
|
|
8
8
|
|
|
9
|
-
assert_equal '05', format(year, :two_digits)
|
|
10
|
-
assert_equal '2005', format(year, :four_digits)
|
|
11
|
-
assert_equal '05', format(05, :two_digits)
|
|
12
9
|
assert_equal '0005', format(05, :four_digits)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
assert_equal '08', format(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
assert_equal '', format(nil, :two_digits)
|
|
22
|
-
assert_equal '', format('', :two_digits)
|
|
10
|
+
assert_equal '2005', format(2005, :four_digits)
|
|
11
|
+
|
|
12
|
+
assert_equal '05', format(2005, :two_digits)
|
|
13
|
+
assert_equal '05', format(05, :two_digits)
|
|
14
|
+
assert_equal '08', format(8, :two_digits)
|
|
15
|
+
|
|
16
|
+
assert format(nil, :two_digits).blank?
|
|
17
|
+
assert format('', :two_digits).blank?
|
|
23
18
|
end
|
|
24
19
|
end
|