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
|
@@ -1,46 +1,36 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class PslCardTest < Test::Unit::TestCase
|
|
4
|
-
# 100 Cents
|
|
5
|
-
AMOUNT = 100
|
|
6
4
|
|
|
7
5
|
def setup
|
|
8
6
|
@gateway = PslCardGateway.new(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
:login => 'LOGIN',
|
|
8
|
+
:password => 'PASSWORD'
|
|
9
|
+
)
|
|
12
10
|
|
|
13
|
-
@
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
assert_success response
|
|
20
|
-
assert_equal '5555', response.authorization
|
|
21
|
-
assert response.test?
|
|
11
|
+
@credit_card = credit_card
|
|
12
|
+
@options = {
|
|
13
|
+
:billing_address => address,
|
|
14
|
+
:description => 'Store purchase'
|
|
15
|
+
}
|
|
16
|
+
@amount = 100
|
|
22
17
|
end
|
|
23
18
|
|
|
24
19
|
def test_successful_authorization
|
|
25
|
-
@
|
|
26
|
-
assert response = @gateway.authorize(
|
|
20
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
21
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
27
22
|
assert_success response
|
|
28
|
-
assert_equal '
|
|
23
|
+
assert_equal '08012522454901256086', response.authorization
|
|
29
24
|
assert response.test?
|
|
30
25
|
end
|
|
31
26
|
|
|
32
27
|
def test_unsuccessful_request
|
|
33
|
-
@
|
|
34
|
-
assert response = @gateway.purchase(
|
|
28
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
29
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
35
30
|
assert_failure response
|
|
36
31
|
assert response.test?
|
|
37
32
|
end
|
|
38
33
|
|
|
39
|
-
def test_request_error
|
|
40
|
-
@creditcard.number = 3
|
|
41
|
-
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
34
|
def test_supported_countries
|
|
45
35
|
assert_equal ['GB'], PslCardGateway.supported_countries
|
|
46
36
|
end
|
|
@@ -48,4 +38,27 @@ class PslCardTest < Test::Unit::TestCase
|
|
|
48
38
|
def test_supported_card_types
|
|
49
39
|
assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ], PslCardGateway.supported_cardtypes
|
|
50
40
|
end
|
|
41
|
+
|
|
42
|
+
def test_avs_result
|
|
43
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
44
|
+
|
|
45
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
46
|
+
assert_equal 'Y', response.avs_result['code']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_cvv_result
|
|
50
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
51
|
+
|
|
52
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
53
|
+
assert_equal 'M', response.cvv_result['code']
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
def successful_purchase_response
|
|
58
|
+
"ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def unsuccessful_purchase_response
|
|
62
|
+
"ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName="
|
|
63
|
+
end
|
|
51
64
|
end
|
|
@@ -1,56 +1,48 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class QuickpayTest < Test::Unit::TestCase
|
|
4
|
-
# 100 Cents
|
|
5
|
-
AMOUNT = 100
|
|
6
|
-
|
|
7
4
|
def setup
|
|
8
5
|
@gateway = QuickpayGateway.new(
|
|
9
6
|
:login => 'LOGIN',
|
|
10
7
|
:password => 'PASSWORD'
|
|
11
8
|
)
|
|
12
9
|
|
|
13
|
-
@
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:year => 2008,
|
|
17
|
-
:first_name => 'Longbob',
|
|
18
|
-
:last_name => 'Longsen'
|
|
19
|
-
)
|
|
10
|
+
@credit_card = credit_card('4242424242424242')
|
|
11
|
+
@amount = 100
|
|
12
|
+
@options = { :order_id => '1', :billing_address => address }
|
|
20
13
|
end
|
|
21
14
|
|
|
22
15
|
def test_successful_purchase
|
|
23
|
-
@
|
|
24
|
-
|
|
16
|
+
@gateway.expects(:ssl_post).times(2).returns(successful_authorization_response, successful_capture_response)
|
|
17
|
+
|
|
18
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
25
19
|
assert_success response
|
|
26
|
-
assert_equal '
|
|
20
|
+
assert_equal '2865261', response.authorization
|
|
27
21
|
assert response.test?
|
|
28
22
|
end
|
|
29
23
|
|
|
30
24
|
def test_successful_authorization
|
|
31
|
-
@
|
|
32
|
-
|
|
25
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
26
|
+
|
|
27
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
33
28
|
assert_success response
|
|
34
|
-
assert_equal '
|
|
29
|
+
assert_equal '2865261', response.authorization
|
|
35
30
|
assert response.test?
|
|
36
31
|
end
|
|
37
32
|
|
|
38
|
-
def
|
|
39
|
-
@
|
|
40
|
-
|
|
33
|
+
def test_failed_authorization
|
|
34
|
+
@gateway.expects(:ssl_post).returns(failed_authorization_response)
|
|
35
|
+
|
|
36
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
41
37
|
assert_failure response
|
|
38
|
+
assert_equal 'Missing/error in card verification data', response.message
|
|
42
39
|
assert response.test?
|
|
43
40
|
end
|
|
44
|
-
|
|
45
|
-
def test_request_error
|
|
46
|
-
@creditcard.number = 3
|
|
47
|
-
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
|
|
48
|
-
end
|
|
49
41
|
|
|
50
42
|
def test_parsing_response_with_errors
|
|
51
43
|
@gateway.expects(:ssl_post).returns(error_response)
|
|
52
44
|
|
|
53
|
-
response = @gateway.purchase(
|
|
45
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
54
46
|
assert_failure response
|
|
55
47
|
assert_equal '008', response.params['qpstat']
|
|
56
48
|
assert_equal 'Missing/error in cardnumberMissing/error in expirationdateMissing/error in card verification dataMissing/error in amountMissing/error in ordernumMissing/error in currency', response.params['qpstatmsg']
|
|
@@ -60,15 +52,15 @@ class QuickpayTest < Test::Unit::TestCase
|
|
|
60
52
|
def test_merchant_error
|
|
61
53
|
@gateway.expects(:ssl_post).returns(merchant_error)
|
|
62
54
|
|
|
63
|
-
response = @gateway.purchase(
|
|
55
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
64
56
|
assert_failure response
|
|
65
57
|
assert_equal response.message, 'Missing/error in merchant'
|
|
66
58
|
end
|
|
67
59
|
|
|
68
60
|
def test_parsing_successful_response
|
|
69
|
-
@gateway.expects(:ssl_post).returns(
|
|
61
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
70
62
|
|
|
71
|
-
response = @gateway.authorize(
|
|
63
|
+
response = @gateway.authorize(@amount, @credit_card, @options)
|
|
72
64
|
|
|
73
65
|
assert_success response
|
|
74
66
|
assert_equal 'OK', response.message
|
|
@@ -81,7 +73,7 @@ class QuickpayTest < Test::Unit::TestCase
|
|
|
81
73
|
assert_equal '104680', response.params['ordernum']
|
|
82
74
|
assert_equal 'cody@example.com', response.params['merchantemail']
|
|
83
75
|
assert_equal 'Visa', response.params['cardtype']
|
|
84
|
-
assert_equal
|
|
76
|
+
assert_equal @amount.to_s, response.params['amount']
|
|
85
77
|
assert_equal 'OK', response.params['qpstatmsg']
|
|
86
78
|
assert_equal 'Shopify', response.params['merchant']
|
|
87
79
|
assert_equal '1110', response.params['msgtype']
|
|
@@ -96,30 +88,25 @@ class QuickpayTest < Test::Unit::TestCase
|
|
|
96
88
|
assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], QuickpayGateway.supported_cardtypes
|
|
97
89
|
end
|
|
98
90
|
|
|
99
|
-
|
|
100
91
|
private
|
|
101
92
|
|
|
102
93
|
def error_response
|
|
103
|
-
|
|
104
|
-
<?xml version='1.0' encoding='ISO-8859-1'?>
|
|
105
|
-
|
|
106
|
-
<values qpstat='008' qpstatmsg='Missing/error in cardnumberMissing/error in expirationdateMissing/error in card verification dataMissing/error in amountMissing/error in ordernumMissing/error in currency'/>
|
|
107
|
-
XML
|
|
94
|
+
"<?xml version='1.0' encoding='ISO-8859-1'?><values qpstat='008' qpstatmsg='Missing/error in cardnumberMissing/error in expirationdateMissing/error in card verification dataMissing/error in amountMissing/error in ordernumMissing/error in currency'/>"
|
|
108
95
|
end
|
|
109
96
|
|
|
110
97
|
def merchant_error
|
|
111
|
-
|
|
112
|
-
<?xml version='1.0' encoding='ISO-8859-1'?>
|
|
113
|
-
|
|
114
|
-
<values qpstat='008' qpstatmsg='Missing/error in merchant'/>
|
|
115
|
-
XML
|
|
98
|
+
"<?xml version='1.0' encoding='ISO-8859-1'?><values qpstat='008' qpstatmsg='Missing/error in merchant'/>"
|
|
116
99
|
end
|
|
117
100
|
|
|
118
|
-
def
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
101
|
+
def successful_authorization_response
|
|
102
|
+
"<?xml version='1.0' encoding='ISO-8859-1'?><values qpstat='000' transaction='2865261' time='070425223705' ordernum='104680' merchantemail='cody@example.com' pbsstat='000' cardtype='Visa' amount='100' qpstatmsg='OK' merchant='Shopify' msgtype='1110' currency='USD'/>"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def successful_capture_response
|
|
106
|
+
'<?xml version="1.0" encoding="ISO-8859-1"?><values msgtype="1230" amount="100" time="080107061755" pbsstat="000" qpstat="000" qpstatmsg="OK" currency="DKK" ordernum="4820346075804536193" transaction="2865261" merchant="Shopify" merchantemail="pixels@jadedpixel.com" />'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def failed_authorization_response
|
|
110
|
+
'<?xml version="1.0" encoding="ISO-8859-1"?><values qpstat="008" qpstatmsg="Missing/error in card verification data" />'
|
|
124
111
|
end
|
|
125
112
|
end
|
|
@@ -2,8 +2,7 @@ require File.dirname(__FILE__) + '/../../test_helper'
|
|
|
2
2
|
require 'digest/sha1'
|
|
3
3
|
|
|
4
4
|
class RealexTest < Test::Unit::TestCase
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
def setup
|
|
8
7
|
@login = 'your_merchant_id'
|
|
9
8
|
@password = 'your_secret'
|
|
@@ -20,7 +19,7 @@ class RealexTest < Test::Unit::TestCase
|
|
|
20
19
|
:account => 'bill_web_cengal'
|
|
21
20
|
)
|
|
22
21
|
|
|
23
|
-
@
|
|
22
|
+
@credit_card = CreditCard.new(
|
|
24
23
|
:number => '4263971921001307',
|
|
25
24
|
:month => 8,
|
|
26
25
|
:year => 2008,
|
|
@@ -28,6 +27,12 @@ class RealexTest < Test::Unit::TestCase
|
|
|
28
27
|
:last_name => 'Longsen',
|
|
29
28
|
:type => 'visa'
|
|
30
29
|
)
|
|
30
|
+
|
|
31
|
+
@options = {
|
|
32
|
+
:order_id => '1'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@amount = 100
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
|
|
@@ -43,40 +48,23 @@ class RealexTest < Test::Unit::TestCase
|
|
|
43
48
|
result = Digest::SHA1.hexdigest(result + "." + @password)
|
|
44
49
|
assert_equal "06a8b619cbd76024676401e5a83e7e5453521af3", result
|
|
45
50
|
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def test_successful_request
|
|
49
|
-
@creditcard.number = 1
|
|
50
|
-
assert response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
|
|
51
|
-
assert_success response
|
|
52
|
-
assert_equal '5555', response.authorization
|
|
53
|
-
assert response.test?
|
|
54
|
-
end
|
|
55
51
|
|
|
56
|
-
def test_unsuccessful_request
|
|
57
|
-
@creditcard.number = 2
|
|
58
|
-
assert response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
|
|
59
|
-
assert_failure response
|
|
60
|
-
assert response.test?
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def test_request_error
|
|
64
|
-
@creditcard.number = 3
|
|
65
|
-
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, :order_id => 1) }
|
|
66
|
-
end
|
|
67
|
-
|
|
68
52
|
def test_successful_purchase
|
|
69
|
-
@gateway.expects(:ssl_post).returns(
|
|
53
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
70
54
|
|
|
71
|
-
response = @gateway.purchase(
|
|
55
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
56
|
+
assert_instance_of Response, response
|
|
72
57
|
assert_success response
|
|
58
|
+
assert response.test?
|
|
73
59
|
end
|
|
74
60
|
|
|
75
61
|
def test_unsuccessful_purchase
|
|
76
|
-
@gateway.expects(:ssl_post).returns(
|
|
62
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
77
63
|
|
|
78
|
-
response = @gateway.purchase(
|
|
64
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
65
|
+
assert_instance_of Response, response
|
|
79
66
|
assert_failure response
|
|
67
|
+
assert response.test?
|
|
80
68
|
end
|
|
81
69
|
|
|
82
70
|
def test_supported_countries
|
|
@@ -87,10 +75,23 @@ class RealexTest < Test::Unit::TestCase
|
|
|
87
75
|
assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes
|
|
88
76
|
end
|
|
89
77
|
|
|
78
|
+
def test_avs_result_not_supported
|
|
79
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
80
|
+
|
|
81
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
82
|
+
assert_nil response.avs_result['code']
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_cvv_result
|
|
86
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
87
|
+
|
|
88
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
89
|
+
assert_equal 'M', response.cvv_result['code']
|
|
90
|
+
end
|
|
90
91
|
|
|
91
92
|
private
|
|
92
93
|
|
|
93
|
-
def
|
|
94
|
+
def successful_purchase_response
|
|
94
95
|
<<-RESPONSE
|
|
95
96
|
<response timestamp='20010427043422'>
|
|
96
97
|
<merchantid>your merchant id</merchantid>
|
|
@@ -119,7 +120,7 @@ class RealexTest < Test::Unit::TestCase
|
|
|
119
120
|
RESPONSE
|
|
120
121
|
end
|
|
121
122
|
|
|
122
|
-
def
|
|
123
|
+
def unsuccessful_purchase_response
|
|
123
124
|
<<-RESPONSE
|
|
124
125
|
<response timestamp='20010427043422'>
|
|
125
126
|
<merchantid>your merchant id</merchantid>
|
|
@@ -127,7 +128,7 @@ class RealexTest < Test::Unit::TestCase
|
|
|
127
128
|
<orderid>order id from request</orderid>
|
|
128
129
|
<authcode>authcode received</authcode>
|
|
129
130
|
<result>01</result>
|
|
130
|
-
<message>message returned from system</message>
|
|
131
|
+
<message>[ test system ] message returned from system</message>
|
|
131
132
|
<pasref> realex payments reference</pasref>
|
|
132
133
|
<cvnresult>M</cvnresult>
|
|
133
134
|
<batchid>batch id for this transaction (if any)</batchid>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class SecurePayTechTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = SecurePayTechGateway.new(
|
|
6
|
+
:login => 'x',
|
|
7
|
+
:password => 'y'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
@amount = 100
|
|
11
|
+
@credit_card = credit_card('4987654321098769')
|
|
12
|
+
@options = {
|
|
13
|
+
:billing_address => address
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_successful_purchase
|
|
18
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
19
|
+
|
|
20
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
21
|
+
assert_instance_of Response, response
|
|
22
|
+
assert_success response
|
|
23
|
+
assert response.test?
|
|
24
|
+
assert_equal '4--120119220646821', response.authorization
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_unsuccessful_purchase
|
|
28
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
29
|
+
|
|
30
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
31
|
+
assert_instance_of Response, response
|
|
32
|
+
assert_failure response
|
|
33
|
+
assert response.test?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
def successful_purchase_response
|
|
38
|
+
"1,4--120119220646821,000000014511,23284,014511,20080125\r\n"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def unsuccessful_purchase_response
|
|
42
|
+
"4,4--120119180936527,000000014510,23283,014510,20080125\r\n"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class SecurePayTest < Test::Unit::TestCase
|
|
4
|
-
include ActiveMerchant::Billing
|
|
5
4
|
|
|
6
5
|
def setup
|
|
7
6
|
@gateway = SecurePayGateway.new(
|
|
@@ -9,31 +8,21 @@ class SecurePayTest < Test::Unit::TestCase
|
|
|
9
8
|
:password => 'Y'
|
|
10
9
|
)
|
|
11
10
|
|
|
12
|
-
@
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
|
|
11
|
+
@credit_card = credit_card
|
|
12
|
+
|
|
13
|
+
@options = {
|
|
14
|
+
:order_id => generate_unique_id,
|
|
15
|
+
:description => 'Store purchase',
|
|
16
|
+
:billing_address => address
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@amount = 100
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def test_failed_purchase
|
|
22
23
|
@gateway.stubs(:ssl_post).returns(failure_response)
|
|
23
24
|
|
|
24
|
-
assert response = @gateway.purchase(
|
|
25
|
-
:order_id => generate_order_id,
|
|
26
|
-
:description => 'Store purchase',
|
|
27
|
-
:billing_address => {
|
|
28
|
-
:first_name => 'Cody',
|
|
29
|
-
:last_name => 'Fauser',
|
|
30
|
-
:address1 => '1234 Test St.',
|
|
31
|
-
:city => 'Ottawa',
|
|
32
|
-
:state => 'ON',
|
|
33
|
-
:country => 'Canada',
|
|
34
|
-
:zip => 'K2P7G2'
|
|
35
|
-
}
|
|
36
|
-
)
|
|
25
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
37
26
|
assert_failure response
|
|
38
27
|
assert response.test?
|
|
39
28
|
assert_equal 'This transaction has been declined', response.message
|
|
@@ -43,17 +32,29 @@ class SecurePayTest < Test::Unit::TestCase
|
|
|
43
32
|
def test_successful_purchase
|
|
44
33
|
@gateway.stubs(:ssl_post).returns(successful_purchase_response)
|
|
45
34
|
|
|
46
|
-
assert response = @gateway.purchase(
|
|
47
|
-
:order_id => generate_order_id,
|
|
48
|
-
:description => 'Store purchase'
|
|
49
|
-
)
|
|
50
|
-
|
|
35
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
51
36
|
assert_success response
|
|
52
37
|
assert response.test?
|
|
53
38
|
assert_equal 'This transaction has been approved', response.message
|
|
54
39
|
assert response.authorization
|
|
55
40
|
end
|
|
56
41
|
|
|
42
|
+
|
|
43
|
+
def test_avs_result
|
|
44
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
45
|
+
|
|
46
|
+
response = @gateway.purchase(@amount, @credit_card)
|
|
47
|
+
assert_equal 'X', response.avs_result['code']
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_cvv_result_not_supported
|
|
51
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
52
|
+
|
|
53
|
+
response = @gateway.purchase(@amount, @credit_card)
|
|
54
|
+
assert_nil response.cvv_result['code']
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
57
58
|
def test_undefine_unsupported_methods
|
|
58
59
|
assert @gateway.respond_to?(:purchase)
|
|
59
60
|
|
|
@@ -62,6 +63,14 @@ class SecurePayTest < Test::Unit::TestCase
|
|
|
62
63
|
end
|
|
63
64
|
end
|
|
64
65
|
|
|
66
|
+
def test_supported_countries_are_inherited
|
|
67
|
+
assert_equal AuthorizeNetGateway.supported_countries, SecurePayGateway.supported_countries
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_supported_card_types_are_inherited
|
|
71
|
+
assert_equal AuthorizeNetGateway.supported_cardtypes, SecurePayGateway.supported_cardtypes
|
|
72
|
+
end
|
|
73
|
+
|
|
65
74
|
private
|
|
66
75
|
|
|
67
76
|
def successful_purchase_response
|