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,61 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
3
|
+
|
|
4
|
+
class PayJunctionTest < Test::Unit::TestCase
|
|
5
|
+
include ActiveMerchant::Billing
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
|
|
9
|
+
ActiveMerchant::Billing::Base.gateway_mode = :test
|
|
10
|
+
|
|
11
|
+
@gateway = PayJunctionGateway.new({
|
|
12
|
+
:login => "pj-ql-01",
|
|
13
|
+
:password => "pj-ql-01p"
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
@creditcard = CreditCard.new({
|
|
17
|
+
:number => '4111111111111111',
|
|
18
|
+
:month => 8,
|
|
19
|
+
:year => 2006,
|
|
20
|
+
:first_name => 'Longbob',
|
|
21
|
+
:last_name => 'Longsen'
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_purchase_success
|
|
27
|
+
@creditcard.number = '1'
|
|
28
|
+
|
|
29
|
+
assert response = @gateway.purchase(Money.new(100), @creditcard)
|
|
30
|
+
assert_equal Response, response.class
|
|
31
|
+
assert_equal '#0001', response.params['receiptid']
|
|
32
|
+
assert_equal true, response.success?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_purchase_error
|
|
36
|
+
@creditcard.number = '2'
|
|
37
|
+
|
|
38
|
+
assert response = @gateway.purchase(Money.new(100), @creditcard)
|
|
39
|
+
assert_equal Response, response.class
|
|
40
|
+
assert_equal '#0001', response.params['receiptid']
|
|
41
|
+
assert_equal false, response.success?
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_purchase_exceptions
|
|
46
|
+
@creditcard.number = '3'
|
|
47
|
+
|
|
48
|
+
assert_raise(Error) do
|
|
49
|
+
assert response = @gateway.purchase(Money.new(100), @creditcard)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_amount_style
|
|
54
|
+
assert_equal '10.34', @gateway.send(:amount, Money.us_dollar(1034))
|
|
55
|
+
assert_equal '10.34', @gateway.send(:amount, 1034)
|
|
56
|
+
|
|
57
|
+
assert_raise(ArgumentError) do
|
|
58
|
+
@gateway.send(:amount, '10.34')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class PayflowExpressTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = PayflowExpressGateway.new(
|
|
8
|
+
:login => 'LOGIN',
|
|
9
|
+
:password => 'PASSWORD'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@address = { :address1 => '1234 My Street',
|
|
13
|
+
:address2 => 'Apt 1',
|
|
14
|
+
:company => 'Widgets Inc',
|
|
15
|
+
:city => 'Ottawa',
|
|
16
|
+
:state => 'ON',
|
|
17
|
+
:zip => 'K1C2N6',
|
|
18
|
+
:country => 'Canada',
|
|
19
|
+
:phone => '(555)555-5555'
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def teardown
|
|
24
|
+
Base.gateway_mode = :test
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_using_test_mode
|
|
28
|
+
assert @gateway.test?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_overriding_test_mode
|
|
32
|
+
Base.gateway_mode = :production
|
|
33
|
+
|
|
34
|
+
gateway = PayflowExpressGateway.new(
|
|
35
|
+
:login => 'LOGIN',
|
|
36
|
+
:password => 'PASSWORD',
|
|
37
|
+
:test => true
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
assert gateway.test?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_using_production_mode
|
|
44
|
+
Base.gateway_mode = :production
|
|
45
|
+
|
|
46
|
+
gateway = PayflowExpressGateway.new(
|
|
47
|
+
:login => 'LOGIN',
|
|
48
|
+
:password => 'PASSWORD'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
assert !gateway.test?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_class_certification_id
|
|
55
|
+
assert_equal '55d64dfec398cbbe66c1bf843cbad9', PayflowExpressGateway.certification_id
|
|
56
|
+
PayflowExpressGateway.certification_id = 'test'
|
|
57
|
+
assert_equal 'test', PayflowExpressGateway.certification_id
|
|
58
|
+
gateway = PayflowExpressGateway.new(:login => 'test', :password => 'test')
|
|
59
|
+
assert_equal 'test', gateway.certification_id
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_live_redirect_url
|
|
63
|
+
Base.gateway_mode = :production
|
|
64
|
+
assert_equal 'https://www.paypal.com/cgibin/webscr?cmd=_express-checkout&token=1234567890', @gateway.redirect_url_for('1234567890')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_test_redirect_url
|
|
68
|
+
assert_equal 'https://test-expresscheckout.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=1234567890', @gateway.redirect_url_for('1234567890')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_invalid_get_express_details_request
|
|
72
|
+
@gateway.expects(:ssl_post).returns(invalid_get_express_details_response)
|
|
73
|
+
response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
|
|
74
|
+
assert_failure response
|
|
75
|
+
assert response.test?
|
|
76
|
+
assert_equal 'Field format error: Invalid Token', response.message
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_get_express_details
|
|
80
|
+
@gateway.expects(:ssl_post).returns(successful_get_express_details_response)
|
|
81
|
+
response = @gateway.details_for('EC-2OPN7UJGFWK9OYFV')
|
|
82
|
+
assert_instance_of PayflowExpressResponse, response
|
|
83
|
+
assert_success response
|
|
84
|
+
assert response.test?
|
|
85
|
+
|
|
86
|
+
assert_equal 'EC-2OPN7UJGFWK9OYFV', response.token
|
|
87
|
+
assert_equal '12345678901234567', response.payer_id
|
|
88
|
+
assert_equal 'Buyer1@paypal.com', response.email
|
|
89
|
+
assert_equal 'Joe Smith', response.full_name
|
|
90
|
+
assert_equal 'US', response.payer_country
|
|
91
|
+
|
|
92
|
+
assert address = response.address
|
|
93
|
+
assert_equal 'Joe Smith', address['name']
|
|
94
|
+
assert_nil address['company']
|
|
95
|
+
assert_equal '111 Main St.', address['address1']
|
|
96
|
+
assert_nil address['address2']
|
|
97
|
+
assert_equal 'San Jose', address['city']
|
|
98
|
+
assert_equal 'CA', address['state']
|
|
99
|
+
assert_equal '95100', address['zip']
|
|
100
|
+
assert_equal 'US', address['country']
|
|
101
|
+
assert_nil address['phone']
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_button_source
|
|
105
|
+
xml = Builder::XmlMarkup.new
|
|
106
|
+
@gateway.send(:add_paypal_details, xml, {})
|
|
107
|
+
xml_doc = REXML::Document.new(xml.target!)
|
|
108
|
+
assert_equal 'ActiveMerchant', REXML::XPath.first(xml_doc, '/PayPal/ButtonSource').text
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
private
|
|
112
|
+
|
|
113
|
+
def successful_get_express_details_response
|
|
114
|
+
<<-RESPONSE
|
|
115
|
+
<XMLPayResponse xmlns='http://www.verisign.com/XMLPay'>
|
|
116
|
+
<ResponseData>
|
|
117
|
+
<Vendor>TEST</Vendor>
|
|
118
|
+
<Partner>verisign</Partner>
|
|
119
|
+
<TransactionResults>
|
|
120
|
+
<TransactionResult>
|
|
121
|
+
<Result>0</Result>
|
|
122
|
+
<Message>Approved</Message>
|
|
123
|
+
<PayPalResult>
|
|
124
|
+
<EMail>Buyer1@paypal.com</EMail>
|
|
125
|
+
<PayerID>12345678901234567</PayerID>
|
|
126
|
+
<Token>EC-2OPN7UJGFWK9OYFV</Token>
|
|
127
|
+
<FeeAmount>0</FeeAmount>
|
|
128
|
+
<PayerStatus>verified</PayerStatus>
|
|
129
|
+
<Name>Joe</Name>
|
|
130
|
+
<ShipTo>
|
|
131
|
+
<Address>
|
|
132
|
+
<Street>111 Main St.</Street>
|
|
133
|
+
<City>San Jose</City>
|
|
134
|
+
<State>CA</State>
|
|
135
|
+
<Zip>95100</Zip>
|
|
136
|
+
<Country>US</Country>
|
|
137
|
+
</Address>
|
|
138
|
+
</ShipTo>
|
|
139
|
+
<CorrelationID>9c3706997455e</CorrelationID>
|
|
140
|
+
</PayPalResult>
|
|
141
|
+
<ExtData Name='LASTNAME' Value='Smith'/>
|
|
142
|
+
</TransactionResult>
|
|
143
|
+
</TransactionResults>
|
|
144
|
+
</ResponseData>
|
|
145
|
+
</XMLPayResponse>
|
|
146
|
+
RESPONSE
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def invalid_get_express_details_response
|
|
150
|
+
<<-RESPONSE
|
|
151
|
+
<XMLPayResponse xmlns='http://www.verisign.com/XMLPay'>
|
|
152
|
+
<ResponseData>
|
|
153
|
+
<Vendor>TEST</Vendor>
|
|
154
|
+
<Partner>verisign</Partner>
|
|
155
|
+
<TransactionResults>
|
|
156
|
+
<TransactionResult>
|
|
157
|
+
<Result>7</Result>
|
|
158
|
+
<Message>Field format error: Invalid Token</Message>
|
|
159
|
+
</TransactionResult>
|
|
160
|
+
</TransactionResults>
|
|
161
|
+
</ResponseData>
|
|
162
|
+
</XMLPayResponse>
|
|
163
|
+
RESPONSE
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class PayflowExpressUkTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = PayflowExpressUkGateway.new(
|
|
6
|
+
:login => 'LOGIN',
|
|
7
|
+
:password => 'PASSWORD'
|
|
8
|
+
)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_supported_countries
|
|
12
|
+
assert_equal ['GB'], PayflowExpressUkGateway.supported_countries
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class PayflowTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Base.gateway_mode = :test
|
|
6
|
+
|
|
7
|
+
@gateway = PayflowGateway.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
|
+
end
|
|
24
|
+
|
|
25
|
+
def teardown
|
|
26
|
+
Base.gateway_mode = :test
|
|
27
|
+
PayflowGateway.certification_id = nil
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_successful_request
|
|
31
|
+
@creditcard.number = 1
|
|
32
|
+
assert response = @gateway.purchase(100, @creditcard, {})
|
|
33
|
+
assert_success response
|
|
34
|
+
assert_equal '5555', response.authorization
|
|
35
|
+
assert response.test?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_unsuccessful_request
|
|
39
|
+
@creditcard.number = 2
|
|
40
|
+
assert response = @gateway.purchase(100, @creditcard, {})
|
|
41
|
+
assert_failure response
|
|
42
|
+
assert response.test?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_request_error
|
|
46
|
+
@creditcard.number = 3
|
|
47
|
+
assert_raise(Error){ @gateway.purchase(100, @creditcard, {}) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_using_test_mode
|
|
51
|
+
assert @gateway.test?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_overriding_test_mode
|
|
55
|
+
Base.gateway_mode = :production
|
|
56
|
+
|
|
57
|
+
gateway = PayflowGateway.new(
|
|
58
|
+
:login => 'LOGIN',
|
|
59
|
+
:password => 'PASSWORD',
|
|
60
|
+
:test => true
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
assert gateway.test?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_using_production_mode
|
|
67
|
+
Base.gateway_mode = :production
|
|
68
|
+
|
|
69
|
+
gateway = PayflowGateway.new(
|
|
70
|
+
:login => 'LOGIN',
|
|
71
|
+
:password => 'PASSWORD'
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
assert !gateway.test?
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_certification_id_class_accessor
|
|
78
|
+
PayflowGateway.certification_id = 'test'
|
|
79
|
+
assert_equal 'test', PayflowGateway.certification_id
|
|
80
|
+
gateway = PayflowGateway.new(:login => 'test', :password => 'test')
|
|
81
|
+
assert_equal 'test', gateway.options[:certification_id]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_passed_in_certificate_overrides_class_accessor
|
|
85
|
+
PayflowGateway.certification_id = 'test'
|
|
86
|
+
gateway = PayflowGateway.new(:login => 'test', :password => 'test', :certification_id => 'Clobber')
|
|
87
|
+
assert_equal 'Clobber', gateway.options[:certification_id]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_partner_class_accessor
|
|
91
|
+
assert_equal 'PayPal', PayflowGateway.partner
|
|
92
|
+
gateway = PayflowGateway.new(:login => 'test', :password => 'test')
|
|
93
|
+
assert_equal 'PayPal', gateway.options[:partner]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_passed_in_partner_overrides_class_accessor
|
|
97
|
+
assert_equal 'PayPal', PayflowGateway.partner
|
|
98
|
+
gateway = PayflowGateway.new(:login => 'test', :password => 'test', :partner => 'PayPalUk')
|
|
99
|
+
assert_equal 'PayPalUk', gateway.options[:partner]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_express_instance
|
|
103
|
+
PayflowGateway.certification_id = '123456'
|
|
104
|
+
gateway = PayflowGateway.new(
|
|
105
|
+
:login => 'test',
|
|
106
|
+
:password => 'password'
|
|
107
|
+
)
|
|
108
|
+
express = gateway.express
|
|
109
|
+
assert_instance_of PayflowExpressGateway, express
|
|
110
|
+
assert_equal '123456', express.options[:certification_id]
|
|
111
|
+
assert_equal 'PayPal', express.options[:partner]
|
|
112
|
+
assert_equal 'test', express.options[:login]
|
|
113
|
+
assert_equal 'password', express.options[:password]
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_default_currency
|
|
117
|
+
assert_equal 'USD', PayflowGateway.default_currency
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_supported_countries
|
|
121
|
+
assert_equal ['US', 'CA', 'SG', 'AU'], PayflowGateway.supported_countries
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_supported_card_types
|
|
125
|
+
assert_equal [:visa, :master, :american_express, :jcb, :discover, :diners_club], PayflowGateway.supported_cardtypes
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_initial_recurring_transaction_missing_parameters
|
|
129
|
+
assert_raises ArgumentError do
|
|
130
|
+
response = @gateway.recurring(1000, @creditcard,
|
|
131
|
+
:periodicity => :monthly,
|
|
132
|
+
:initial_transaction => { }
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def test_initial_purchase_missing_amount
|
|
138
|
+
assert_raises ArgumentError do
|
|
139
|
+
response = @gateway.recurring(1000, @creditcard,
|
|
140
|
+
:periodicity => :monthly,
|
|
141
|
+
:initial_transaction => { :amount => :purchase }
|
|
142
|
+
)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def test_successful_recurring_action
|
|
147
|
+
@gateway.stubs(:ssl_post).returns(successful_recurring_response)
|
|
148
|
+
|
|
149
|
+
response = @gateway.recurring(1000, @creditcard, :periodicity => :monthly)
|
|
150
|
+
|
|
151
|
+
assert_instance_of PayflowResponse, response
|
|
152
|
+
assert_success response
|
|
153
|
+
assert_equal 'RT0000000009', response.profile_id
|
|
154
|
+
assert response.test?
|
|
155
|
+
assert_equal "R7960E739F80", response.authorization
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_successful_authorization
|
|
159
|
+
@gateway.stubs(:ssl_post).returns(successful_authorization_response)
|
|
160
|
+
|
|
161
|
+
assert response = @gateway.authorize(100, @creditcard, { :address => @address })
|
|
162
|
+
assert_equal "Approved", response.message
|
|
163
|
+
assert_success response
|
|
164
|
+
assert response.test?
|
|
165
|
+
assert_equal "VUJN1A6E11D9", response.authorization
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def test_format_issue_number
|
|
169
|
+
xml = Builder::XmlMarkup.new
|
|
170
|
+
credit_card = credit_card("5641820000000005",
|
|
171
|
+
:type => "switch",
|
|
172
|
+
:issue_number => 1
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
@gateway.send(:add_credit_card, xml, credit_card)
|
|
176
|
+
doc = REXML::Document.new(xml.target!)
|
|
177
|
+
node = REXML::XPath.first(doc, '/Card/ExtData')
|
|
178
|
+
assert_equal '01', node.attributes['Value']
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def test_eof_received_on_timeout
|
|
182
|
+
Net::HTTP.any_instance.stubs(:post).raises(EOFError, "end of file reached")
|
|
183
|
+
|
|
184
|
+
assert_raises(ActiveMerchant::ConnectionError) do
|
|
185
|
+
@gateway.purchase(100, @creditcard, {})
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def test__received_on_timeout
|
|
190
|
+
Net::HTTP.any_instance.stubs(:post).raises(Errno::ECONNREFUSED, "Connection refused - connect(2)")
|
|
191
|
+
|
|
192
|
+
assert_raises(ActiveMerchant::ConnectionError) do
|
|
193
|
+
@gateway.purchase(100, @creditcard, {})
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
private
|
|
198
|
+
def successful_recurring_response
|
|
199
|
+
<<-XML
|
|
200
|
+
<ResponseData>
|
|
201
|
+
<Result>0</Result>
|
|
202
|
+
<Message>Approved</Message>
|
|
203
|
+
<Partner>paypal</Partner>
|
|
204
|
+
<RpRef>R7960E739F80</RpRef>
|
|
205
|
+
<Vendor>ActiveMerchant</Vendor>
|
|
206
|
+
<ProfileId>RT0000000009</ProfileId>
|
|
207
|
+
</ResponseData>
|
|
208
|
+
XML
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def successful_authorization_response
|
|
212
|
+
<<-XML
|
|
213
|
+
<ResponseData>
|
|
214
|
+
<Result>0</Result>
|
|
215
|
+
<Message>Approved</Message>
|
|
216
|
+
<Partner>verisign</Partner>
|
|
217
|
+
<HostCode>000</HostCode>
|
|
218
|
+
<ResponseText>AP</ResponseText>
|
|
219
|
+
<PnRef>VUJN1A6E11D9</PnRef>
|
|
220
|
+
<IavsResult>N</IavsResult>
|
|
221
|
+
<ZipMatch>Match</ZipMatch>
|
|
222
|
+
<AuthCode>094016</AuthCode>
|
|
223
|
+
<Vendor>ActiveMerchant</Vendor>
|
|
224
|
+
<AvsResult>Y</AvsResult>
|
|
225
|
+
<StreetMatch>Match</StreetMatch>
|
|
226
|
+
<CvResult>Match</CvResult>
|
|
227
|
+
</ResponseData>
|
|
228
|
+
XML
|
|
229
|
+
end
|
|
230
|
+
end
|