activemerchant 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +9 -0
- data/MIT-LICENSE +1 -1
- data/lib/active_merchant.rb +6 -26
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +12 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -1
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +40 -1
- data/lib/active_merchant/billing/integrations/two_checkout.rb +1 -1
- metadata +9 -173
- metadata.gz.sig +0 -0
- data/Rakefile +0 -153
- data/init.rb +0 -3
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/test/fixtures.yml +0 -355
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +0 -460
- data/test/remote/gateways/remote_authorize_net_test.rb +0 -145
- data/test/remote/gateways/remote_beanstream_interac_test.rb +0 -53
- data/test/remote/gateways/remote_beanstream_test.rb +0 -150
- data/test/remote/gateways/remote_braintree_test.rb +0 -147
- data/test/remote/gateways/remote_card_stream_test.rb +0 -148
- data/test/remote/gateways/remote_cyber_source_test.rb +0 -144
- data/test/remote/gateways/remote_data_cash_test.rb +0 -356
- data/test/remote/gateways/remote_efsnet_test.rb +0 -81
- data/test/remote/gateways/remote_elavon_test.rb +0 -66
- data/test/remote/gateways/remote_eway_test.rb +0 -74
- data/test/remote/gateways/remote_exact_test.rb +0 -60
- data/test/remote/gateways/remote_first_pay_test.rb +0 -87
- data/test/remote/gateways/remote_instapay_test.rb +0 -61
- data/test/remote/gateways/remote_jetpay_test.rb +0 -103
- data/test/remote/gateways/remote_linkpoint_test.rb +0 -121
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +0 -173
- data/test/remote/gateways/remote_merchant_ware_test.rb +0 -113
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +0 -58
- data/test/remote/gateways/remote_modern_payments_test.rb +0 -57
- data/test/remote/gateways/remote_moneris_test.rb +0 -82
- data/test/remote/gateways/remote_net_registry_test.rb +0 -85
- data/test/remote/gateways/remote_netbilling_test.rb +0 -70
- data/test/remote/gateways/remote_ogone_test.rb +0 -115
- data/test/remote/gateways/remote_pay_junction_test.rb +0 -143
- data/test/remote/gateways/remote_pay_secure_test.rb +0 -39
- data/test/remote/gateways/remote_payflow_express_test.rb +0 -50
- data/test/remote/gateways/remote_payflow_test.rb +0 -237
- data/test/remote/gateways/remote_payflow_uk_test.rb +0 -173
- data/test/remote/gateways/remote_payment_express_test.rb +0 -136
- data/test/remote/gateways/remote_paypal_express_test.rb +0 -49
- data/test/remote/gateways/remote_paypal_test.rb +0 -191
- data/test/remote/gateways/remote_plugnpay_test.rb +0 -72
- data/test/remote/gateways/remote_psigate_test.rb +0 -50
- data/test/remote/gateways/remote_psl_card_test.rb +0 -123
- data/test/remote/gateways/remote_quickpay_test.rb +0 -190
- data/test/remote/gateways/remote_realex_test.rb +0 -224
- data/test/remote/gateways/remote_sage_bankcard_test.rb +0 -109
- data/test/remote/gateways/remote_sage_pay_test.rb +0 -219
- data/test/remote/gateways/remote_sage_test.rb +0 -87
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +0 -62
- data/test/remote/gateways/remote_sallie_mae_test.rb +0 -51
- data/test/remote/gateways/remote_secure_pay_au_test.rb +0 -40
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +0 -37
- data/test/remote/gateways/remote_secure_pay_test.rb +0 -28
- data/test/remote/gateways/remote_skipjack_test.rb +0 -105
- data/test/remote/gateways/remote_trans_first_test.rb +0 -34
- data/test/remote/gateways/remote_transax_test.rb +0 -112
- data/test/remote/gateways/remote_trust_commerce_test.rb +0 -152
- data/test/remote/gateways/remote_usa_epay_test.rb +0 -46
- data/test/remote/gateways/remote_verifi_test.rb +0 -107
- data/test/remote/gateways/remote_viaklix_test.rb +0 -43
- data/test/remote/gateways/remote_wirecard_test.rb +0 -111
- data/test/remote/integrations/remote_gestpay_integration_test.rb +0 -37
- data/test/remote/integrations/remote_paypal_integration_test.rb +0 -26
- data/test/test_helper.rb +0 -184
- data/test/unit/avs_result_test.rb +0 -59
- data/test/unit/base_test.rb +0 -54
- data/test/unit/check_test.rb +0 -88
- data/test/unit/connection_test.rb +0 -129
- data/test/unit/country_code_test.rb +0 -33
- data/test/unit/country_test.rb +0 -64
- data/test/unit/credit_card_formatting_test.rb +0 -19
- data/test/unit/credit_card_methods_test.rb +0 -179
- data/test/unit/credit_card_test.rb +0 -318
- data/test/unit/cvv_result_test.rb +0 -33
- data/test/unit/expiry_date_test.rb +0 -32
- data/test/unit/gateways/authorize_net_cim_test.rb +0 -676
- data/test/unit/gateways/authorize_net_test.rb +0 -290
- data/test/unit/gateways/beanstream_interac_test.rb +0 -51
- data/test/unit/gateways/beanstream_test.rb +0 -108
- data/test/unit/gateways/bogus_test.rb +0 -46
- data/test/unit/gateways/braintree_test.rb +0 -118
- data/test/unit/gateways/card_stream_test.rb +0 -90
- data/test/unit/gateways/cyber_source_test.rb +0 -188
- data/test/unit/gateways/data_cash_test.rb +0 -133
- data/test/unit/gateways/efsnet_test.rb +0 -123
- data/test/unit/gateways/elavon_test.rb +0 -139
- data/test/unit/gateways/eway_test.rb +0 -118
- data/test/unit/gateways/exact_test.rb +0 -156
- data/test/unit/gateways/first_pay_test.rb +0 -125
- data/test/unit/gateways/gateway_test.rb +0 -48
- data/test/unit/gateways/instapay_test.rb +0 -102
- data/test/unit/gateways/jetpay_test.rb +0 -185
- data/test/unit/gateways/linkpoint_test.rb +0 -197
- data/test/unit/gateways/merchant_e_solutions_test.rb +0 -169
- data/test/unit/gateways/merchant_ware_test.rb +0 -188
- data/test/unit/gateways/modern_payments_cim_test.rb +0 -162
- data/test/unit/gateways/moneris_test.rb +0 -158
- data/test/unit/gateways/net_registry_test.rb +0 -416
- data/test/unit/gateways/netbilling_test.rb +0 -54
- data/test/unit/gateways/ogone_test.rb +0 -319
- data/test/unit/gateways/pay_junction_test.rb +0 -123
- data/test/unit/gateways/pay_secure_test.rb +0 -71
- data/test/unit/gateways/payflow_express_test.rb +0 -173
- data/test/unit/gateways/payflow_express_uk_test.rb +0 -86
- data/test/unit/gateways/payflow_test.rb +0 -305
- data/test/unit/gateways/payflow_uk_test.rb +0 -30
- data/test/unit/gateways/payment_express_test.rb +0 -195
- data/test/unit/gateways/paypal_express_test.rb +0 -382
- data/test/unit/gateways/paypal_test.rb +0 -569
- data/test/unit/gateways/plugnpay_test.rb +0 -86
- data/test/unit/gateways/psigate_test.rb +0 -169
- data/test/unit/gateways/psl_card_test.rb +0 -64
- data/test/unit/gateways/quickpay_test.rb +0 -112
- data/test/unit/gateways/realex_test.rb +0 -151
- data/test/unit/gateways/sage_bankcard_test.rb +0 -196
- data/test/unit/gateways/sage_pay_test.rb +0 -139
- data/test/unit/gateways/sage_virtual_check_test.rb +0 -71
- data/test/unit/gateways/sallie_mae_test.rb +0 -53
- data/test/unit/gateways/secure_pay_au_test.rb +0 -207
- data/test/unit/gateways/secure_pay_tech_test.rb +0 -44
- data/test/unit/gateways/secure_pay_test.rb +0 -101
- data/test/unit/gateways/skip_jack_test.rb +0 -213
- data/test/unit/gateways/trans_first_test.rb +0 -112
- data/test/unit/gateways/trust_commerce_test.rb +0 -90
- data/test/unit/gateways/usa_epay_test.rb +0 -128
- data/test/unit/gateways/verifi_test.rb +0 -96
- data/test/unit/gateways/viaklix_test.rb +0 -78
- data/test/unit/gateways/wirecard_test.rb +0 -250
- data/test/unit/generators/test_gateway_generator.rb +0 -46
- data/test/unit/generators/test_generator_helper.rb +0 -20
- data/test/unit/generators/test_integration_generator.rb +0 -53
- data/test/unit/integrations/action_view_helper_test.rb +0 -50
- data/test/unit/integrations/bogus_module_test.rb +0 -20
- data/test/unit/integrations/chronopay_module_test.rb +0 -13
- data/test/unit/integrations/gestpay_module_test.rb +0 -14
- data/test/unit/integrations/helpers/bogus_helper_test.rb +0 -28
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +0 -67
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +0 -100
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +0 -16
- data/test/unit/integrations/helpers/nochex_helper_test.rb +0 -53
- data/test/unit/integrations/helpers/paypal_helper_test.rb +0 -171
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +0 -40
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +0 -92
- data/test/unit/integrations/hi_trust_module_test.rb +0 -13
- data/test/unit/integrations/nochex_module_test.rb +0 -13
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +0 -66
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +0 -60
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +0 -59
- data/test/unit/integrations/notifications/nochex_notification_test.rb +0 -51
- data/test/unit/integrations/notifications/notification_test.rb +0 -54
- data/test/unit/integrations/notifications/paypal_notification_test.rb +0 -85
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +0 -69
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +0 -55
- data/test/unit/integrations/paypal_module_test.rb +0 -28
- data/test/unit/integrations/quickpay_module_test.rb +0 -9
- data/test/unit/integrations/returns/chronopay_return_test.rb +0 -11
- data/test/unit/integrations/returns/gestpay_return_test.rb +0 -10
- data/test/unit/integrations/returns/hi_trust_return_test.rb +0 -24
- data/test/unit/integrations/returns/nochex_return_test.rb +0 -10
- data/test/unit/integrations/returns/paypal_return_test.rb +0 -10
- data/test/unit/integrations/returns/return_test.rb +0 -11
- data/test/unit/integrations/returns/two_checkout_return_test.rb +0 -24
- data/test/unit/integrations/two_checkout_module_test.rb +0 -13
- data/test/unit/post_data_test.rb +0 -55
- data/test/unit/posts_data_test.rb +0 -48
- data/test/unit/response_test.rb +0 -28
- data/test/unit/utils_test.rb +0 -7
- data/test/unit/validateable_test.rb +0 -60
@@ -1,148 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RemoteCardStreamTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
Base.mode = :test
|
6
|
-
|
7
|
-
@gateway = CardStreamGateway.new(fixtures(:card_stream))
|
8
|
-
|
9
|
-
@amex = credit_card('374245455400001',
|
10
|
-
:month => '12',
|
11
|
-
:year => '2009',
|
12
|
-
:verification_value => '4887',
|
13
|
-
:type => :american_express
|
14
|
-
)
|
15
|
-
|
16
|
-
@uk_maestro = credit_card('675940410531100173',
|
17
|
-
:month => '12',
|
18
|
-
:year => '2008',
|
19
|
-
:issue_number => '0',
|
20
|
-
:verification_value => '134',
|
21
|
-
:type => :switch
|
22
|
-
)
|
23
|
-
|
24
|
-
@solo = credit_card('676740340572345678',
|
25
|
-
:month => '12',
|
26
|
-
:year => '2008',
|
27
|
-
:issue_number => '1',
|
28
|
-
:verification_value => '773',
|
29
|
-
:type => :solo
|
30
|
-
)
|
31
|
-
|
32
|
-
@mastercard = credit_card('5301250070000191',
|
33
|
-
:month => '12',
|
34
|
-
:year => '2009',
|
35
|
-
:verification_value => '419',
|
36
|
-
:type => :master
|
37
|
-
)
|
38
|
-
|
39
|
-
@declined_card = credit_card('4000300011112220',
|
40
|
-
:month => '9',
|
41
|
-
:year => '2009'
|
42
|
-
)
|
43
|
-
|
44
|
-
@mastercard_options = {
|
45
|
-
:billing_address => {
|
46
|
-
:address1 => '25 The Larches',
|
47
|
-
:city => "Narborough",
|
48
|
-
:state => "Leicester",
|
49
|
-
:zip => 'LE10 2RT'
|
50
|
-
},
|
51
|
-
:order_id => generate_unique_id,
|
52
|
-
:description => 'Store purchase'
|
53
|
-
}
|
54
|
-
|
55
|
-
@uk_maestro_options = {
|
56
|
-
:billing_address => {
|
57
|
-
:address1 => 'The Parkway',
|
58
|
-
:address2 => "Larches Approach",
|
59
|
-
:city => "Hull",
|
60
|
-
:state => "North Humberside",
|
61
|
-
:zip => 'HU7 9OP'
|
62
|
-
},
|
63
|
-
:order_id => generate_unique_id,
|
64
|
-
:description => 'Store purchase'
|
65
|
-
}
|
66
|
-
|
67
|
-
@solo_options = {
|
68
|
-
:billing_address => {
|
69
|
-
:address1 => '5 Zigzag Road',
|
70
|
-
:city => 'Isleworth',
|
71
|
-
:state => 'Middlesex',
|
72
|
-
:zip => 'TW7 8FF'
|
73
|
-
},
|
74
|
-
:order_id => generate_unique_id,
|
75
|
-
:description => 'Store purchase'
|
76
|
-
}
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_successful_mastercard_purchase
|
80
|
-
assert response = @gateway.purchase(100, @mastercard, @mastercard_options)
|
81
|
-
assert_equal 'APPROVED', response.message
|
82
|
-
assert_success response
|
83
|
-
assert response.test?
|
84
|
-
assert !response.authorization.blank?
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_declined_mastercard_purchase
|
88
|
-
assert response = @gateway.purchase(10000, @mastercard, @mastercard_options)
|
89
|
-
assert_equal 'CARD DECLINED', response.message
|
90
|
-
assert_failure response
|
91
|
-
assert response.test?
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_expired_mastercard
|
95
|
-
@mastercard.year = 2005
|
96
|
-
assert response = @gateway.purchase(100, @mastercard, @mastercard_options)
|
97
|
-
assert_equal 'CARD EXPIRED', response.message
|
98
|
-
assert_failure response
|
99
|
-
assert response.test?
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_successful_maestro_purchase
|
103
|
-
assert response = @gateway.purchase(100, @uk_maestro, @uk_maestro_options)
|
104
|
-
assert_equal 'APPROVED', response.message
|
105
|
-
assert_success response
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_successful_solo_purchase
|
109
|
-
assert response = @gateway.purchase(100, @solo, @solo_options)
|
110
|
-
assert_equal 'APPROVED', response.message
|
111
|
-
assert_success response
|
112
|
-
assert response.test?
|
113
|
-
assert !response.authorization.blank?
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_successful_amex_purchase
|
117
|
-
assert response = @gateway.purchase(100, @amex, :order_id => generate_unique_id)
|
118
|
-
assert_equal 'APPROVED', response.message
|
119
|
-
assert_success response
|
120
|
-
assert response.test?
|
121
|
-
assert !response.authorization.blank?
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_maestro_missing_start_date_and_issue_date
|
125
|
-
@uk_maestro.issue_number = nil
|
126
|
-
assert response = @gateway.purchase(100, @uk_maestro, @uk_maestro_options)
|
127
|
-
assert_equal 'ISSUE NUMBER MISSING', response.message
|
128
|
-
assert_failure response
|
129
|
-
assert response.test?
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_invalid_login
|
133
|
-
gateway = CardStreamGateway.new(
|
134
|
-
:login => '',
|
135
|
-
:password => ''
|
136
|
-
)
|
137
|
-
assert response = gateway.purchase(100, @mastercard, @mastercard_options)
|
138
|
-
assert_equal 'MERCHANT ID MISSING', response.message
|
139
|
-
assert_failure response
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_unsupported_merchant_currency
|
143
|
-
assert response = @gateway.purchase(100, @mastercard, @mastercard_options.update(:currency => 'USD'))
|
144
|
-
assert_equal "ERROR 1052", response.message
|
145
|
-
assert_failure response
|
146
|
-
assert response.test?
|
147
|
-
end
|
148
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RemoteCyberSourceTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
Base.gateway_mode = :test
|
6
|
-
|
7
|
-
@gateway = CyberSourceGateway.new(fixtures(:cyber_source))
|
8
|
-
|
9
|
-
@credit_card = credit_card('4111111111111111', :type => 'visa')
|
10
|
-
@declined_card = credit_card('801111111111111', :type => 'visa')
|
11
|
-
|
12
|
-
@amount = 100
|
13
|
-
|
14
|
-
@options = {
|
15
|
-
:billing_address => address,
|
16
|
-
|
17
|
-
:order_id => generate_unique_id,
|
18
|
-
:line_items => [
|
19
|
-
{
|
20
|
-
:declared_value => 100,
|
21
|
-
:quantity => 2,
|
22
|
-
:code => 'default',
|
23
|
-
:description => 'Giant Walrus',
|
24
|
-
:sku => 'WA323232323232323'
|
25
|
-
},
|
26
|
-
{
|
27
|
-
:declared_value => 100,
|
28
|
-
:quantity => 2,
|
29
|
-
:description => 'Marble Snowcone',
|
30
|
-
:sku => 'FAKE1232132113123'
|
31
|
-
}
|
32
|
-
],
|
33
|
-
:currency => 'USD',
|
34
|
-
:email => 'someguy1232@fakeemail.net',
|
35
|
-
:ignore_avs => 'true',
|
36
|
-
:ignore_cvv => 'true'
|
37
|
-
}
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_successful_authorization
|
42
|
-
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
43
|
-
assert_equal 'Successful transaction', response.message
|
44
|
-
assert_success response
|
45
|
-
assert response.test?
|
46
|
-
assert !response.authorization.blank?
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_unsuccessful_authorization
|
50
|
-
assert response = @gateway.authorize(@amount, @declined_card, @options)
|
51
|
-
assert response.test?
|
52
|
-
assert_equal 'Invalid account number', response.message
|
53
|
-
assert_equal false, response.success?
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_successful_tax_calculation
|
57
|
-
assert response = @gateway.calculate_tax(@credit_card, @options)
|
58
|
-
assert_equal 'Successful transaction', response.message
|
59
|
-
assert response.params['totalTaxAmount']
|
60
|
-
assert_not_equal "0", response.params['totalTaxAmount']
|
61
|
-
assert_success response
|
62
|
-
assert response.test?
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_successful_tax_calculation_with_nexus
|
66
|
-
total_line_items_value = @options[:line_items].inject(0) do |sum, item|
|
67
|
-
sum += item[:declared_value] * item[:quantity]
|
68
|
-
end
|
69
|
-
|
70
|
-
canada_gst_rate = 0.05
|
71
|
-
ontario_pst_rate = 0.08
|
72
|
-
|
73
|
-
|
74
|
-
total_pst = total_line_items_value.to_f * ontario_pst_rate / 100
|
75
|
-
total_gst = total_line_items_value.to_f * canada_gst_rate / 100
|
76
|
-
total_tax = total_pst + total_gst
|
77
|
-
|
78
|
-
assert response = @gateway.calculate_tax(@credit_card, @options.merge(:nexus => 'ON'))
|
79
|
-
assert_equal 'Successful transaction', response.message
|
80
|
-
assert response.params['totalTaxAmount']
|
81
|
-
assert_equal total_pst, response.params['totalCountyTaxAmount'].to_f
|
82
|
-
assert_equal total_gst, response.params['totalStateTaxAmount'].to_f
|
83
|
-
assert_equal total_tax, response.params['totalTaxAmount'].to_f
|
84
|
-
assert_success response
|
85
|
-
assert response.test?
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_successful_purchase
|
89
|
-
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
90
|
-
assert_equal 'Successful transaction', response.message
|
91
|
-
assert_success response
|
92
|
-
assert response.test?
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_unsuccessful_purchase
|
96
|
-
assert response = @gateway.purchase(@amount, @declined_card, @options)
|
97
|
-
assert_equal 'Invalid account number', response.message
|
98
|
-
assert_failure response
|
99
|
-
assert response.test?
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_authorize_and_capture
|
103
|
-
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
104
|
-
assert_success auth
|
105
|
-
assert_equal 'Successful transaction', auth.message
|
106
|
-
|
107
|
-
assert capture = @gateway.capture(@amount, auth.authorization)
|
108
|
-
assert_success capture
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_successful_authorization_and_failed_capture
|
112
|
-
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
113
|
-
assert_success auth
|
114
|
-
assert_equal 'Successful transaction', auth.message
|
115
|
-
|
116
|
-
assert capture = @gateway.capture(@amount + 10, auth.authorization, @options)
|
117
|
-
assert_failure capture
|
118
|
-
assert_equal "The requested amount exceeds the originally authorized amount", capture.message
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_failed_capture_bad_auth_info
|
122
|
-
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
123
|
-
assert capture = @gateway.capture(@amount, "a;b;c", @options)
|
124
|
-
assert_failure capture
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_invalid_login
|
128
|
-
gateway = CyberSourceGateway.new( :login => '', :password => '' )
|
129
|
-
assert response = gateway.purchase(@amount, @credit_card, @options)
|
130
|
-
assert_match /wsse:InvalidSecurity/, response.message
|
131
|
-
assert_failure response
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_successful_credit
|
135
|
-
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
136
|
-
assert_equal 'Successful transaction', response.message
|
137
|
-
assert_success response
|
138
|
-
assert response.test?
|
139
|
-
assert response = @gateway.credit(@amount, response.authorization)
|
140
|
-
assert_equal 'Successful transaction', response.message
|
141
|
-
assert_success response
|
142
|
-
assert response.test?
|
143
|
-
end
|
144
|
-
end
|
@@ -1,356 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RemoteDataCashTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
# gateway to connect to Datacash
|
7
|
-
@gateway = DataCashGateway.new(fixtures(:data_cash))
|
8
|
-
|
9
|
-
@mastercard = CreditCard.new(
|
10
|
-
:number => '5473000000000007',
|
11
|
-
:month => 3,
|
12
|
-
:year => Date.today.year + 2,
|
13
|
-
:first_name => 'Mark',
|
14
|
-
:last_name => 'McBride',
|
15
|
-
:type => :master,
|
16
|
-
:verification_value => '547'
|
17
|
-
)
|
18
|
-
|
19
|
-
@mastercard_declined = CreditCard.new(
|
20
|
-
:number => '5473000000000106',
|
21
|
-
:month => 3,
|
22
|
-
:year => Date.today.year + 2,
|
23
|
-
:first_name => 'Mark',
|
24
|
-
:last_name => 'McBride',
|
25
|
-
:type => :master,
|
26
|
-
:verification_value => '547'
|
27
|
-
)
|
28
|
-
|
29
|
-
@visa_delta = CreditCard.new(
|
30
|
-
:number => '4539792100000003',
|
31
|
-
:month => 3,
|
32
|
-
:year => Date.today.year + 2,
|
33
|
-
:first_name => 'Mark',
|
34
|
-
:last_name => 'McBride',
|
35
|
-
:type => :visa,
|
36
|
-
:verification_value => '444'
|
37
|
-
)
|
38
|
-
|
39
|
-
@solo = CreditCard.new(
|
40
|
-
:first_name => 'Cody',
|
41
|
-
:last_name => 'Fauser',
|
42
|
-
:number => '633499100000000004',
|
43
|
-
:month => 3,
|
44
|
-
:year => Date.today.year + 2,
|
45
|
-
:type => :solo,
|
46
|
-
:issue_number => 5,
|
47
|
-
:start_month => 12,
|
48
|
-
:start_year => 2006,
|
49
|
-
:verification_value => 444
|
50
|
-
)
|
51
|
-
|
52
|
-
@address = {
|
53
|
-
:name => 'Mark McBride',
|
54
|
-
:address1 => 'Flat 12/3',
|
55
|
-
:address2 => '45 Main Road',
|
56
|
-
:city => 'Sometown',
|
57
|
-
:state => 'Somecounty',
|
58
|
-
:zip => 'A987AA',
|
59
|
-
:phone => '(555)555-5555'
|
60
|
-
}
|
61
|
-
|
62
|
-
@params = {
|
63
|
-
:order_id => generate_unique_id,
|
64
|
-
:billing_address => @address
|
65
|
-
}
|
66
|
-
|
67
|
-
@amount = 198
|
68
|
-
end
|
69
|
-
|
70
|
-
# Testing that we can successfully make a purchase in a one step
|
71
|
-
# operation
|
72
|
-
def test_successful_purchase
|
73
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
74
|
-
assert_success response
|
75
|
-
assert response.test?
|
76
|
-
end
|
77
|
-
|
78
|
-
#the amount is changed to £1.99 - the DC test server won't check the
|
79
|
-
#address details - this is more a check on the passed ExtendedPolicy
|
80
|
-
def test_successful_purchase_without_address_check
|
81
|
-
response = @gateway.purchase(199, @mastercard, @params)
|
82
|
-
assert_success response
|
83
|
-
assert response.test?
|
84
|
-
end
|
85
|
-
|
86
|
-
# Note the Datacash test server regularly times out on switch requests
|
87
|
-
def test_successful_purchase_with_solo_card
|
88
|
-
response = @gateway.purchase(@amount, @solo, @params)
|
89
|
-
assert_success response
|
90
|
-
assert response.test?
|
91
|
-
end
|
92
|
-
|
93
|
-
# this card number won't check the address details - testing extended
|
94
|
-
# policy
|
95
|
-
def test_successful_purchase_without_address_check2
|
96
|
-
@solo.number = '633499110000000003'
|
97
|
-
|
98
|
-
response = @gateway.purchase(@amount, @solo, @params)
|
99
|
-
assert_success response
|
100
|
-
assert response.test?
|
101
|
-
end
|
102
|
-
|
103
|
-
# Testing purchase with request to set up recurring payment account
|
104
|
-
def test_successful_purchase_without_account_set_up_and_repeat_payments
|
105
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
106
|
-
assert_success response
|
107
|
-
assert response.authorization.to_s.split(';')[2].blank?
|
108
|
-
assert response.test?
|
109
|
-
end
|
110
|
-
|
111
|
-
# Testing purchase with request to set up recurring payment account
|
112
|
-
def test_successful_purchase_with_account_set_up_and_repeat_payments
|
113
|
-
@params[:set_up_continuous_authority] = true
|
114
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
115
|
-
assert_success response
|
116
|
-
assert !response.authorization.to_s.split(';')[2].blank?
|
117
|
-
assert response.test?
|
118
|
-
|
119
|
-
#Make second payment on the continuous authorization that was set up in the first purchase
|
120
|
-
second_order_params = { :order_id => generate_unique_id }
|
121
|
-
purchase = @gateway.purchase(201, response.params['ca_reference'], second_order_params)
|
122
|
-
assert_success purchase
|
123
|
-
assert purchase.test?
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_successful_purchase_with_account_set_up_and_repeat_payments_with_visa_delta_card
|
127
|
-
@params[:set_up_continuous_authority] = true
|
128
|
-
response = @gateway.purchase(@amount, @visa_delta, @params)
|
129
|
-
assert_success response
|
130
|
-
assert !response.authorization.to_s.split(';')[2].blank?
|
131
|
-
assert response.test?
|
132
|
-
|
133
|
-
#Make second payment on the continuous authorization that was set up in the first purchase
|
134
|
-
second_order_params = { :order_id => generate_unique_id }
|
135
|
-
purchase = @gateway.purchase(201, response.params['ca_reference'], second_order_params)
|
136
|
-
assert_success purchase
|
137
|
-
assert purchase.test?
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_purchase_with_account_set_up_for_repeat_payments_fails_for_solo_card
|
141
|
-
@params[:set_up_continuous_authority] = true
|
142
|
-
response = @gateway.purchase(@amount, @solo, @params)
|
143
|
-
assert_equal '92', response.params['status'] # Error code for CA not supported
|
144
|
-
assert_equal 'CA Not Supported', response.message
|
145
|
-
assert response.test?
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_successful_authorization_and_capture_with_account_set_up_and_second_purchase
|
149
|
-
#Authorize first payment
|
150
|
-
@params[:set_up_continuous_authority] = true
|
151
|
-
first_authorization = @gateway.authorize(@amount, @mastercard, @params)
|
152
|
-
assert_success first_authorization
|
153
|
-
assert !first_authorization.authorization.to_s.split(';')[2].blank?
|
154
|
-
assert first_authorization.test?
|
155
|
-
|
156
|
-
#Capture first payment
|
157
|
-
capture = @gateway.capture(@amount, first_authorization.authorization, @params)
|
158
|
-
assert_success capture
|
159
|
-
assert capture.test?
|
160
|
-
|
161
|
-
#Collect second purchase
|
162
|
-
second_order_params = { :order_id => generate_unique_id }
|
163
|
-
purchase = @gateway.purchase(201, first_authorization.authorization, second_order_params)
|
164
|
-
assert_success purchase
|
165
|
-
assert purchase.test?
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_duplicate_order_id
|
169
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
170
|
-
assert_success response
|
171
|
-
|
172
|
-
duplicate_response = @gateway.purchase(@amount, @mastercard, @params)
|
173
|
-
assert_failure duplicate_response
|
174
|
-
assert_equal 'Duplicate reference', duplicate_response.message
|
175
|
-
assert duplicate_response.test?
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_invalid_verification_number
|
179
|
-
@mastercard.verification_value = 123
|
180
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
181
|
-
assert_failure response
|
182
|
-
assert_equal 'CV2AVS DECLINED', response.message
|
183
|
-
assert response.test?
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_invalid_expiry_month
|
187
|
-
@mastercard.month = 13
|
188
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
189
|
-
assert_failure response
|
190
|
-
assert_equal 'Expiry date invalid', response.message
|
191
|
-
assert response.test?
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_invalid_expiry_year
|
195
|
-
@mastercard.year = 1999
|
196
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
197
|
-
assert_failure response
|
198
|
-
assert_equal 'Card has already expired', response.message
|
199
|
-
assert response.test?
|
200
|
-
end
|
201
|
-
|
202
|
-
def test_declined_card
|
203
|
-
response = @gateway.purchase(@amount, @mastercard_declined, @params)
|
204
|
-
assert_failure response
|
205
|
-
assert_equal 'DECLINED', response.message
|
206
|
-
assert response.test?
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_successful_authorization_and_capture
|
210
|
-
authorization = @gateway.authorize(@amount, @mastercard, @params)
|
211
|
-
assert_success authorization
|
212
|
-
assert authorization.test?
|
213
|
-
|
214
|
-
capture = @gateway.capture(@amount, authorization.authorization, @params)
|
215
|
-
assert_success capture
|
216
|
-
assert capture.test?
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_unsuccessful_capture
|
220
|
-
response = @gateway.capture(@amount, ';1234', @params)
|
221
|
-
assert_failure response
|
222
|
-
assert_equal 'AUTHCODE field required', response.message
|
223
|
-
assert response.test?
|
224
|
-
end
|
225
|
-
|
226
|
-
def test_successful_authorization_and_void
|
227
|
-
authorization = @gateway.authorize(@amount, @mastercard, @params)
|
228
|
-
assert_success authorization
|
229
|
-
assert authorization.test?
|
230
|
-
|
231
|
-
void = @gateway.void(authorization.authorization, @params)
|
232
|
-
assert_success void
|
233
|
-
assert void.test?
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_successfully_purchase_and_void
|
237
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
238
|
-
assert_success purchase
|
239
|
-
assert purchase.test?
|
240
|
-
|
241
|
-
void = @gateway.void(purchase.authorization, @params)
|
242
|
-
assert_success void
|
243
|
-
assert void.test?
|
244
|
-
end
|
245
|
-
|
246
|
-
|
247
|
-
def test_successful_refund
|
248
|
-
response = @gateway.credit(@amount, @mastercard, @params)
|
249
|
-
assert_success response
|
250
|
-
assert !response.params['datacash_reference'].blank?
|
251
|
-
assert !response.params['merchantreference'].blank?
|
252
|
-
|
253
|
-
assert response.test?
|
254
|
-
end
|
255
|
-
|
256
|
-
def test_successful_transaction_refund
|
257
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
258
|
-
assert_success purchase
|
259
|
-
assert purchase.test?
|
260
|
-
|
261
|
-
refund = @gateway.credit(@amount, purchase.params['datacash_reference'])
|
262
|
-
assert_success refund
|
263
|
-
assert !refund.params['datacash_reference'].blank?
|
264
|
-
assert !refund.params['merchantreference'].blank?
|
265
|
-
|
266
|
-
assert refund.test?
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_successful_transaction_refund_with_money_set_to_nil
|
270
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
271
|
-
assert_success purchase
|
272
|
-
assert purchase.test?
|
273
|
-
|
274
|
-
refund = @gateway.credit(nil, purchase.params['datacash_reference'])
|
275
|
-
assert_success refund
|
276
|
-
assert refund.test?
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_successful_transaction_refund_in_two_stages
|
280
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
281
|
-
assert_success purchase
|
282
|
-
assert purchase.test?
|
283
|
-
|
284
|
-
first_partial_refund = @gateway.credit(100, purchase.params['datacash_reference'])
|
285
|
-
assert_success first_partial_refund
|
286
|
-
assert first_partial_refund.test?
|
287
|
-
|
288
|
-
second_partial_refund = @gateway.credit(98, purchase.params['datacash_reference'])
|
289
|
-
assert_success second_partial_refund
|
290
|
-
assert second_partial_refund.test?
|
291
|
-
end
|
292
|
-
|
293
|
-
def test_successful_partial_transaction_refund
|
294
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
295
|
-
assert_success purchase
|
296
|
-
assert purchase.test?
|
297
|
-
|
298
|
-
partial_refund = @gateway.credit(100, purchase.params['datacash_reference'])
|
299
|
-
assert_success partial_refund
|
300
|
-
assert partial_refund.test?
|
301
|
-
end
|
302
|
-
|
303
|
-
def test_fail_to_refund_too_much
|
304
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
305
|
-
assert_success purchase
|
306
|
-
assert purchase.test?
|
307
|
-
|
308
|
-
refund_too_much = @gateway.credit(500, purchase.params['datacash_reference'])
|
309
|
-
assert_failure refund_too_much
|
310
|
-
assert_equal 'Refund amount > orig 1.98', refund_too_much.message
|
311
|
-
assert refund_too_much.test?
|
312
|
-
end
|
313
|
-
|
314
|
-
def test_fail_to_refund_with_declined_purchase_reference
|
315
|
-
declined_purchase = @gateway.purchase(@amount, @mastercard_declined, @params)
|
316
|
-
assert_failure declined_purchase
|
317
|
-
assert declined_purchase.test?
|
318
|
-
|
319
|
-
refund = @gateway.credit(@amount, declined_purchase.params['datacash_reference'])
|
320
|
-
assert_failure refund
|
321
|
-
assert_equal 'Cannot refund transaction', refund.message
|
322
|
-
assert refund.test?
|
323
|
-
end
|
324
|
-
|
325
|
-
def test_fail_to_refund_purchase_which_is_already_refunded
|
326
|
-
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
327
|
-
assert_success purchase
|
328
|
-
assert purchase.test?
|
329
|
-
|
330
|
-
first_refund = @gateway.credit(nil, purchase.params['datacash_reference'])
|
331
|
-
assert_success first_refund
|
332
|
-
assert first_refund.test?
|
333
|
-
|
334
|
-
second_refund = @gateway.credit(@amount, purchase.params['datacash_reference'])
|
335
|
-
assert_failure second_refund
|
336
|
-
assert_equal '1.98 > remaining funds 0.00', second_refund.message
|
337
|
-
assert second_refund.test?
|
338
|
-
end
|
339
|
-
|
340
|
-
# Check short merchant references are reformatted
|
341
|
-
def test_merchant_reference_that_is_too_short
|
342
|
-
@params[:order_id] = @params[:order_id].first(5)
|
343
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
344
|
-
assert_success response
|
345
|
-
assert response.test?
|
346
|
-
end
|
347
|
-
|
348
|
-
# Check long merchant references are reformatted
|
349
|
-
def test_merchant_reference_that_is_too_long
|
350
|
-
@params[:order_id] = "#{@params[:order_id]}1234356"
|
351
|
-
response = @gateway.purchase(@amount, @mastercard, @params)
|
352
|
-
assert_success response
|
353
|
-
assert response.test?
|
354
|
-
end
|
355
|
-
|
356
|
-
end
|