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,130 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteCyberSourceTest < Test::Unit::TestCase
|
|
4
|
+
# Amount in cents
|
|
5
|
+
AMOUNT = 100
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
Base.gateway_mode = :test
|
|
9
|
+
|
|
10
|
+
@gateway = CyberSourceGateway.new(fixtures(:cyber_source))
|
|
11
|
+
|
|
12
|
+
@creditcard = credit_card('4111111111111111', :type => 'visa')
|
|
13
|
+
@declined_card = credit_card('801111111111111', :type => 'visa')
|
|
14
|
+
|
|
15
|
+
@options = {
|
|
16
|
+
:address => {
|
|
17
|
+
:address1 => '1234 My Street',
|
|
18
|
+
:address2 => 'Apt 1',
|
|
19
|
+
:company => 'Widgets Inc',
|
|
20
|
+
:city => 'Ottawa',
|
|
21
|
+
:state => 'ON',
|
|
22
|
+
:zip => 'K1C2N6',
|
|
23
|
+
:country => 'Canada',
|
|
24
|
+
:phone => '(555)555-5555'
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
:order_id => generate_order_id,
|
|
28
|
+
:line_items => [
|
|
29
|
+
{
|
|
30
|
+
:declared_value => 100,
|
|
31
|
+
:quantity => 2,
|
|
32
|
+
:code => 'default',
|
|
33
|
+
:description => 'Giant Walrus',
|
|
34
|
+
:sku => 'WA323232323232323'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
:declared_value => 100,
|
|
38
|
+
:quantity => 2,
|
|
39
|
+
:description => 'Marble Snowcone',
|
|
40
|
+
:sku => 'FAKE1232132113123'
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
:currency => 'USD',
|
|
44
|
+
:email => 'someguy1232@fakeemail.net',
|
|
45
|
+
:ignore_avs => 'true',
|
|
46
|
+
:ignore_cvv => 'true'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_successful_authorization
|
|
52
|
+
assert response = @gateway.authorize(AMOUNT, @creditcard, @options)
|
|
53
|
+
assert_equal 'Successful transaction', response.message
|
|
54
|
+
assert_success response
|
|
55
|
+
assert response.test?
|
|
56
|
+
assert !response.authorization.blank?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_unsuccessful_authorization
|
|
60
|
+
assert response = @gateway.authorize(AMOUNT, @declined_card, @options)
|
|
61
|
+
assert response.test?
|
|
62
|
+
assert_equal 'Invalid account number', response.message
|
|
63
|
+
assert_equal false, response.success?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_successful_tax_calculation
|
|
67
|
+
assert response = @gateway.calculate_tax(@creditcard, @options)
|
|
68
|
+
assert_equal 'Successful transaction', response.message
|
|
69
|
+
assert response.params['totalTaxAmount']
|
|
70
|
+
assert_not_equal "0", response.params['totalTaxAmount']
|
|
71
|
+
assert_success response
|
|
72
|
+
assert response.test?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_successful_tax_calculation_with_nexus
|
|
76
|
+
@gateway.options = @gateway.options.merge(:nexus => 'WI')
|
|
77
|
+
assert response = @gateway.calculate_tax(@creditcard, @options)
|
|
78
|
+
assert_equal 'Successful transaction', response.message
|
|
79
|
+
assert response.params['totalTaxAmount']
|
|
80
|
+
assert_equal "0", response.params['totalTaxAmount']
|
|
81
|
+
assert_success response
|
|
82
|
+
assert response.test?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_successful_purchase
|
|
86
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
|
|
87
|
+
assert_equal 'Successful transaction', response.message
|
|
88
|
+
assert_success response
|
|
89
|
+
assert response.test?
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_unsuccessful_purchase
|
|
93
|
+
assert response = @gateway.purchase(AMOUNT, @declined_card, @options)
|
|
94
|
+
assert_equal 'Invalid account number', response.message
|
|
95
|
+
assert_failure response
|
|
96
|
+
assert response.test?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_authorize_and_capture
|
|
100
|
+
assert auth = @gateway.authorize(AMOUNT, @creditcard, @options)
|
|
101
|
+
assert_success auth
|
|
102
|
+
assert_equal 'Successful transaction', auth.message
|
|
103
|
+
|
|
104
|
+
assert capture = @gateway.capture(AMOUNT, auth.authorization)
|
|
105
|
+
assert_success capture
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_good_authorize_and_bad_capture
|
|
109
|
+
assert auth = @gateway.authorize(AMOUNT, @creditcard, @options)
|
|
110
|
+
assert_success auth
|
|
111
|
+
assert_equal 'Successful transaction', auth.message
|
|
112
|
+
|
|
113
|
+
assert capture = @gateway.capture(AMOUNT + 10, auth.authorization, @options)
|
|
114
|
+
assert_failure capture
|
|
115
|
+
assert_equal "One or more fields contains invalid data", capture.message
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def test_failed_capture_bad_auth_info
|
|
119
|
+
assert auth = @gateway.authorize(AMOUNT, @creditcard, @options)
|
|
120
|
+
assert capture = @gateway.capture(AMOUNT, "a;b;c", @options)
|
|
121
|
+
assert_failure capture
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_invalid_login
|
|
125
|
+
gateway = CyberSourceGateway.new( :login => '', :password => '' )
|
|
126
|
+
assert response = gateway.purchase(AMOUNT, @creditcard, @options)
|
|
127
|
+
assert_equal "wsse:InvalidSecurity: \nSecurity Data : illegal null input\n", response.message
|
|
128
|
+
assert_failure response
|
|
129
|
+
end
|
|
130
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Author:: MoneySpyder, www.moneyspyder.co.uk
|
|
2
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
3
|
+
|
|
4
|
+
class RemoteDataCashTest < Test::Unit::TestCase
|
|
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 => 2010,
|
|
13
|
+
:first_name => 'Mark',
|
|
14
|
+
:last_name => 'McBride',
|
|
15
|
+
:type => :master,
|
|
16
|
+
:verification_value => '547'
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
@solo = CreditCard.new(
|
|
20
|
+
:first_name => 'Cody',
|
|
21
|
+
:last_name => 'Fauser',
|
|
22
|
+
:number => '633499100000000004',
|
|
23
|
+
:month => 3,
|
|
24
|
+
:year => 2010,
|
|
25
|
+
:type => :solo,
|
|
26
|
+
:issue_number => 5,
|
|
27
|
+
:start_month => 12,
|
|
28
|
+
:start_year => 2006,
|
|
29
|
+
:verification_value => 444
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
@address = {
|
|
33
|
+
:name => 'Mark McBride',
|
|
34
|
+
:address1 => 'Flat 12/3',
|
|
35
|
+
:address2 => '45 Main Road',
|
|
36
|
+
:city => 'London',
|
|
37
|
+
:state => 'None',
|
|
38
|
+
:country => 'GBR',
|
|
39
|
+
:zip => 'A987AA',
|
|
40
|
+
:phone => '(555)555-5555'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@params = {
|
|
44
|
+
:order_id => generate_order_id,
|
|
45
|
+
:billing_address => @address
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Testing that we can successfully make a purchase in a one step
|
|
50
|
+
# operation
|
|
51
|
+
def test_successful_purchase
|
|
52
|
+
response = @gateway.purchase(198, @mastercard, @params)
|
|
53
|
+
assert_success response
|
|
54
|
+
assert response.test?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#the amount is changed to £1.99 - the DC test server won't check the
|
|
58
|
+
#address details - this is more a check on the passed ExtendedPolicy
|
|
59
|
+
def test_successful_purchase_without_address_check
|
|
60
|
+
response = @gateway.purchase(199, @mastercard, @params)
|
|
61
|
+
assert_success response
|
|
62
|
+
assert response.test?
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_successful_purchase_with_solo_card
|
|
66
|
+
response = @gateway.purchase(198, @solo, @params)
|
|
67
|
+
assert_success response
|
|
68
|
+
assert response.test?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# this card number won't check the address details - testing extended
|
|
72
|
+
# policy
|
|
73
|
+
def test_successful_purchase_without_address_check2
|
|
74
|
+
@solo.number = '633499110000000003'
|
|
75
|
+
|
|
76
|
+
response = @gateway.purchase(198, @solo, @params)
|
|
77
|
+
assert_success response
|
|
78
|
+
assert response.test?
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_invalid_verification_number
|
|
82
|
+
@mastercard.verification_value = 123
|
|
83
|
+
response = @gateway.purchase(198, @mastercard, @params)
|
|
84
|
+
assert_failure response
|
|
85
|
+
assert response.test?
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def test_invalid_expiry_month
|
|
89
|
+
@mastercard.month = 13
|
|
90
|
+
response = @gateway.purchase(198, @mastercard, @params)
|
|
91
|
+
assert_failure response
|
|
92
|
+
assert response.test?
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_invalid_expiry_year
|
|
96
|
+
@mastercard.year = 1999
|
|
97
|
+
response = @gateway.purchase(198, @mastercard, @params)
|
|
98
|
+
assert_failure response
|
|
99
|
+
assert response.test?
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_successful_authorization_and_capture
|
|
103
|
+
amount = 198
|
|
104
|
+
|
|
105
|
+
authorization = @gateway.authorize(amount, @mastercard, @params)
|
|
106
|
+
assert_success authorization
|
|
107
|
+
assert authorization.test?
|
|
108
|
+
|
|
109
|
+
capture = @gateway.capture(amount, authorization.authorization, @params)
|
|
110
|
+
assert_success capture
|
|
111
|
+
assert capture.test?
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_unsuccessful_capture
|
|
115
|
+
response = @gateway.capture(198, '1234', @params)
|
|
116
|
+
assert_failure response
|
|
117
|
+
assert response.test?
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_successful_authorization_and_void
|
|
121
|
+
amount = 198
|
|
122
|
+
|
|
123
|
+
authorization = @gateway.authorize(amount, @mastercard, @params)
|
|
124
|
+
assert_success authorization
|
|
125
|
+
assert authorization.test?
|
|
126
|
+
|
|
127
|
+
void = @gateway.void(authorization.authorization, @params)
|
|
128
|
+
assert_success void
|
|
129
|
+
assert void.test?
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_successfuly_purchase_and_void
|
|
133
|
+
purchase = @gateway.purchase(198, @mastercard, @params)
|
|
134
|
+
assert_success purchase
|
|
135
|
+
assert purchase.test?
|
|
136
|
+
|
|
137
|
+
void = @gateway.void(purchase.authorization, @params)
|
|
138
|
+
assert_success void
|
|
139
|
+
assert void.test?
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_merchant_reference_that_is_too_short
|
|
143
|
+
@params[:order_id] = rand(10000)
|
|
144
|
+
response = @gateway.purchase(198, @mastercard, @params)
|
|
145
|
+
assert_success response
|
|
146
|
+
assert response.test?
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_merchant_reference_containing_invalid_characters
|
|
150
|
+
@params[:order_id] = "##{rand(1000) + 1000}.1"
|
|
151
|
+
response = @gateway.purchase(198, @mastercard, @params)
|
|
152
|
+
assert_success response
|
|
153
|
+
assert response.test?
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RemoteEfsnetTest < Test::Unit::TestCase
|
|
4
|
+
AMOUNT = 100
|
|
5
|
+
DECLINED_AMOUNT = 156
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
Base.gateway_mode = :test
|
|
9
|
+
|
|
10
|
+
@gateway = EfsnetGateway.new(fixtures(:efsnet))
|
|
11
|
+
|
|
12
|
+
@creditcard = credit_card('4000100011112224')
|
|
13
|
+
|
|
14
|
+
@options = { :order_id => 0,
|
|
15
|
+
:address => { :address1 => '1234 Shady Brook Lane',
|
|
16
|
+
:zip => '90210'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_successful_purchase
|
|
22
|
+
@options[:order_id] += 1
|
|
23
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
|
|
24
|
+
assert_equal 'Approved', response.message
|
|
25
|
+
assert_success response
|
|
26
|
+
assert response.test?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_successful_force
|
|
30
|
+
@options[:order_id] += 1
|
|
31
|
+
assert response = @gateway.force(AMOUNT, '123456', @creditcard, @options)
|
|
32
|
+
assert_equal 'Approved', response.message
|
|
33
|
+
assert_success response
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_successful_voice_authorize
|
|
37
|
+
@options[:order_id] += 1
|
|
38
|
+
assert response = @gateway.voice_authorize(AMOUNT, '123456', @creditcard, @options)
|
|
39
|
+
assert_equal 'Accepted', response.message
|
|
40
|
+
assert_success response
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_unsuccessful_purchase
|
|
44
|
+
@options[:order_id] += 1
|
|
45
|
+
assert response = @gateway.purchase(DECLINED_AMOUNT, @creditcard, @options)
|
|
46
|
+
assert_equal 'Declined', response.message
|
|
47
|
+
assert_failure response
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_authorize_and_capture
|
|
51
|
+
@options[:order_id] += 1
|
|
52
|
+
|
|
53
|
+
amount = AMOUNT
|
|
54
|
+
assert auth = @gateway.authorize(amount, @creditcard, @options)
|
|
55
|
+
assert_success auth
|
|
56
|
+
assert_equal 'Approved', auth.message
|
|
57
|
+
assert auth.authorization
|
|
58
|
+
|
|
59
|
+
@options[:order_id] += 1
|
|
60
|
+
assert capture = @gateway.capture(amount, auth.authorization, @options)
|
|
61
|
+
assert_success capture
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_purchase_and_void
|
|
65
|
+
@options[:order_id] += 1
|
|
66
|
+
amount = AMOUNT
|
|
67
|
+
assert purchase = @gateway.purchase(amount, @creditcard, @options)
|
|
68
|
+
assert_success purchase
|
|
69
|
+
assert_equal 'Approved', purchase.message
|
|
70
|
+
assert purchase.authorization
|
|
71
|
+
@options[:order_id] += 1
|
|
72
|
+
assert void = @gateway.void(purchase.authorization, @options)
|
|
73
|
+
assert_success void
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_failed_capture
|
|
77
|
+
@options[:order_id] += 1
|
|
78
|
+
assert response = @gateway.capture(AMOUNT, '1;1', @options)
|
|
79
|
+
assert_failure response
|
|
80
|
+
assert_equal 'Bad original transaction', response.message
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_invalid_login
|
|
84
|
+
@options[:order_id] += 1
|
|
85
|
+
gateway = EfsnetGateway.new(
|
|
86
|
+
:login => '',
|
|
87
|
+
:password => ''
|
|
88
|
+
)
|
|
89
|
+
assert response = gateway.purchase(AMOUNT, @creditcard, @options)
|
|
90
|
+
assert_equal 'Invalid credentials', response.message
|
|
91
|
+
assert_failure response
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class EwayTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
@gateway = EwayGateway.new(fixtures(:eway))
|
|
7
|
+
|
|
8
|
+
@creditcard_success = credit_card('4444333322221111')
|
|
9
|
+
|
|
10
|
+
@creditcard_fail = credit_card('1234567812345678',
|
|
11
|
+
:month => Time.now.month,
|
|
12
|
+
:year => Time.now.year
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
@params = {
|
|
16
|
+
:order_id => '1230123',
|
|
17
|
+
:email => 'bob@testbob.com',
|
|
18
|
+
:address => { :address1 => '47 Bobway, Bobville, WA, Australia',
|
|
19
|
+
:zip => '2000'
|
|
20
|
+
} ,
|
|
21
|
+
:description => 'purchased items'
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_invalid_amount
|
|
26
|
+
assert response = @gateway.purchase(101, @creditcard_success, @params)
|
|
27
|
+
assert_failure response
|
|
28
|
+
assert response.test?
|
|
29
|
+
assert_equal EwayGateway::MESSAGES["01"], response.message
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_purchase_success_with_verification_value
|
|
33
|
+
assert response = @gateway.purchase(100, @creditcard_success, @params)
|
|
34
|
+
assert_equal '123456', response.authorization
|
|
35
|
+
assert_success response
|
|
36
|
+
assert response.test?
|
|
37
|
+
assert_equal EwayGateway::MESSAGES["00"], response.message
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_invalid_expiration_date
|
|
41
|
+
@creditcard_success.year = 2005
|
|
42
|
+
assert response = @gateway.purchase(100, @creditcard_success, @params)
|
|
43
|
+
assert_failure response
|
|
44
|
+
assert response.test?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_purchase_with_invalid_verification_value
|
|
48
|
+
@creditcard_success.verification_value = 'AAA'
|
|
49
|
+
assert response = @gateway.purchase(100, @creditcard_success, @params)
|
|
50
|
+
assert_nil response.authorization
|
|
51
|
+
assert_failure response
|
|
52
|
+
assert response.test?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_purchase_success_without_verification_value
|
|
56
|
+
@creditcard_success.verification_value = nil
|
|
57
|
+
|
|
58
|
+
assert response = @gateway.purchase(100, @creditcard_success, @params)
|
|
59
|
+
assert_equal '123456', response.authorization
|
|
60
|
+
assert_success response
|
|
61
|
+
assert response.test?
|
|
62
|
+
assert_equal EwayGateway::MESSAGES["00"], response.message
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_purchase_error
|
|
66
|
+
assert response = @gateway.purchase(100, @creditcard_fail, @params)
|
|
67
|
+
assert_nil response.authorization
|
|
68
|
+
assert_equal false, response.success?
|
|
69
|
+
assert response.test?
|
|
70
|
+
end
|
|
71
|
+
end
|