activemerchant 1.2.1 → 1.3.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 +310 -294
- data/CONTRIBUTERS +13 -0
- data/README +55 -31
- data/Rakefile +21 -13
- data/lib/active_merchant.rb +7 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +8 -3
- data/lib/active_merchant/billing/check.rb +61 -0
- data/lib/active_merchant/billing/credit_card.rb +104 -80
- data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
- data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +28 -0
- data/lib/active_merchant/billing/gateway.rb +47 -111
- data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
- data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
- data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
- data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
- data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
- data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
- data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
- data/lib/active_merchant/billing/gateways/eway.rb +8 -19
- data/lib/active_merchant/billing/gateways/exact.rb +17 -25
- data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
- data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
- data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
- data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
- data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
- data/lib/active_merchant/billing/gateways/protx.rb +24 -25
- data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
- data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
- data/lib/active_merchant/billing/gateways/realex.rb +7 -19
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
- data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
- data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
- data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
- data/lib/active_merchant/billing/integrations.rb +2 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +12 -8
- data/lib/active_merchant/lib/posts_data.rb +39 -7
- data/lib/active_merchant/lib/requires_parameters.rb +2 -3
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +3 -3
- data/lib/support/gateway_support.rb +22 -9
- data/script/destroy +14 -0
- data/script/generate +7 -7
- data/test/fixtures.yml +25 -3
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
- data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
- data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
- data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
- data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
- data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
- data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
- data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
- data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
- data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
- data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
- data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
- data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
- data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
- data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
- data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
- data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
- data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
- data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +102 -61
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +33 -39
- data/test/unit/check_test.rb +76 -0
- data/test/unit/credit_card_formatting_test.rb +10 -15
- data/test/unit/credit_card_methods_test.rb +132 -17
- data/test/unit/credit_card_test.rb +157 -228
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +21 -0
- data/test/unit/gateways/authorize_net_test.rb +180 -40
- data/test/unit/gateways/bogus_test.rb +2 -3
- data/test/unit/gateways/brain_tree_test.rb +63 -29
- data/test/unit/gateways/card_stream_test.rb +59 -6
- data/test/unit/gateways/cyber_source_test.rb +59 -40
- data/test/unit/gateways/data_cash_test.rb +82 -1
- data/test/unit/gateways/efsnet_test.rb +97 -44
- data/test/unit/gateways/eway_test.rb +55 -42
- data/test/unit/gateways/exact_test.rb +93 -55
- data/test/unit/gateways/gateway_test.rb +7 -0
- data/test/unit/gateways/linkpoint_test.rb +60 -58
- data/test/unit/gateways/moneris_test.rb +67 -76
- data/test/unit/gateways/net_registry_test.rb +351 -419
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/pay_junction_test.rb +108 -46
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +0 -8
- data/test/unit/gateways/payflow_test.rb +136 -65
- data/test/unit/gateways/payflow_uk_test.rb +0 -38
- data/test/unit/gateways/payment_express_test.rb +31 -51
- data/test/unit/gateways/paypal_express_test.rb +8 -2
- data/test/unit/gateways/paypal_test.rb +213 -54
- data/test/unit/gateways/plugnpay_test.rb +39 -32
- data/test/unit/gateways/protx_test.rb +45 -33
- data/test/unit/gateways/psigate_test.rb +146 -87
- data/test/unit/gateways/psl_card_test.rb +37 -24
- data/test/unit/gateways/quickpay_test.rb +33 -46
- data/test/unit/gateways/realex_test.rb +32 -31
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +35 -26
- data/test/unit/gateways/skip_jack_test.rb +125 -0
- data/test/unit/gateways/trans_first_test.rb +24 -37
- data/test/unit/gateways/trust_commerce_test.rb +47 -26
- data/test/unit/gateways/usa_epay_test.rb +52 -41
- data/test/unit/gateways/verifi_test.rb +41 -35
- data/test/unit/gateways/viaklix_test.rb +38 -32
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +7 -14
- data/test/unit/integrations/bogus_module_test.rb +4 -0
- data/test/unit/integrations/chronopay_module_test.rb +4 -0
- data/test/unit/integrations/gestpay_module_test.rb +4 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +4 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
- data/test/unit/integrations/paypal_module_test.rb +4 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +4 -0
- data/test/unit/posts_data_test.rb +86 -0
- data/test/unit/response_test.rb +15 -1
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +10 -6
- metadata +180 -142
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
- data/script/generator/base.rb +0 -45
- data/script/generator/generator.rb +0 -24
- data/script/generator/generators/gateway/gateway_generator.rb +0 -14
- data/script/generator/generators/gateway/templates/gateway.rb +0 -73
- data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
- data/script/generator/generators/integration/integration_generator.rb +0 -25
- data/script/generator/generators/integration/templates/helper.rb +0 -34
- data/script/generator/generators/integration/templates/helper_test.rb +0 -54
- data/script/generator/generators/integration/templates/integration.rb +0 -18
- data/script/generator/generators/integration/templates/module_test.rb +0 -9
- data/script/generator/generators/integration/templates/notification.rb +0 -100
- data/script/generator/generators/integration/templates/notification_test.rb +0 -41
- data/script/generator/manifest.rb +0 -20
- data/test/remote_tests/remote_authorize_net_test.rb +0 -113
- data/test/remote_tests/remote_brain_tree_test.rb +0 -78
- data/test/remote_tests/remote_moneris_test.rb +0 -110
- data/test/remote_tests/remote_psigate_test.rb +0 -87
- data/test/remote_tests/remote_secure_pay_test.rb +0 -36
- data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
|
@@ -6,46 +6,8 @@ class PayflowUkTest < Test::Unit::TestCase
|
|
|
6
6
|
:login => 'LOGIN',
|
|
7
7
|
:password => 'PASSWORD'
|
|
8
8
|
)
|
|
9
|
-
|
|
10
|
-
@creditcard = CreditCard.new(
|
|
11
|
-
:number => '4242424242424242',
|
|
12
|
-
:month => 8,
|
|
13
|
-
:year => 2008,
|
|
14
|
-
:first_name => 'Longbob',
|
|
15
|
-
:last_name => 'Longsen'
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
@address = { :address1 => '1234 My Street',
|
|
19
|
-
:address2 => 'Apt 1',
|
|
20
|
-
:company => 'Widgets Inc',
|
|
21
|
-
:city => 'Ottawa',
|
|
22
|
-
:state => 'ON',
|
|
23
|
-
:zip => 'K1C2N6',
|
|
24
|
-
:country => 'Canada',
|
|
25
|
-
:phone => '(555)555-5555'
|
|
26
|
-
}
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_successful_request
|
|
30
|
-
@creditcard.number = 1
|
|
31
|
-
assert response = @gateway.purchase(100, @creditcard, {})
|
|
32
|
-
assert_success response
|
|
33
|
-
assert_equal '5555', response.authorization
|
|
34
|
-
assert response.test?
|
|
35
9
|
end
|
|
36
10
|
|
|
37
|
-
def test_unsuccessful_request
|
|
38
|
-
@creditcard.number = 2
|
|
39
|
-
assert response = @gateway.purchase(100, @creditcard, {})
|
|
40
|
-
assert_failure response
|
|
41
|
-
assert response.test?
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def test_request_error
|
|
45
|
-
@creditcard.number = 3
|
|
46
|
-
assert_raise(Error){ @gateway.purchase(100, @creditcard, {}) }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
11
|
def test_default_currency
|
|
50
12
|
assert_equal 'GBP', PayflowUkGateway.default_currency
|
|
51
13
|
end
|
|
@@ -8,55 +8,21 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
8
8
|
:password => 'PASSWORD'
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
@visa =
|
|
12
|
-
:number => '4242424242424242',
|
|
13
|
-
:month => 8,
|
|
14
|
-
:year => 2008,
|
|
15
|
-
:first_name => 'Longbob',
|
|
16
|
-
:last_name => 'Longsen',
|
|
17
|
-
:type => 'visa'
|
|
18
|
-
)
|
|
11
|
+
@visa = credit_card
|
|
19
12
|
|
|
20
|
-
@solo =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
:year => 2012,
|
|
25
|
-
:first_name => "Test",
|
|
26
|
-
:last_name => "Mensch",
|
|
27
|
-
:issue_number => '01'
|
|
28
|
-
)
|
|
13
|
+
@solo = credit_card("6334900000000005",
|
|
14
|
+
:type => "solo",
|
|
15
|
+
:issue_number => '01'
|
|
16
|
+
)
|
|
29
17
|
|
|
30
|
-
@
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:country => 'Canada',
|
|
37
|
-
:phone => '(555)555-5555'
|
|
38
|
-
}
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_successful_request
|
|
42
|
-
@visa.number = 1
|
|
18
|
+
@options = {
|
|
19
|
+
:order_id => generate_unique_id,
|
|
20
|
+
:billing_address => address,
|
|
21
|
+
:email => 'cody@example.com',
|
|
22
|
+
:description => 'Store purchase'
|
|
23
|
+
}
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
assert_success response
|
|
46
|
-
assert_equal '5555', response.authorization
|
|
47
|
-
assert response.test?
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_unsuccessful_request
|
|
51
|
-
@visa.number = 2
|
|
52
|
-
assert response = @gateway.purchase(100, @visa)
|
|
53
|
-
assert_failure response
|
|
54
|
-
assert response.test?
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def test_request_error
|
|
58
|
-
@visa.number = 3
|
|
59
|
-
assert_raise(Error){ @gateway.purchase(100, @visa) }
|
|
25
|
+
@amount = 100
|
|
60
26
|
end
|
|
61
27
|
|
|
62
28
|
def test_default_currency
|
|
@@ -66,7 +32,7 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
66
32
|
def test_invalid_credentials
|
|
67
33
|
@gateway.expects(:ssl_post).returns(invalid_credentials_response)
|
|
68
34
|
|
|
69
|
-
assert response = @gateway.purchase(
|
|
35
|
+
assert response = @gateway.purchase(@amount, @visa, @options)
|
|
70
36
|
assert_equal 'Invalid Credentials', response.message
|
|
71
37
|
assert_failure response
|
|
72
38
|
end
|
|
@@ -74,7 +40,7 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
74
40
|
def test_successful_authorization
|
|
75
41
|
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
76
42
|
|
|
77
|
-
assert response = @gateway.purchase(
|
|
43
|
+
assert response = @gateway.purchase(@amount, @visa, @options)
|
|
78
44
|
assert_success response
|
|
79
45
|
assert response.test?
|
|
80
46
|
assert_equal 'APPROVED', response.message
|
|
@@ -84,7 +50,7 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
84
50
|
def test_successful_solo_authorization
|
|
85
51
|
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
86
52
|
|
|
87
|
-
assert response = @gateway.purchase(
|
|
53
|
+
assert response = @gateway.purchase(@amount, @solo, @options)
|
|
88
54
|
assert_success response
|
|
89
55
|
assert response.test?
|
|
90
56
|
assert_equal 'APPROVED', response.message
|
|
@@ -126,7 +92,7 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
126
92
|
|
|
127
93
|
@gateway.expects(:ssl_post).returns( successful_token_purchase_response )
|
|
128
94
|
|
|
129
|
-
assert response = @gateway.purchase(
|
|
95
|
+
assert response = @gateway.purchase(@amount, token, @options)
|
|
130
96
|
assert_success response
|
|
131
97
|
assert_equal 'APPROVED', response.message
|
|
132
98
|
assert_equal '0000000303ace8db', response.authorization
|
|
@@ -140,6 +106,20 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
140
106
|
assert_equal [ :visa, :master, :american_express, :diners_club, :jcb ], PaymentExpressGateway.supported_cardtypes
|
|
141
107
|
end
|
|
142
108
|
|
|
109
|
+
def test_avs_result_not_supported
|
|
110
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
111
|
+
|
|
112
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
113
|
+
assert_nil response.avs_result['code']
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_cvv_result_not_supported
|
|
117
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
118
|
+
|
|
119
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
120
|
+
assert_nil response.cvv_result['code']
|
|
121
|
+
end
|
|
122
|
+
|
|
143
123
|
private
|
|
144
124
|
def invalid_credentials_response
|
|
145
125
|
'<Txn><ReCo>0</ReCo><ResponseText>Invalid Credentials</ResponseText></Txn>'
|
|
@@ -151,7 +131,7 @@ class PaymentExpressTest < Test::Unit::TestCase
|
|
|
151
131
|
<Transaction success="1" reco="00" responsetext="APPROVED">
|
|
152
132
|
<Authorized>1</Authorized>
|
|
153
133
|
<MerchantReference>Test Transaction</MerchantReference>
|
|
154
|
-
<Cvc2
|
|
134
|
+
<Cvc2>M</Cvc2>
|
|
155
135
|
<CardName>Visa</CardName>
|
|
156
136
|
<Retry>0</Retry>
|
|
157
137
|
<StatusRequired>0</StatusRequired>
|
|
@@ -8,7 +8,7 @@ class PaypalExpressTest < Test::Unit::TestCase
|
|
|
8
8
|
@gateway = PaypalExpressGateway.new(
|
|
9
9
|
:login => 'cody',
|
|
10
10
|
:password => 'test',
|
|
11
|
-
:pem => ''
|
|
11
|
+
:pem => 'PEM'
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
@address = { :address1 => '1234 My Street',
|
|
@@ -39,7 +39,7 @@ class PaypalExpressTest < Test::Unit::TestCase
|
|
|
39
39
|
gateway = PaypalExpressGateway.new(
|
|
40
40
|
:login => 'cody',
|
|
41
41
|
:password => 'test',
|
|
42
|
-
:pem => '',
|
|
42
|
+
:pem => 'PEM',
|
|
43
43
|
:test => true
|
|
44
44
|
)
|
|
45
45
|
|
|
@@ -108,6 +108,12 @@ class PaypalExpressTest < Test::Unit::TestCase
|
|
|
108
108
|
assert_equal '1.00', REXML::XPath.first(xml, '//n2:OrderTotal').text
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
+
def test_handle_locale_code
|
|
112
|
+
xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 0, { :locale => 'GB' }))
|
|
113
|
+
|
|
114
|
+
assert_equal 'GB', REXML::XPath.first(xml, '//n2:LocaleCode').text
|
|
115
|
+
end
|
|
116
|
+
|
|
111
117
|
def test_supported_countries
|
|
112
118
|
assert_equal ['US'], PaypalExpressGateway.supported_countries
|
|
113
119
|
end
|
|
@@ -2,69 +2,57 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
|
2
2
|
|
|
3
3
|
class PaypalTest < Test::Unit::TestCase
|
|
4
4
|
def setup
|
|
5
|
+
Base.mode = :test
|
|
6
|
+
PaypalGateway.pem_file = nil
|
|
7
|
+
|
|
8
|
+
@amount = 100
|
|
5
9
|
@gateway = PaypalGateway.new(
|
|
6
10
|
:login => 'cody',
|
|
7
11
|
:password => 'test',
|
|
8
|
-
:pem => ''
|
|
12
|
+
:pem => 'PEM'
|
|
9
13
|
)
|
|
10
|
-
|
|
11
|
-
@address = { :address1 => '1234 My Street',
|
|
12
|
-
:address2 => 'Apt 1',
|
|
13
|
-
:company => 'Widgets Inc',
|
|
14
|
-
:city => 'Ottawa',
|
|
15
|
-
:state => 'ON',
|
|
16
|
-
:zip => 'K1C2N6',
|
|
17
|
-
:country => 'Canada',
|
|
18
|
-
:phone => '(555)555-5555'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@creditcard = credit_card('4242424242424242')
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def teardown
|
|
27
|
-
Base.gateway_mode = :test
|
|
28
|
-
PaypalGateway.pem_file = nil
|
|
15
|
+
@credit_card = credit_card('4242424242424242')
|
|
16
|
+
@options = { :billing_address => address, :ip => '127.0.0.1' }
|
|
29
17
|
end
|
|
30
18
|
|
|
31
19
|
def test_no_ip_address
|
|
32
|
-
assert_raise(ArgumentError){ @gateway.purchase(
|
|
20
|
+
assert_raise(ArgumentError){ @gateway.purchase(@amount, @credit_card, :billing_address => address)}
|
|
33
21
|
end
|
|
34
|
-
|
|
35
|
-
def
|
|
36
|
-
@
|
|
37
|
-
|
|
38
|
-
assert response = @gateway.purchase(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
assert_equal
|
|
22
|
+
|
|
23
|
+
def test_successful_purchase
|
|
24
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
25
|
+
|
|
26
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
27
|
+
assert_instance_of Response, response
|
|
28
|
+
assert_success response
|
|
29
|
+
assert_equal '62U664727W5914806', response.authorization
|
|
30
|
+
assert response.test?
|
|
42
31
|
end
|
|
43
|
-
|
|
44
|
-
def
|
|
45
|
-
@
|
|
46
|
-
|
|
47
|
-
assert response = @gateway.purchase(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
|
|
33
|
+
def test_failed_purchase
|
|
34
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
|
35
|
+
|
|
36
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
37
|
+
assert_instance_of Response, response
|
|
38
|
+
assert_failure response
|
|
39
|
+
assert response.test?
|
|
52
40
|
end
|
|
53
41
|
|
|
54
42
|
def test_reauthorization
|
|
55
43
|
@gateway.expects(:ssl_post).returns(successful_reauthorization_response)
|
|
56
|
-
response = @gateway.reauthorize(
|
|
44
|
+
response = @gateway.reauthorize(@amount, '32J876265E528623B')
|
|
57
45
|
assert response.success?
|
|
58
46
|
assert_equal('1TX27389GX108740X', response.authorization)
|
|
59
47
|
assert response.test?
|
|
60
48
|
end
|
|
61
49
|
|
|
62
|
-
def
|
|
63
|
-
@
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
def test_reauthorization_with_warning
|
|
51
|
+
@gateway.expects(:ssl_post).returns(successful_with_warning_reauthorization_response)
|
|
52
|
+
response = @gateway.reauthorize(@amount, '32J876265E528623B')
|
|
53
|
+
assert response.success?
|
|
54
|
+
assert_equal('1TX27389GX108740X', response.authorization)
|
|
55
|
+
assert response.test?
|
|
68
56
|
end
|
|
69
57
|
|
|
70
58
|
def test_amount_style
|
|
@@ -77,7 +65,7 @@ class PaypalTest < Test::Unit::TestCase
|
|
|
77
65
|
|
|
78
66
|
def test_paypal_timeout_error
|
|
79
67
|
@gateway.stubs(:ssl_post).returns(paypal_timeout_error_response)
|
|
80
|
-
response = @gateway.purchase(
|
|
68
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
81
69
|
assert_equal "SOAP-ENV:Server", response.params['faultcode']
|
|
82
70
|
assert_equal "Internal error", response.params['faultstring']
|
|
83
71
|
assert_equal "Timeout processing request", response.params['detail']
|
|
@@ -137,15 +125,15 @@ class PaypalTest < Test::Unit::TestCase
|
|
|
137
125
|
def test_button_source
|
|
138
126
|
PaypalGateway.application_id = 'ActiveMerchant_DC'
|
|
139
127
|
|
|
140
|
-
xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Test',
|
|
128
|
+
xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Test', @amount, @credit_card, {}))
|
|
141
129
|
assert_equal 'ActiveMerchant_DC', REXML::XPath.first(xml, '//n2:ButtonSource').text
|
|
142
130
|
end
|
|
143
131
|
|
|
144
132
|
def test_item_total_shipping_handling_and_tax_not_included_unless_all_are_present
|
|
145
|
-
xml = @gateway.send(:build_sale_or_authorization_request, 'Authorization',
|
|
146
|
-
:tax =>
|
|
147
|
-
:shipping =>
|
|
148
|
-
:handling =>
|
|
133
|
+
xml = @gateway.send(:build_sale_or_authorization_request, 'Authorization', @amount, @credit_card,
|
|
134
|
+
:tax => @amount,
|
|
135
|
+
:shipping => @amount,
|
|
136
|
+
:handling => @amount
|
|
149
137
|
)
|
|
150
138
|
|
|
151
139
|
doc = REXML::Document.new(xml)
|
|
@@ -153,10 +141,10 @@ class PaypalTest < Test::Unit::TestCase
|
|
|
153
141
|
end
|
|
154
142
|
|
|
155
143
|
def test_item_total_shipping_handling_and_tax
|
|
156
|
-
xml = @gateway.send(:build_sale_or_authorization_request, 'Authorization',
|
|
157
|
-
:tax =>
|
|
158
|
-
:shipping =>
|
|
159
|
-
:handling =>
|
|
144
|
+
xml = @gateway.send(:build_sale_or_authorization_request, 'Authorization', @amount, @credit_card,
|
|
145
|
+
:tax => @amount,
|
|
146
|
+
:shipping => @amount,
|
|
147
|
+
:handling => @amount,
|
|
160
148
|
:subtotal => 200
|
|
161
149
|
)
|
|
162
150
|
|
|
@@ -164,7 +152,129 @@ class PaypalTest < Test::Unit::TestCase
|
|
|
164
152
|
assert_equal '1.00', REXML::XPath.first(doc, '//n2:PaymentDetails/n2:TaxTotal').text
|
|
165
153
|
end
|
|
166
154
|
|
|
155
|
+
def test_should_use_test_certificate_endpoint
|
|
156
|
+
gateway = PaypalGateway.new(
|
|
157
|
+
:login => 'cody',
|
|
158
|
+
:password => 'test',
|
|
159
|
+
:pem => 'PEM'
|
|
160
|
+
)
|
|
161
|
+
assert_equal PaypalGateway::URLS[:test][:certificate], gateway.send(:endpoint_url)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def test_should_use_live_certificate_endpoint
|
|
165
|
+
gateway = PaypalGateway.new(
|
|
166
|
+
:login => 'cody',
|
|
167
|
+
:password => 'test',
|
|
168
|
+
:pem => 'PEM'
|
|
169
|
+
)
|
|
170
|
+
gateway.expects(:test?).returns(false)
|
|
171
|
+
|
|
172
|
+
assert_equal PaypalGateway::URLS[:live][:certificate], gateway.send(:endpoint_url)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_should_use_test_signature_endpoint
|
|
176
|
+
gateway = PaypalGateway.new(
|
|
177
|
+
:login => 'cody',
|
|
178
|
+
:password => 'test',
|
|
179
|
+
:signature => 'SIG'
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
assert_equal PaypalGateway::URLS[:test][:signature], gateway.send(:endpoint_url)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def test_should_use_live_signature_endpoint
|
|
186
|
+
gateway = PaypalGateway.new(
|
|
187
|
+
:login => 'cody',
|
|
188
|
+
:password => 'test',
|
|
189
|
+
:signature => 'SIG'
|
|
190
|
+
)
|
|
191
|
+
gateway.expects(:test?).returns(false)
|
|
192
|
+
|
|
193
|
+
assert_equal PaypalGateway::URLS[:live][:signature], gateway.send(:endpoint_url)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def test_should_raise_argument_when_credentials_not_present
|
|
197
|
+
assert_raises(ArgumentError) do
|
|
198
|
+
PaypalGateway.new(:login => 'cody', :password => 'test')
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def test_avs_result
|
|
203
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
204
|
+
|
|
205
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
206
|
+
assert_equal 'X', response.avs_result['code']
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def test_cvv_result
|
|
210
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
211
|
+
|
|
212
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
213
|
+
assert_equal 'M', response.cvv_result['code']
|
|
214
|
+
end
|
|
215
|
+
|
|
167
216
|
private
|
|
217
|
+
def successful_purchase_response
|
|
218
|
+
<<-RESPONSE
|
|
219
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
220
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
|
|
221
|
+
<SOAP-ENV:Header>
|
|
222
|
+
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
|
|
223
|
+
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
|
|
224
|
+
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
|
|
225
|
+
<Username xsi:type="xs:string"/>
|
|
226
|
+
<Password xsi:type="xs:string"/>
|
|
227
|
+
<Subject xsi:type="xs:string"/>
|
|
228
|
+
</Credentials>
|
|
229
|
+
</RequesterCredentials>
|
|
230
|
+
</SOAP-ENV:Header>
|
|
231
|
+
<SOAP-ENV:Body id="_0">
|
|
232
|
+
<DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
|
|
233
|
+
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-01-06T23:41:25Z</Timestamp>
|
|
234
|
+
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
|
|
235
|
+
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">fee61882e6f47</CorrelationID>
|
|
236
|
+
<Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
|
|
237
|
+
<Build xmlns="urn:ebay:apis:eBLBaseComponents">1.0006</Build>
|
|
238
|
+
<Amount xsi:type="cc:BasicAmountType" currencyID="USD">3.00</Amount>
|
|
239
|
+
<AVSCode xsi:type="xs:string">X</AVSCode>
|
|
240
|
+
<CVV2Code xsi:type="xs:string">M</CVV2Code>
|
|
241
|
+
<TransactionID>62U664727W5914806</TransactionID>
|
|
242
|
+
</DoDirectPaymentResponse>
|
|
243
|
+
</SOAP-ENV:Body>
|
|
244
|
+
</SOAP-ENV:Envelope>
|
|
245
|
+
RESPONSE
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def failed_purchase_response
|
|
249
|
+
<<-RESPONSE
|
|
250
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
251
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI">
|
|
252
|
+
<SOAP-ENV:Header>
|
|
253
|
+
<Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"/>
|
|
254
|
+
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType">
|
|
255
|
+
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType">
|
|
256
|
+
<Username xsi:type="xs:string"/>
|
|
257
|
+
<Password xsi:type="xs:string"/>
|
|
258
|
+
<Subject xsi:type="xs:string"/>
|
|
259
|
+
</Credentials>
|
|
260
|
+
</RequesterCredentials>
|
|
261
|
+
</SOAP-ENV:Header>
|
|
262
|
+
<SOAP-ENV:Body id="_0">
|
|
263
|
+
<DoDirectPaymentResponse xmlns="urn:ebay:api:PayPalAPI">
|
|
264
|
+
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-01-06T23:41:25Z</Timestamp>
|
|
265
|
+
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">Failure</Ack>
|
|
266
|
+
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">fee61882e6f47</CorrelationID>
|
|
267
|
+
<Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
|
|
268
|
+
<Build xmlns="urn:ebay:apis:eBLBaseComponents">1.0006</Build>
|
|
269
|
+
<Amount xsi:type="cc:BasicAmountType" currencyID="USD">3.00</Amount>
|
|
270
|
+
<AVSCode xsi:type="xs:string">X</AVSCode>
|
|
271
|
+
<CVV2Code xsi:type="xs:string">M</CVV2Code>
|
|
272
|
+
</DoDirectPaymentResponse>
|
|
273
|
+
</SOAP-ENV:Body>
|
|
274
|
+
</SOAP-ENV:Envelope>
|
|
275
|
+
RESPONSE
|
|
276
|
+
end
|
|
277
|
+
|
|
168
278
|
def paypal_timeout_error_response
|
|
169
279
|
<<-RESPONSE
|
|
170
280
|
<?xml version='1.0' encoding='UTF-8'?>
|
|
@@ -235,6 +345,55 @@ class PaypalTest < Test::Unit::TestCase
|
|
|
235
345
|
<AuthorizationID xsi:type="ebl:AuthorizationId">1TX27389GX108740X</AuthorizationID>
|
|
236
346
|
</DoReauthorizationResponse>
|
|
237
347
|
</SOAP-ENV:Body>
|
|
348
|
+
</SOAP-ENV:Envelope>
|
|
349
|
+
RESPONSE
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
def successful_with_warning_reauthorization_response
|
|
353
|
+
<<-RESPONSE
|
|
354
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
355
|
+
<SOAP-ENV:Envelope
|
|
356
|
+
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
|
|
357
|
+
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
|
|
358
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
359
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
360
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
361
|
+
xmlns:cc="urn:ebay:apis:CoreComponentTypes"
|
|
362
|
+
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
|
|
363
|
+
xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
|
|
364
|
+
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
|
|
365
|
+
xmlns:market="urn:ebay:apis:Market"
|
|
366
|
+
xmlns:auction="urn:ebay:apis:Auction"
|
|
367
|
+
xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd"
|
|
368
|
+
xmlns:ship="urn:ebay:apis:ship"
|
|
369
|
+
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"
|
|
370
|
+
xmlns:ebl="urn:ebay:apis:eBLBaseComponents"
|
|
371
|
+
xmlns:ns="urn:ebay:api:PayPalAPI">
|
|
372
|
+
<SOAP-ENV:Header>
|
|
373
|
+
<Security
|
|
374
|
+
xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"
|
|
375
|
+
xsi:type="wsse:SecurityType">
|
|
376
|
+
</Security>
|
|
377
|
+
<RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"
|
|
378
|
+
xsi:type="ebl:CustomSecurityHeaderType">
|
|
379
|
+
<Credentials xmlns="urn:ebay:apis:eBLBaseComponents"
|
|
380
|
+
xsi:type="ebl:UserIdPasswordType">
|
|
381
|
+
<Username xsi:type="xs:string"></Username>
|
|
382
|
+
<Password xsi:type="xs:string"></Password>
|
|
383
|
+
<Subject xsi:type="xs:string"></Subject>
|
|
384
|
+
</Credentials>
|
|
385
|
+
</RequesterCredentials>
|
|
386
|
+
</SOAP-ENV:Header>
|
|
387
|
+
<SOAP-ENV:Body id="_0">
|
|
388
|
+
<DoReauthorizationResponse xmlns="urn:ebay:api:PayPalAPI">
|
|
389
|
+
<Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2007-03-04T23:34:42Z</Timestamp>
|
|
390
|
+
<Ack xmlns="urn:ebay:apis:eBLBaseComponents">SuccessWithWarning</Ack>
|
|
391
|
+
<CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">e444ddb7b3ed9</CorrelationID>
|
|
392
|
+
<Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
|
|
393
|
+
<Build xmlns="urn:ebay:apis:eBLBaseComponents">1.0006</Build>
|
|
394
|
+
<AuthorizationID xsi:type="ebl:AuthorizationId">1TX27389GX108740X</AuthorizationID>
|
|
395
|
+
</DoReauthorizationResponse>
|
|
396
|
+
</SOAP-ENV:Body>
|
|
238
397
|
</SOAP-ENV:Envelope>
|
|
239
398
|
RESPONSE
|
|
240
399
|
end
|