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,140 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class AuthorizeNetTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = AuthorizeNetGateway.new(
|
|
6
|
+
:login => 'X',
|
|
7
|
+
:password => 'Y'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
@creditcard = credit_card('4242424242424242')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_purchase_success
|
|
14
|
+
@creditcard.number = 1
|
|
15
|
+
|
|
16
|
+
assert response = @gateway.purchase(100, @creditcard)
|
|
17
|
+
assert_equal Response, response.class
|
|
18
|
+
assert_equal '#0001', response.params['receiptid']
|
|
19
|
+
assert_equal true, response.success?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_purchase_error
|
|
23
|
+
@creditcard.number = 2
|
|
24
|
+
|
|
25
|
+
assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
|
|
26
|
+
assert_equal Response, response.class
|
|
27
|
+
assert_equal '#0001', response.params['receiptid']
|
|
28
|
+
assert_equal false, response.success?
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_purchase_exceptions
|
|
33
|
+
@creditcard.number = 3
|
|
34
|
+
|
|
35
|
+
assert_raise(Error) do
|
|
36
|
+
assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_amount_style
|
|
41
|
+
assert_equal '10.34', @gateway.send(:amount, 1034)
|
|
42
|
+
|
|
43
|
+
assert_raise(ArgumentError) do
|
|
44
|
+
@gateway.send(:amount, '10.34')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_add_address_outsite_north_america
|
|
49
|
+
result = {}
|
|
50
|
+
|
|
51
|
+
@gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => ''} )
|
|
52
|
+
|
|
53
|
+
assert_equal ["address", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort
|
|
54
|
+
assert_equal 'n/a', result[:state]
|
|
55
|
+
assert_equal '164 Waverley Street', result[:address]
|
|
56
|
+
assert_equal 'DE', result[:country]
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_add_address
|
|
61
|
+
result = {}
|
|
62
|
+
|
|
63
|
+
@gateway.send(:add_address, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
|
|
64
|
+
|
|
65
|
+
assert_equal ["address", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort
|
|
66
|
+
assert_equal 'CO', result[:state]
|
|
67
|
+
assert_equal '164 Waverley Street', result[:address]
|
|
68
|
+
assert_equal 'US', result[:country]
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_add_invoice
|
|
73
|
+
result = {}
|
|
74
|
+
@gateway.send(:add_invoice, result, :order_id => '#1001')
|
|
75
|
+
assert_equal '#1001', result[:invoice_num]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_add_description
|
|
79
|
+
result = {}
|
|
80
|
+
@gateway.send(:add_invoice, result, :description => 'My Purchase is great')
|
|
81
|
+
assert_equal 'My Purchase is great', result[:description]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_purchase_is_valid_csv
|
|
85
|
+
params = { :amount => '1.01' }
|
|
86
|
+
|
|
87
|
+
@gateway.send(:add_creditcard, params, @creditcard)
|
|
88
|
+
|
|
89
|
+
assert data = @gateway.send(:post_data, 'AUTH_ONLY', params)
|
|
90
|
+
assert_equal post_data_fixture.size, data.size
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_purchase_meets_minimum_requirements
|
|
94
|
+
params = {
|
|
95
|
+
:amount => "1.01",
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@gateway.send(:add_creditcard, params, @creditcard)
|
|
99
|
+
|
|
100
|
+
assert data = @gateway.send(:post_data, 'AUTH_ONLY', params)
|
|
101
|
+
minimum_requirements.each do |key|
|
|
102
|
+
assert_not_nil(data =~ /x_#{key}=/)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_credit_success
|
|
107
|
+
assert response = @gateway.credit(100, '123456789', :card_number => '1')
|
|
108
|
+
assert_success response
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_credit_failure
|
|
112
|
+
assert response = @gateway.credit(100, '123456789', :card_number => '2')
|
|
113
|
+
assert_failure response
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_supported_countries
|
|
117
|
+
assert_equal ['US'], AuthorizeNetGateway.supported_countries
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_supported_card_types
|
|
121
|
+
assert_equal [:visa, :master, :american_express, :discover], AuthorizeNetGateway.supported_cardtypes
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_failure_without_response_reason_text
|
|
125
|
+
assert_nothing_raised do
|
|
126
|
+
assert_equal '', @gateway.send(:message_from, {})
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
private
|
|
131
|
+
|
|
132
|
+
def post_data_fixture
|
|
133
|
+
'x_encap_char=%24&x_card_num=4242424242424242&x_exp_date=0806&x_card_code=123&x_type=AUTH_ONLY&x_first_name=Longbob&x_version=3.1&x_login=X&x_last_name=Longsen&x_tran_key=Y&x_relay_response=FALSE&x_delim_data=TRUE&x_delim_char=%2C&x_amount=1.01'
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def minimum_requirements
|
|
137
|
+
%w(version delim_data relay_response login tran_key amount card_num exp_date type)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class BogusTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = BogusGateway.new(
|
|
6
|
+
:login => 'bogus',
|
|
7
|
+
:password => 'bogus',
|
|
8
|
+
:test => true
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
@creditcard = credit_card('1')
|
|
12
|
+
|
|
13
|
+
@response = ActiveMerchant::Billing::Response.new(true, "Transaction successful", :transid => '1')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_authorize
|
|
17
|
+
@gateway.capture(1000, @creditcard)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_purchase
|
|
21
|
+
@gateway.purchase(1000, @creditcard)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_credit
|
|
25
|
+
@gateway.credit(1000, @response.params["transid"])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_store
|
|
29
|
+
@gateway.store(@creditcard)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_unstore
|
|
33
|
+
@gateway.unstore('1')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_supported_countries
|
|
37
|
+
assert_equal ['US'], BogusGateway.supported_countries
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_supported_card_types
|
|
41
|
+
assert_equal [:bogus], BogusGateway.supported_cardtypes
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class BrainTreeTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@gateway = BrainTreeGateway.new(
|
|
7
|
+
:login => 'LOGIN',
|
|
8
|
+
:password => 'PASSWORD'
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
@creditcard = credit_card('4242424242424242')
|
|
12
|
+
@amount = rand(9999)+1001
|
|
13
|
+
@address = { :address1 => '1234 My Street',
|
|
14
|
+
:address2 => 'Apt 1',
|
|
15
|
+
:company => 'Widgets Inc',
|
|
16
|
+
:city => 'Ottawa',
|
|
17
|
+
:state => 'ON',
|
|
18
|
+
:zip => 'K1C2N6',
|
|
19
|
+
:country => 'Canada',
|
|
20
|
+
:phone => '(555)555-5555'
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_successful_request
|
|
25
|
+
@creditcard.number = 1
|
|
26
|
+
assert response = @gateway.purchase(@amount, @creditcard, {})
|
|
27
|
+
assert_success response
|
|
28
|
+
assert_equal '5555', response.authorization
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_unsuccessful_request
|
|
32
|
+
@creditcard.number = 2
|
|
33
|
+
assert response = @gateway.purchase(@amount, @creditcard, {})
|
|
34
|
+
assert_failure response
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_request_error
|
|
38
|
+
@creditcard.number = 3
|
|
39
|
+
assert_raise(Error){ @gateway.purchase(@amount, @creditcard, {}) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_add_address
|
|
43
|
+
result = {}
|
|
44
|
+
|
|
45
|
+
@gateway.send(:add_address, result,nil, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
|
|
46
|
+
assert_equal ["address1", "city", "company", "country", "phone", "state", "zip"], result.stringify_keys.keys.sort
|
|
47
|
+
assert_equal 'CO', result[:state]
|
|
48
|
+
assert_equal '164 Waverley Street', result[:address1]
|
|
49
|
+
assert_equal 'US', result[:country]
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_supported_countries
|
|
54
|
+
assert_equal ['US'], AuthorizeNetGateway.supported_countries
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_supported_card_types
|
|
58
|
+
assert_equal [:visa, :master, :american_express, :discover], AuthorizeNetGateway.supported_cardtypes
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_adding_store_adds_vault_id_flag
|
|
62
|
+
result = {}
|
|
63
|
+
|
|
64
|
+
@gateway.send(:add_creditcard, result,@creditcard, :store=>true )
|
|
65
|
+
assert_equal ["ccexp", "ccnumber", "customer_vault", "cvv", "firstname", "lastname"], result.stringify_keys.keys.sort
|
|
66
|
+
assert_equal 'add_customer', result[:customer_vault]
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
def test_blank_store_doesnt_add_vault_flag
|
|
70
|
+
result = {}
|
|
71
|
+
|
|
72
|
+
@gateway.send(:add_creditcard, result,@creditcard, {} )
|
|
73
|
+
assert_equal ["ccexp", "ccnumber", "cvv", "firstname", "lastname"], result.stringify_keys.keys.sort
|
|
74
|
+
assert_nil result[:customer_vault]
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class CardStreamTest < Test::Unit::TestCase
|
|
4
|
+
# 100 Cents
|
|
5
|
+
AMOUNT = 100
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@gateway = CardStreamGateway.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'], CardStreamGateway.supported_countries
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_supported_card_types
|
|
21
|
+
assert_equal [:visa, :master, :american_express, :discover, :jcb, :maestro, :solo, :switch], CardStreamGateway.supported_cardtypes
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_default_currency
|
|
25
|
+
params = {}
|
|
26
|
+
|
|
27
|
+
@gateway.send(:add_amount, params, 1000, {})
|
|
28
|
+
assert_equal '826', params[:CurrencyCode]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_override_currency
|
|
32
|
+
params = {}
|
|
33
|
+
|
|
34
|
+
@gateway.send(:add_amount, params, 1000, :currency => 'USD')
|
|
35
|
+
assert_equal '840', params[:CurrencyCode]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class CyberSourceTest < Test::Unit::TestCase
|
|
4
|
+
LOGIN = 'YourLogin'
|
|
5
|
+
TRANSACTION_KEY = 'GenerateThisInTheBusinessCenter'
|
|
6
|
+
AMOUNT = 100
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
Base.gateway_mode = :test
|
|
10
|
+
@gateway = CyberSourceGateway.new(
|
|
11
|
+
:login => LOGIN,
|
|
12
|
+
:password => TRANSACTION_KEY , :test => true
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
@creditcard = credit_card('4111111111111111', :type => 'visa')
|
|
16
|
+
@declined_card = credit_card('801111111111111', :type => 'visa')
|
|
17
|
+
|
|
18
|
+
@options = { :address => {
|
|
19
|
+
:address1 => '1234 My Street',
|
|
20
|
+
:address2 => 'Apt 1',
|
|
21
|
+
:company => 'Widgets Inc',
|
|
22
|
+
:city => 'Ottawa',
|
|
23
|
+
:state => 'ON',
|
|
24
|
+
:zip => 'K1C2N6',
|
|
25
|
+
:country => 'Canada',
|
|
26
|
+
:phone => '(555)555-5555'
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
:email => 'someguy1232@fakeemail.net',
|
|
30
|
+
:order_id => 'test1111111111111111',
|
|
31
|
+
:line_items => [
|
|
32
|
+
{
|
|
33
|
+
:declared_value => 100,
|
|
34
|
+
:quantity => 2,
|
|
35
|
+
:code => 'default',
|
|
36
|
+
:description => 'Giant Walrus',
|
|
37
|
+
:sku => 'WA323232323232323'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
:declared_value => 100,
|
|
41
|
+
:quantity => 2,
|
|
42
|
+
:description => 'Marble Snowcone',
|
|
43
|
+
:sku => 'FAKE1232132113123'
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
:currency => 'USD'
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_purchase_success
|
|
51
|
+
@creditcard.number = 1
|
|
52
|
+
|
|
53
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
54
|
+
assert_equal Response, response.class
|
|
55
|
+
assert_equal '#0001', response.params['receiptid']
|
|
56
|
+
assert_equal true, response.success?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_purchase_error
|
|
60
|
+
@creditcard.number = 2
|
|
61
|
+
|
|
62
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
63
|
+
assert_equal Response, response.class
|
|
64
|
+
assert_equal '#0001', response.params['receiptid']
|
|
65
|
+
assert_equal false, response.success?
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_purchase_exceptions
|
|
69
|
+
@creditcard.number = 3
|
|
70
|
+
|
|
71
|
+
assert_raise(Error) do
|
|
72
|
+
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_successful_auth_request
|
|
77
|
+
@gateway.stubs(:ssl_post).returns(successful_authorization_response)
|
|
78
|
+
assert response = @gateway.authorize(AMOUNT, @creditcard, @options)
|
|
79
|
+
assert_equal Response, response.class
|
|
80
|
+
assert response.success?
|
|
81
|
+
assert response.test?
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_successful_tax_request
|
|
85
|
+
@gateway.stubs(:ssl_post).returns(successful_tax_response)
|
|
86
|
+
assert response = @gateway.calculate_tax(@creditcard, @options)
|
|
87
|
+
assert_equal Response, response.class
|
|
88
|
+
assert response.success?
|
|
89
|
+
assert response.test?
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_successful_capture_request
|
|
93
|
+
@gateway.stubs(:ssl_post).returns(successful_authorization_response, successful_capture_response)
|
|
94
|
+
assert response = @gateway.authorize(AMOUNT, @creditcard, @options)
|
|
95
|
+
assert response.success?
|
|
96
|
+
assert response.test?
|
|
97
|
+
assert response_capture = @gateway.capture(AMOUNT, response.authorization)
|
|
98
|
+
assert response_capture.success?
|
|
99
|
+
assert response_capture.test?
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_successful_purchase_request
|
|
103
|
+
@gateway.stubs(:ssl_post).returns(successful_capture_response)
|
|
104
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
|
|
105
|
+
assert response.success?
|
|
106
|
+
assert response.test?
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_requires_error_on_purchase_without_order_id
|
|
110
|
+
assert_raise(ArgumentError){ @gateway.purchase(AMOUNT, @creditcard, @options.delete_if{|key, val| key == :order_id}) }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def test_requires_error_on_authorization_without_order_id
|
|
114
|
+
assert_raise(ArgumentError){ @gateway.purchase(AMOUNT, @creditcard, @options.delete_if{|key, val| key == :order_id}) }
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_requires_error_on_tax_calculation_without_line_items
|
|
118
|
+
assert_raise(ArgumentError){ @gateway.calculate_tax(@creditcard, @options.delete_if{|key, val| key == :line_items})}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_default_currency
|
|
122
|
+
assert_equal 'USD', CyberSourceGateway.default_currency
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
def successful_authorization_response
|
|
128
|
+
<<-XML
|
|
129
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
130
|
+
<soap:Header>
|
|
131
|
+
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-32551101"><wsu:Created>2007-07-12T18:31:53.838Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>TEST11111111111</c:merchantReferenceCode><c:requestID>1842651133440156177166</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccAuthReply><c:reasonCode>100</c:reasonCode><c:amount>1.00</c:amount><c:authorizationCode>004542</c:authorizationCode><c:avsCode>A</c:avsCode><c:avsCodeRaw>I7</c:avsCodeRaw><c:authorizedDateTime>2007-07-12T18:31:53Z</c:authorizedDateTime><c:processorResponse>100</c:processorResponse><c:reconciliationID>23439130C40VZ2FB</c:reconciliationID></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
|
|
132
|
+
XML
|
|
133
|
+
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def successful_tax_response
|
|
137
|
+
<<-XML
|
|
138
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
139
|
+
<soap:Header>
|
|
140
|
+
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-21248497"><wsu:Created>2007-07-11T18:27:56.314Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>TEST11111111111</c:merchantReferenceCode><c:requestID>1841784762620176127166</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>AMYJY9fl62i+vx2OEQYAx9zv/9UBZAAA5h5D</c:requestToken><c:taxReply><c:reasonCode>100</c:reasonCode><c:grandTotalAmount>1.00</c:grandTotalAmount><c:totalCityTaxAmount>0</c:totalCityTaxAmount><c:city>Madison</c:city><c:totalCountyTaxAmount>0</c:totalCountyTaxAmount><c:totalDistrictTaxAmount>0</c:totalDistrictTaxAmount><c:totalStateTaxAmount>0</c:totalStateTaxAmount><c:state>WI</c:state><c:totalTaxAmount>0</c:totalTaxAmount><c:postalCode>53717</c:postalCode><c:item id="0"><c:totalTaxAmount>0</c:totalTaxAmount></c:item></c:taxReply></c:replyMessage></soap:Body></soap:Envelope>
|
|
141
|
+
XML
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def successful_capture_response
|
|
146
|
+
<<-XML
|
|
147
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-6000655"><wsu:Created>2007-07-17T17:15:32.642Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>test1111111111111111</c:merchantReferenceCode><c:requestID>1846925324700976124593</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>AP4JZB883WKS/34BEZAzMTE1OTI5MVQzWE0wQjEzBTUt3wbOAQUy3D7oDgMMmvQAnQgl</c:requestToken><c:purchaseTotals><c:currency>GBP</c:currency></c:purchaseTotals><c:ccCaptureReply><c:reasonCode>100</c:reasonCode><c:requestDateTime>2007-07-17T17:15:32Z</c:requestDateTime><c:amount>1.00</c:amount><c:reconciliationID>31159291T3XM2B13</c:reconciliationID></c:ccCaptureReply></c:replyMessage></soap:Body></soap:Envelope>
|
|
148
|
+
XML
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
end
|