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,23 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class DataCashTest < Test::Unit::TestCase
|
|
4
|
+
# 100 Cents
|
|
5
|
+
AMOUNT = 100
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@gateway = DataCashGateway.new(
|
|
9
|
+
:login => 'LOGIN',
|
|
10
|
+
:password => 'PASSWORD'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@creditcard = credit_card('4242424242424242')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_supported_countries
|
|
17
|
+
assert_equal ['GB'], DataCashGateway.supported_countries
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_supported_card_types
|
|
21
|
+
assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class EfsnetTest < Test::Unit::TestCase
|
|
4
|
+
AMOUNT = 100
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@gateway = EfsnetGateway.new(
|
|
8
|
+
:login => 'LOGIN',
|
|
9
|
+
:password => 'PASSWORD'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@creditcard = credit_card('4242424242424242')
|
|
13
|
+
|
|
14
|
+
@address = { :address1 => '1234 My Street',
|
|
15
|
+
:address2 => 'Apt 1',
|
|
16
|
+
:company => 'Widgets Inc',
|
|
17
|
+
:city => 'Ottawa',
|
|
18
|
+
:state => 'ON',
|
|
19
|
+
:zip => 'K1C2N6',
|
|
20
|
+
:country => 'Canada',
|
|
21
|
+
:phone => '(555)555-5555'
|
|
22
|
+
}
|
|
23
|
+
@options = {:order_id => 1}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_successful_request
|
|
27
|
+
@creditcard.number = 1
|
|
28
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
|
|
29
|
+
assert_success response
|
|
30
|
+
assert_equal '5555', response.authorization
|
|
31
|
+
assert response.test?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_unsuccessful_request
|
|
35
|
+
@creditcard.number = 2
|
|
36
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
|
|
37
|
+
assert_failure response
|
|
38
|
+
assert response.test?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_request_error
|
|
42
|
+
@creditcard.number = 3
|
|
43
|
+
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, @options) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_authorize_is_valid_xml
|
|
47
|
+
params = {
|
|
48
|
+
:order_id => "order1",
|
|
49
|
+
:transaction_amount => "1.01",
|
|
50
|
+
:account_number => "4242424242424242",
|
|
51
|
+
:expiration_month => "12",
|
|
52
|
+
:expiration_year => "2029",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
assert data = @gateway.send(:post_data, :credit_card_authorize, params)
|
|
56
|
+
assert REXML::Document.new(data)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_settle_is_valid_xml
|
|
60
|
+
params = {
|
|
61
|
+
:order_id => "order1",
|
|
62
|
+
:transaction_amount => "1.01",
|
|
63
|
+
:original_transaction_amount => "1.01",
|
|
64
|
+
:original_transaction_id => "1",
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
assert data = @gateway.send(:post_data, :credit_card_settle, params)
|
|
68
|
+
assert REXML::Document.new(data)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class EwayTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = EwayGateway.new(
|
|
6
|
+
:login => '87654321'
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
@creditcard = credit_card('4646464646464646')
|
|
10
|
+
|
|
11
|
+
@test_params_success = {
|
|
12
|
+
:order_id => '1230123',
|
|
13
|
+
:email => 'bob@testbob.com',
|
|
14
|
+
:address => {
|
|
15
|
+
:address1 => '1234 First St.',
|
|
16
|
+
:address2 => 'Apt. 1',
|
|
17
|
+
:city => 'Melbourne',
|
|
18
|
+
:state => 'ACT',
|
|
19
|
+
:country => 'AU',
|
|
20
|
+
:zip => '12345'
|
|
21
|
+
},
|
|
22
|
+
:description => 'purchased items'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@xml_test_parameters = {
|
|
26
|
+
:CustomerID => @test_params_success[:login],
|
|
27
|
+
:CustomerInvoiceRef => @test_params_success[:order_id],
|
|
28
|
+
:TotalAmount => 100,
|
|
29
|
+
:CardNumber => @creditcard.number,
|
|
30
|
+
:CardExpiryMonth => sprintf("%.2i", @creditcard.month),
|
|
31
|
+
:CardExpiryYear => sprintf("%.4i", @creditcard.year)[-2..-1],
|
|
32
|
+
:CustomerFirstName => @creditcard.first_name,
|
|
33
|
+
:CustomerLastName => @creditcard.last_name,
|
|
34
|
+
:CustomerEmail => @test_params_success[:email],
|
|
35
|
+
:CustomerAddress => @test_params_success[:address][:address1],
|
|
36
|
+
:CustomerPostcode => @test_params_success[:address][:zip],
|
|
37
|
+
:CustomerInvoiceDescription => @test_params_success[:description],
|
|
38
|
+
:CardHoldersName => @creditcard.name,
|
|
39
|
+
:TrxnNumber => @test_params_success[:order_id],
|
|
40
|
+
:Option1 => '',
|
|
41
|
+
:Option2 => '',
|
|
42
|
+
:Option3 => ''
|
|
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, @test_params_success)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_amount_style
|
|
55
|
+
assert_equal '1034', @gateway.send(:amount, 1034)
|
|
56
|
+
|
|
57
|
+
assert_raise(ArgumentError) do
|
|
58
|
+
@gateway.send(:amount, '10.34')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_purchase_is_valid_xml
|
|
63
|
+
assert data = @gateway.send(:post_data, @xml_test_parameters)
|
|
64
|
+
assert REXML::Document.new(data)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_ensure_does_not_respond_to_authorize
|
|
68
|
+
assert !@gateway.respond_to?(:authorize)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_ensure_does_not_respond_to_capture
|
|
72
|
+
assert !@gateway.respond_to?(:capture)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_test_url_without_cvn
|
|
76
|
+
assert_equal EwayGateway::TEST_URL, @gateway.send(:gateway_url, false, true)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_test_url_with_cvn
|
|
80
|
+
assert_equal EwayGateway::TEST_CVN_URL, @gateway.send(:gateway_url, true, true)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_live_url_without_cvn
|
|
84
|
+
assert_equal EwayGateway::LIVE_URL, @gateway.send(:gateway_url, false, false)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_live_url_with_cvn
|
|
88
|
+
assert_equal EwayGateway::LIVE_CVN_URL, @gateway.send(:gateway_url, true, false)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_add_address
|
|
92
|
+
post = {}
|
|
93
|
+
@gateway.send(:add_address, post, @test_params_success)
|
|
94
|
+
assert_equal '1234 First St., Apt. 1, Melbourne, ACT, AU', post[:CustomerAddress]
|
|
95
|
+
assert_equal @test_params_success[:address][:zip], post[:CustomerPostcode]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
def xml_purchase_fixture
|
|
101
|
+
%q{<ewaygateway><ewayCustomerID>87654321</ewayCustomerID><ewayOption3></ewayOption3><ewayCustomerFirstName>Longbob</ewayCustomerFirstName><ewayCustomerAddress>47 Bobway, Bobville, WA, Australia</ewayCustomerAddress><ewayCustomerInvoiceRef>1230123</ewayCustomerInvoiceRef><ewayCardHoldersName>Longbob Longsen</ewayCardHoldersName><ewayTotalAmount>100</ewayTotalAmount><ewayTrxnNumber>1230123</ewayTrxnNumber><ewayCustomerLastName>Longsen</ewayCustomerLastName><ewayCustomerPostcode>2000</ewayCustomerPostcode><ewayCardNumber>4646464646464646</ewayCardNumber><ewayOption1></ewayOption1><ewayCardExpiryMonth>08</ewayCardExpiryMonth><ewayOption2></ewayOption2><ewayCustomerEmail>bob@testbob.com</ewayCustomerEmail><ewayCustomerInvoiceDescription>purchased items</ewayCustomerInvoiceDescription><ewayCardExpiryYear>07</ewayCardExpiryYear></ewaygateway>}
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class ExactTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = ExactGateway.new( :login => "A00427-01",
|
|
6
|
+
:password => "testus" )
|
|
7
|
+
|
|
8
|
+
@credit_card = credit_card("4111111111111111")
|
|
9
|
+
|
|
10
|
+
@options = { :address => { :address1 => "1234 Testing Ave.",
|
|
11
|
+
:zip => "55555" } }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_successful_request
|
|
15
|
+
@credit_card.number = "1"
|
|
16
|
+
assert response = @gateway.purchase(100, @credit_card, {})
|
|
17
|
+
assert_success response
|
|
18
|
+
assert_equal '5555', response.authorization
|
|
19
|
+
assert response.test?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_unsuccessful_request
|
|
23
|
+
@credit_card.number = "2"
|
|
24
|
+
assert response = @gateway.purchase(100, @credit_card, {})
|
|
25
|
+
assert_failure response
|
|
26
|
+
assert response.test?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_request_error
|
|
30
|
+
@credit_card.number = "3"
|
|
31
|
+
assert_raise(Error){ @gateway.purchase(100, @credit_card, {}) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_expdate
|
|
35
|
+
assert_equal( "%02d%s" % [ @credit_card.month,
|
|
36
|
+
@credit_card.year.to_s[-2..-1] ],
|
|
37
|
+
@gateway.send(:expdate, @credit_card) )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_successful_purchase
|
|
41
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
42
|
+
assert response = @gateway.purchase(100, @credit_card, {})
|
|
43
|
+
assert_success response
|
|
44
|
+
assert_equal 'ET0426;80928103', response.authorization
|
|
45
|
+
assert response.test?
|
|
46
|
+
assert_equal 'Transaction Normal - VER UNAVAILABLE', response.message
|
|
47
|
+
|
|
48
|
+
ExactGateway::SENSITIVE_FIELDS.each{ |f| assert !response.params.has_key?(f.to_s) }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_soap_fault
|
|
52
|
+
@gateway.expects(:ssl_post).returns(soap_fault_response)
|
|
53
|
+
assert response = @gateway.purchase(100, @credit_card, {})
|
|
54
|
+
assert_failure response
|
|
55
|
+
assert response.test?
|
|
56
|
+
assert_equal 'Unable to handle request without a valid action parameter. Please supply a valid soap action.', response.message
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_supported_countries
|
|
60
|
+
assert_equal ['CA', 'US'], ExactGateway.supported_countries
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_supported_card_types
|
|
64
|
+
assert_equal [:visa, :master, :american_express, :jcb, :discover], ExactGateway.supported_cardtypes
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
def successful_purchase_response
|
|
69
|
+
<<-RESPONSE
|
|
70
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">1</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4111111111111111</Card_Number><Verification_Str2 xsi:type="xsd:string">123</Verification_Str2><Transaction_Tag xsi:type="xsd:string">80928103</Transaction_Tag><Authorization_Num xsi:type="xsd:string">ET0426</Authorization_Num><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Active Merchant</CardHoldersName><CVD_Presence_Ind xsi:type="xsd:string">0</CVD_Presence_Ind><ZipCode xsi:type="xsd:string">55555</ZipCode><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by:
|
|
71
|
+
E-xact Transaction Gateway :- Version 8.4.0 B19
|
|
72
|
+
Copyright 2006
|
|
73
|
+
{34:2652}</LogonMessage><Error_Number xsi:type="xsd:string">0</Error_Number><Error_Description xsi:type="xsd:string" /><Transaction_Error xsi:type="xsd:boolean">false</Transaction_Error><Transaction_Approved xsi:type="xsd:boolean">true</Transaction_Approved><EXact_Resp_Code xsi:type="xsd:string">00</EXact_Resp_Code><EXact_Message xsi:type="xsd:string">Transaction Normal</EXact_Message><Bank_Resp_Code xsi:type="xsd:string">00</Bank_Resp_Code><Bank_Message xsi:type="xsd:string">VER UNAVAILABLE </Bank_Message><SequenceNo xsi:type="xsd:string">431</SequenceNo><AVS xsi:type="xsd:string">U</AVS><Retrieval_Ref_No xsi:type="xsd:string">200703280426</Retrieval_Ref_No><MerchantName xsi:type="xsd:string">E-xact ConnectionShop</MerchantName><MerchantAddress xsi:type="xsd:string">Suite 304 - 134 Abbott Street</MerchantAddress><MerchantCity xsi:type="xsd:string">Vancouver</MerchantCity><MerchantProvince xsi:type="xsd:string">BC</MerchantProvince><MerchantCountry xsi:type="xsd:string">Canada</MerchantCountry><MerchantPostal xsi:type="xsd:string">V6B 2K4</MerchantPostal><MerchantURL xsi:type="xsd:string">www.e-xact.com</MerchantURL><CTR xsi:type="xsd:string">========== TRANSACTION RECORD =========
|
|
74
|
+
|
|
75
|
+
E-xact ConnectionShop
|
|
76
|
+
Suite 304 - 134 Abbott Street
|
|
77
|
+
Vancouver, BC V6B 2K4
|
|
78
|
+
www.e-xact.com
|
|
79
|
+
|
|
80
|
+
TYPE: Purchase
|
|
81
|
+
|
|
82
|
+
ACCT: Visa $1.00 USD
|
|
83
|
+
|
|
84
|
+
CARD NUMBER : ############1111
|
|
85
|
+
TRANS. REF. :
|
|
86
|
+
CARD HOLDER : Active Merchant
|
|
87
|
+
EXPIRY DATE : xx/xx
|
|
88
|
+
DATE/TIME : 28 Mar 07 12:04:26
|
|
89
|
+
REFERENCE # : 5999 431 M
|
|
90
|
+
AUTHOR.# : ET0426
|
|
91
|
+
|
|
92
|
+
Approved - Thank You 00
|
|
93
|
+
|
|
94
|
+
SIGNATURE
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
_______________________________________
|
|
99
|
+
|
|
100
|
+
</CTR></types:TransactionResult></soap:Body></soap:Envelope>
|
|
101
|
+
RESPONSE
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def soap_fault_response
|
|
105
|
+
<<-RESPONSE
|
|
106
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
107
|
+
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
|
|
108
|
+
<soap:Body>
|
|
109
|
+
<soap:Fault>
|
|
110
|
+
<faultcode>soap:Client</faultcode>
|
|
111
|
+
<faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring>
|
|
112
|
+
<detail/>
|
|
113
|
+
</soap:Fault>
|
|
114
|
+
</soap:Body>
|
|
115
|
+
</soap:Envelope>
|
|
116
|
+
RESPONSE
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class Gateway < Test::Unit::TestCase
|
|
4
|
+
def test_should_detect_if_a_card_is_supported
|
|
5
|
+
Gateway.supported_cardtypes = [:visa, :bogus]
|
|
6
|
+
assert [:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) }
|
|
7
|
+
|
|
8
|
+
Gateway.supported_cardtypes = []
|
|
9
|
+
assert_false [:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_should_gateway_uses_ssl_strict_checking_by_default
|
|
13
|
+
assert Gateway.ssl_strict
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_should_be_able_to_look_for_test_mode
|
|
17
|
+
Base.gateway_mode = :test
|
|
18
|
+
assert Gateway.new.test?
|
|
19
|
+
|
|
20
|
+
Base.gateway_mode = :production
|
|
21
|
+
assert_false Gateway.new.test?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class LinkpointResponseTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = LinkpointGateway.new(
|
|
8
|
+
:login => 123123,
|
|
9
|
+
:pem => 'PEM'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@creditcard = credit_card('4111111111111111')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def teardown
|
|
16
|
+
Base.gateway_mode = :test
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_credit_card_formatting
|
|
20
|
+
assert_equal '04', @gateway.send(:format_creditcard_expiry_year, 2004)
|
|
21
|
+
assert_equal '04', @gateway.send(:format_creditcard_expiry_year, '2004')
|
|
22
|
+
assert_equal '04', @gateway.send(:format_creditcard_expiry_year, 4)
|
|
23
|
+
assert_equal '04', @gateway.send(:format_creditcard_expiry_year, '04')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_authorize
|
|
27
|
+
@creditcard.number = '1'
|
|
28
|
+
|
|
29
|
+
assert response = @gateway.authorize(2400, @creditcard, :order_id => 1000,
|
|
30
|
+
:address1 => '1313 lucky lane',
|
|
31
|
+
:city => 'Lost Angeles',
|
|
32
|
+
:state => 'CA',
|
|
33
|
+
:zip => '90210'
|
|
34
|
+
)
|
|
35
|
+
assert_equal Response, response.class
|
|
36
|
+
assert_equal true, response.success?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_purchase_success
|
|
40
|
+
@creditcard.number = '1'
|
|
41
|
+
|
|
42
|
+
assert response = @gateway.purchase(2400, @creditcard, :order_id => 1001,
|
|
43
|
+
:address1 => '1313 lucky lane',
|
|
44
|
+
:city => 'Lost Angeles',
|
|
45
|
+
:state => 'CA',
|
|
46
|
+
:zip => '90210'
|
|
47
|
+
)
|
|
48
|
+
assert_equal Response, response.class
|
|
49
|
+
assert_equal true, response.success?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_purchase_decline
|
|
53
|
+
@creditcard.number = '2'
|
|
54
|
+
|
|
55
|
+
@gateway = LinkpointGateway.new(
|
|
56
|
+
:login => 123123,
|
|
57
|
+
:pem => 'PEM'
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
assert response = @gateway.purchase(100, @creditcard, :order_id => 1002)
|
|
61
|
+
assert_equal Response, response.class
|
|
62
|
+
assert_equal false, response.success?
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_recurring
|
|
66
|
+
@creditcard.number = '1'
|
|
67
|
+
|
|
68
|
+
assert response = @gateway.recurring(2400, @creditcard, :order_id => 1003, :installments => 12, :startdate => "immediate", :periodicity => :monthly)
|
|
69
|
+
assert_equal Response, response.class
|
|
70
|
+
assert_equal true, response.success?
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_amount_style
|
|
74
|
+
assert_equal '10.34', @gateway.send(:amount, 1034)
|
|
75
|
+
|
|
76
|
+
assert_raise(ArgumentError) do
|
|
77
|
+
@gateway.send(:amount, '10.34')
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class LinkpointRequestTest < Test::Unit::TestCase
|
|
84
|
+
def setup
|
|
85
|
+
@gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
|
|
86
|
+
|
|
87
|
+
@creditcard = credit_card('4111111111111111')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_purchase_is_valid_xml
|
|
92
|
+
parameters = @gateway.send(:parameters, 1000, @creditcard, :ordertype => "SALE", :order_id => 1004,
|
|
93
|
+
:billing_address => {
|
|
94
|
+
:address1 => '1313 lucky lane',
|
|
95
|
+
:city => 'Lost Angeles',
|
|
96
|
+
:state => 'CA',
|
|
97
|
+
:zip => '90210'
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
assert data = @gateway.send(:post_data, parameters)
|
|
102
|
+
assert REXML::Document.new(data)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_recurring_is_valid_xml
|
|
107
|
+
parameters = @gateway.send(:parameters, 1000, @creditcard, :ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006,
|
|
108
|
+
:billing_address => {
|
|
109
|
+
:address1 => '1313 lucky lane',
|
|
110
|
+
:city => 'Lost Angeles',
|
|
111
|
+
:state => 'CA',
|
|
112
|
+
:zip => '90210'
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
assert data = @gateway.send(:post_data, parameters)
|
|
116
|
+
assert REXML::Document.new(data)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_declined_purchase_is_valid_xml
|
|
120
|
+
@gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
|
|
121
|
+
|
|
122
|
+
parameters = @gateway.send(:parameters, 1000, @creditcard, :ordertype => "SALE", :order_id => 1005,
|
|
123
|
+
:billing_address => {
|
|
124
|
+
:address1 => '1313 lucky lane',
|
|
125
|
+
:city => 'Lost Angeles',
|
|
126
|
+
:state => 'CA',
|
|
127
|
+
:zip => '90210'
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
assert data = @gateway.send(:post_data, parameters)
|
|
132
|
+
assert REXML::Document.new(data)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_overriding_test_mode
|
|
136
|
+
Base.gateway_mode = :production
|
|
137
|
+
|
|
138
|
+
gateway = LinkpointGateway.new(
|
|
139
|
+
:login => 'LOGIN',
|
|
140
|
+
:pem => 'PEM',
|
|
141
|
+
:test => true
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
assert gateway.test?
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_using_production_mode
|
|
148
|
+
Base.gateway_mode = :production
|
|
149
|
+
|
|
150
|
+
gateway = LinkpointGateway.new(
|
|
151
|
+
:login => 'LOGIN',
|
|
152
|
+
:pem => 'PEM'
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
assert !gateway.test?
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_supported_countries
|
|
159
|
+
assert_equal ['US'], LinkpointGateway.supported_countries
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def test_supported_card_types
|
|
163
|
+
assert_equal [:visa, :master, :american_express, :discover], LinkpointGateway.supported_cardtypes
|
|
164
|
+
end
|
|
165
|
+
end
|