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,16 +1,56 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class CardStreamTest < Test::Unit::TestCase
|
|
4
|
-
# 100 Cents
|
|
5
|
-
AMOUNT = 100
|
|
6
|
-
|
|
7
4
|
def setup
|
|
8
5
|
@gateway = CardStreamGateway.new(
|
|
9
6
|
:login => 'LOGIN',
|
|
10
7
|
:password => 'PASSWORD'
|
|
11
8
|
)
|
|
12
|
-
|
|
13
|
-
@
|
|
9
|
+
|
|
10
|
+
@amount = 100
|
|
11
|
+
@credit_card = credit_card('4242424242424242')
|
|
12
|
+
@options = { :order_id => '1', :billing_address => address }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_successful_purchase
|
|
16
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
17
|
+
|
|
18
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
19
|
+
assert_instance_of Response, response
|
|
20
|
+
assert_success response
|
|
21
|
+
assert_equal '08010706065208191057', response.authorization
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_failed_purchase
|
|
25
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
|
26
|
+
|
|
27
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
28
|
+
assert_instance_of Response, response
|
|
29
|
+
assert_failure response
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_successful_avs_result
|
|
33
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
34
|
+
|
|
35
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
36
|
+
assert_equal 'Y', response.avs_result['street_match']
|
|
37
|
+
assert_equal 'Y', response.avs_result['postal_match']
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_failed_avs_result
|
|
41
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_failed_avs_cvv_response)
|
|
42
|
+
|
|
43
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
44
|
+
assert_equal 'N', response.cvv_result['code']
|
|
45
|
+
assert_equal 'N', response.avs_result['street_match']
|
|
46
|
+
assert_equal 'N', response.avs_result['postal_match']
|
|
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']
|
|
14
54
|
end
|
|
15
55
|
|
|
16
56
|
def test_supported_countries
|
|
@@ -18,7 +58,7 @@ class CardStreamTest < Test::Unit::TestCase
|
|
|
18
58
|
end
|
|
19
59
|
|
|
20
60
|
def test_supported_card_types
|
|
21
|
-
assert_equal [:visa, :master, :american_express, :discover, :jcb, :maestro, :solo, :switch], CardStreamGateway.supported_cardtypes
|
|
61
|
+
assert_equal [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch], CardStreamGateway.supported_cardtypes
|
|
22
62
|
end
|
|
23
63
|
|
|
24
64
|
def test_default_currency
|
|
@@ -34,4 +74,17 @@ class CardStreamTest < Test::Unit::TestCase
|
|
|
34
74
|
@gateway.send(:add_amount, params, 1000, :currency => 'USD')
|
|
35
75
|
assert_equal '840', params[:CurrencyCode]
|
|
36
76
|
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
def successful_purchase_response
|
|
80
|
+
'VPResponseCode=00&VPCrossReference=08010706065208191057&VPMessage=AUTHCODE:08191&VPTransactionUnique=c3871e2d005b924bf81565537caba82d&VPOrderDesc=Store purchase&VPBillingCountry=826&VPCardName=Longbob Longsen&VPBillingPostCode=LE10 2RT&VPAmountRecieved=100&VPAVSCV2ResponseCode=222100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=Postcode Matched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=MC&VPBillingAddress=25 The Larches, Narborough, Leicester&VPReturnPoint=0090'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def successful_purchase_failed_avs_cvv_response
|
|
84
|
+
'VPResponseCode=00&VPCrossReference=08010706065208191057&VPMessage=AUTHCODE:08191&VPTransactionUnique=c3871e2d005b924bf81565537caba82d&VPOrderDesc=Store purchase&VPBillingCountry=826&VPCardName=Longbob Longsen&VPBillingPostCode=LE10 2RT&VPAmountRecieved=100&VPAVSCV2ResponseCode=444100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=Postcode Matched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=MC&VPBillingAddress=25 The Larches, Narborough, Leicester&VPReturnPoint=0090'
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def failed_purchase_response
|
|
88
|
+
'VPResponseCode=05&VPCrossReference=NoCrossReference&VPMessage=CARD DECLINED&VPTransactionUnique=d966e18a2983faff3715a541983792e0&VPOrderDesc=Store purchase&VPBillingCountry=826&VPCardName=Longbob Longsen&VPBillingPostCode=LE10 2RT&VPAmountRecieved=NA&VPAVSCV2ResponseCode=222100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=Postcode Matched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=MC&VPBillingAddress=25 The Larches, Narborough, Leicester&VPReturnPoint=0090'
|
|
89
|
+
end
|
|
37
90
|
end
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class CyberSourceTest < Test::Unit::TestCase
|
|
4
|
-
LOGIN = 'YourLogin'
|
|
5
|
-
TRANSACTION_KEY = 'GenerateThisInTheBusinessCenter'
|
|
6
|
-
AMOUNT = 100
|
|
7
|
-
|
|
8
4
|
def setup
|
|
9
5
|
Base.gateway_mode = :test
|
|
6
|
+
|
|
10
7
|
@gateway = CyberSourceGateway.new(
|
|
11
|
-
:login =>
|
|
12
|
-
:password =>
|
|
8
|
+
:login => 'l',
|
|
9
|
+
:password => 'p'
|
|
13
10
|
)
|
|
14
11
|
|
|
15
|
-
@
|
|
12
|
+
@amount = 100
|
|
13
|
+
@credit_card = credit_card('4111111111111111', :type => 'visa')
|
|
16
14
|
@declined_card = credit_card('801111111111111', :type => 'visa')
|
|
17
15
|
|
|
18
|
-
@options = { :
|
|
16
|
+
@options = { :billing_address => {
|
|
19
17
|
:address1 => '1234 My Street',
|
|
20
18
|
:address2 => 'Apt 1',
|
|
21
19
|
:company => 'Widgets Inc',
|
|
@@ -27,17 +25,17 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
|
27
25
|
},
|
|
28
26
|
|
|
29
27
|
:email => 'someguy1232@fakeemail.net',
|
|
30
|
-
:order_id => '
|
|
28
|
+
:order_id => '1000',
|
|
31
29
|
:line_items => [
|
|
32
30
|
{
|
|
33
|
-
:declared_value =>
|
|
31
|
+
:declared_value => @amount,
|
|
34
32
|
:quantity => 2,
|
|
35
33
|
:code => 'default',
|
|
36
34
|
:description => 'Giant Walrus',
|
|
37
35
|
:sku => 'WA323232323232323'
|
|
38
36
|
},
|
|
39
37
|
{
|
|
40
|
-
:declared_value =>
|
|
38
|
+
:declared_value => @amount,
|
|
41
39
|
:quantity => 2,
|
|
42
40
|
:description => 'Marble Snowcone',
|
|
43
41
|
:sku => 'FAKE1232132113123'
|
|
@@ -47,35 +45,27 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
|
47
45
|
}
|
|
48
46
|
end
|
|
49
47
|
|
|
50
|
-
def
|
|
51
|
-
@
|
|
48
|
+
def test_successful_purchase
|
|
49
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
52
50
|
|
|
53
|
-
assert response = @gateway.purchase(
|
|
54
|
-
assert_equal
|
|
55
|
-
|
|
56
|
-
assert_equal
|
|
51
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
52
|
+
assert_equal 'Successful transaction', response.message
|
|
53
|
+
assert_success response
|
|
54
|
+
assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']}", response.authorization
|
|
55
|
+
assert response.test?
|
|
57
56
|
end
|
|
58
57
|
|
|
59
|
-
def
|
|
60
|
-
@
|
|
58
|
+
def test_unsuccessful_authorization
|
|
59
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_authorization_response)
|
|
61
60
|
|
|
62
|
-
assert response = @gateway.purchase(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
assert_equal false, response.success?
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def test_purchase_exceptions
|
|
69
|
-
@creditcard.number = 3
|
|
70
|
-
|
|
71
|
-
assert_raise(Error) do
|
|
72
|
-
assert response = @gateway.purchase(100, @creditcard, @options)
|
|
73
|
-
end
|
|
61
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
62
|
+
assert_instance_of Response, response
|
|
63
|
+
assert_failure response
|
|
74
64
|
end
|
|
75
65
|
|
|
76
66
|
def test_successful_auth_request
|
|
77
67
|
@gateway.stubs(:ssl_post).returns(successful_authorization_response)
|
|
78
|
-
assert response = @gateway.authorize(
|
|
68
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
79
69
|
assert_equal Response, response.class
|
|
80
70
|
assert response.success?
|
|
81
71
|
assert response.test?
|
|
@@ -83,7 +73,7 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
|
83
73
|
|
|
84
74
|
def test_successful_tax_request
|
|
85
75
|
@gateway.stubs(:ssl_post).returns(successful_tax_response)
|
|
86
|
-
assert response = @gateway.calculate_tax(@
|
|
76
|
+
assert response = @gateway.calculate_tax(@credit_card, @options)
|
|
87
77
|
assert_equal Response, response.class
|
|
88
78
|
assert response.success?
|
|
89
79
|
assert response.test?
|
|
@@ -91,38 +81,60 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
|
91
81
|
|
|
92
82
|
def test_successful_capture_request
|
|
93
83
|
@gateway.stubs(:ssl_post).returns(successful_authorization_response, successful_capture_response)
|
|
94
|
-
assert response = @gateway.authorize(
|
|
84
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
95
85
|
assert response.success?
|
|
96
86
|
assert response.test?
|
|
97
|
-
assert response_capture = @gateway.capture(
|
|
87
|
+
assert response_capture = @gateway.capture(@amount, response.authorization)
|
|
98
88
|
assert response_capture.success?
|
|
99
89
|
assert response_capture.test?
|
|
100
90
|
end
|
|
101
91
|
|
|
102
92
|
def test_successful_purchase_request
|
|
103
93
|
@gateway.stubs(:ssl_post).returns(successful_capture_response)
|
|
104
|
-
assert response = @gateway.purchase(
|
|
94
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
105
95
|
assert response.success?
|
|
106
96
|
assert response.test?
|
|
107
97
|
end
|
|
108
98
|
|
|
109
99
|
def test_requires_error_on_purchase_without_order_id
|
|
110
|
-
assert_raise(ArgumentError){ @gateway.purchase(
|
|
100
|
+
assert_raise(ArgumentError){ @gateway.purchase(@amount, @credit_card, @options.delete_if{|key, val| key == :order_id}) }
|
|
111
101
|
end
|
|
112
102
|
|
|
113
103
|
def test_requires_error_on_authorization_without_order_id
|
|
114
|
-
assert_raise(ArgumentError){ @gateway.purchase(
|
|
104
|
+
assert_raise(ArgumentError){ @gateway.purchase(@amount, @credit_card, @options.delete_if{|key, val| key == :order_id}) }
|
|
115
105
|
end
|
|
116
106
|
|
|
117
107
|
def test_requires_error_on_tax_calculation_without_line_items
|
|
118
|
-
assert_raise(ArgumentError){ @gateway.calculate_tax(@
|
|
108
|
+
assert_raise(ArgumentError){ @gateway.calculate_tax(@credit_card, @options.delete_if{|key, val| key == :line_items})}
|
|
119
109
|
end
|
|
120
110
|
|
|
121
111
|
def test_default_currency
|
|
122
112
|
assert_equal 'USD', CyberSourceGateway.default_currency
|
|
123
113
|
end
|
|
114
|
+
|
|
115
|
+
def test_avs_result
|
|
116
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
117
|
+
|
|
118
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
119
|
+
assert_equal 'Y', response.avs_result['code']
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def test_cvv_result
|
|
123
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
124
|
+
|
|
125
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
126
|
+
assert_equal 'M', response.cvv_result['code']
|
|
127
|
+
end
|
|
124
128
|
|
|
125
129
|
private
|
|
130
|
+
|
|
131
|
+
def successful_purchase_response
|
|
132
|
+
<<-XML
|
|
133
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
134
|
+
<soap:Header>
|
|
135
|
+
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-2636690"><wsu:Created>2008-01-15T21:42:03.343Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>b0a6cf9aa07f1a8495f89c364bbd6a9a</c:merchantReferenceCode><c:requestID>2004333231260008401927</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtT</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccAuthReply><c:reasonCode>100</c:reasonCode><c:amount>1.00</c:amount><c:authorizationCode>123456</c:authorizationCode><c:avsCode>Y</c:avsCode><c:avsCodeRaw>Y</c:avsCodeRaw><c:cvCode>M</c:cvCode><c:cvCodeRaw>M</c:cvCodeRaw><c:authorizedDateTime>2008-01-15T21:42:03Z</c:authorizedDateTime><c:processorResponse>00</c:processorResponse><c:authFactorCode>U</c:authFactorCode></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
|
|
136
|
+
XML
|
|
137
|
+
end
|
|
126
138
|
|
|
127
139
|
def successful_authorization_response
|
|
128
140
|
<<-XML
|
|
@@ -130,7 +142,14 @@ class CyberSourceTest < Test::Unit::TestCase
|
|
|
130
142
|
<soap:Header>
|
|
131
143
|
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-32551101"><wsu:Created>2007-07-12T18:31:53.838Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>TEST11111111111</c:merchantReferenceCode><c:requestID>1842651133440156177166</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccAuthReply><c:reasonCode>100</c:reasonCode><c:amount>1.00</c:amount><c:authorizationCode>004542</c:authorizationCode><c:avsCode>A</c:avsCode><c:avsCodeRaw>I7</c:avsCodeRaw><c:authorizedDateTime>2007-07-12T18:31:53Z</c:authorizedDateTime><c:processorResponse>100</c:processorResponse><c:reconciliationID>23439130C40VZ2FB</c:reconciliationID></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
|
|
132
144
|
XML
|
|
133
|
-
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def unsuccessful_authorization_response
|
|
148
|
+
<<-XML
|
|
149
|
+
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
|
150
|
+
<soap:Header>
|
|
151
|
+
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-28121162"><wsu:Created>2008-01-15T21:50:41.580Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>a1efca956703a2a5037178a8a28f7357</c:merchantReferenceCode><c:requestID>2004338415330008402434</c:requestID><c:decision>REJECT</c:decision><c:reasonCode>231</c:reasonCode><c:requestToken>Afvvj7KfIgU12gooCFE2/DanQIApt+G1OgTSA+R9PTnyhFTb0KRjgFY+ynyIFNdoKKAghwgx</c:requestToken><c:ccAuthReply><c:reasonCode>231</c:reasonCode></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
|
|
152
|
+
XML
|
|
134
153
|
end
|
|
135
154
|
|
|
136
155
|
def successful_tax_response
|
|
@@ -10,7 +10,54 @@ class DataCashTest < Test::Unit::TestCase
|
|
|
10
10
|
:password => 'PASSWORD'
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
@
|
|
13
|
+
@credit_card = credit_card('4242424242424242')
|
|
14
|
+
|
|
15
|
+
@address = {
|
|
16
|
+
:name => 'Mark McBride',
|
|
17
|
+
:address1 => 'Flat 12/3',
|
|
18
|
+
:address2 => '45 Main Road',
|
|
19
|
+
:city => 'London',
|
|
20
|
+
:state => 'None',
|
|
21
|
+
:country => 'GBR',
|
|
22
|
+
:zip => 'A987AA',
|
|
23
|
+
:phone => '(555)555-5555'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@options = {
|
|
27
|
+
:order_id => generate_unique_id,
|
|
28
|
+
:billing_address => @address
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_successful_purchase
|
|
33
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
34
|
+
|
|
35
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
36
|
+
assert_instance_of Response, response
|
|
37
|
+
assert_success response
|
|
38
|
+
assert response.test?
|
|
39
|
+
assert_equal 'The transaction was successful', response.message
|
|
40
|
+
assert_equal '4400200050664928;123456789', response.authorization
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_unsuccessful_purchase
|
|
44
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
|
45
|
+
|
|
46
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
47
|
+
assert_instance_of Response, response
|
|
48
|
+
assert_failure response
|
|
49
|
+
assert response.test?
|
|
50
|
+
assert_equal 'Invalid reference number', response.message
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_error_
|
|
54
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
|
55
|
+
|
|
56
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
57
|
+
assert_instance_of Response, response
|
|
58
|
+
assert_failure response
|
|
59
|
+
assert response.test?
|
|
60
|
+
assert_equal 'Invalid reference number', response.message
|
|
14
61
|
end
|
|
15
62
|
|
|
16
63
|
def test_supported_countries
|
|
@@ -20,4 +67,38 @@ class DataCashTest < Test::Unit::TestCase
|
|
|
20
67
|
def test_supported_card_types
|
|
21
68
|
assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
|
|
22
69
|
end
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
def failed_purchase_response
|
|
73
|
+
<<-XML
|
|
74
|
+
<Response>
|
|
75
|
+
<status>22</status>
|
|
76
|
+
<time>1196414665</time>
|
|
77
|
+
<mode>TEST</mode>
|
|
78
|
+
<country>United Kingdom</country>
|
|
79
|
+
<merchantreference>2d24cc91284c1ed5c65d8821f1e752c7</merchantreference>
|
|
80
|
+
<issuer>Clydesdale Bank PLC</issuer>
|
|
81
|
+
<reason>Invalid reference number</reason>
|
|
82
|
+
<card_scheme>Solo</card_scheme>
|
|
83
|
+
<datacash_reference>4400200050664928</datacash_reference>
|
|
84
|
+
</Response>
|
|
85
|
+
XML
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def successful_purchase_response
|
|
89
|
+
<<-XML
|
|
90
|
+
<Response>
|
|
91
|
+
<status>1</status>
|
|
92
|
+
<time>1196414665</time>
|
|
93
|
+
<mode>TEST</mode>
|
|
94
|
+
<country>United Kingdom</country>
|
|
95
|
+
<merchantreference>2d24cc91284c1ed5c65d8821f1e752c7</merchantreference>
|
|
96
|
+
<issuer>Clydesdale Bank PLC</issuer>
|
|
97
|
+
<reason>The transaction was successful</reason>
|
|
98
|
+
<card_scheme>Visa</card_scheme>
|
|
99
|
+
<datacash_reference>4400200050664928</datacash_reference>
|
|
100
|
+
<authcode>123456789</authcode>
|
|
101
|
+
</Response>
|
|
102
|
+
XML
|
|
103
|
+
end
|
|
23
104
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
2
|
|
|
3
3
|
class EfsnetTest < Test::Unit::TestCase
|
|
4
|
-
AMOUNT = 100
|
|
5
4
|
|
|
6
5
|
def setup
|
|
7
6
|
@gateway = EfsnetGateway.new(
|
|
@@ -9,62 +8,116 @@ class EfsnetTest < Test::Unit::TestCase
|
|
|
9
8
|
:password => 'PASSWORD'
|
|
10
9
|
)
|
|
11
10
|
|
|
12
|
-
@
|
|
13
|
-
|
|
14
|
-
@
|
|
15
|
-
:address2 => 'Apt 1',
|
|
16
|
-
:company => 'Widgets Inc',
|
|
17
|
-
:city => 'Ottawa',
|
|
18
|
-
:state => 'ON',
|
|
19
|
-
:zip => 'K1C2N6',
|
|
20
|
-
:country => 'Canada',
|
|
21
|
-
:phone => '(555)555-5555'
|
|
22
|
-
}
|
|
23
|
-
@options = {:order_id => 1}
|
|
11
|
+
@credit_card = credit_card('4242424242424242')
|
|
12
|
+
@amount = 100
|
|
13
|
+
@options = { :order_id => 1, :billing_address => address }
|
|
24
14
|
end
|
|
25
15
|
|
|
26
|
-
def
|
|
27
|
-
@
|
|
28
|
-
|
|
16
|
+
def test_successful_purchase
|
|
17
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
18
|
+
|
|
19
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
20
|
+
assert_instance_of Response, response
|
|
29
21
|
assert_success response
|
|
30
|
-
assert_equal '5555', response.authorization
|
|
31
22
|
assert response.test?
|
|
23
|
+
assert_equal '100018347764;1.00', response.authorization
|
|
24
|
+
assert_equal 'Approved', response.message
|
|
25
|
+
|
|
32
26
|
end
|
|
33
27
|
|
|
34
|
-
def
|
|
35
|
-
@
|
|
36
|
-
|
|
28
|
+
def test_unsuccessful_purchase
|
|
29
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
30
|
+
|
|
31
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
32
|
+
assert_instance_of Response, response
|
|
37
33
|
assert_failure response
|
|
38
34
|
assert response.test?
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def test_request_error
|
|
42
|
-
@creditcard.number = 3
|
|
43
|
-
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, @options) }
|
|
35
|
+
assert_equal 'Declined', response.message
|
|
44
36
|
end
|
|
45
37
|
|
|
46
38
|
def test_authorize_is_valid_xml
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
params = {
|
|
40
|
+
:order_id => "order1",
|
|
41
|
+
:transaction_amount => "1.01",
|
|
42
|
+
:account_number => "4242424242424242",
|
|
43
|
+
:expiration_month => "12",
|
|
44
|
+
:expiration_year => "2029",
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
assert data = @gateway.send(:post_data, :credit_card_authorize, params)
|
|
48
|
+
assert REXML::Document.new(data)
|
|
57
49
|
end
|
|
58
50
|
|
|
59
51
|
def test_settle_is_valid_xml
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
params = {
|
|
53
|
+
:order_id => "order1",
|
|
54
|
+
:transaction_amount => "1.01",
|
|
55
|
+
:original_transaction_amount => "1.01",
|
|
56
|
+
:original_transaction_id => "1",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
assert data = @gateway.send(:post_data, :credit_card_settle, params)
|
|
60
|
+
assert REXML::Document.new(data)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_avs_result
|
|
64
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
65
|
+
|
|
66
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
67
|
+
assert_equal 'N', response.avs_result['code']
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_cvv_result
|
|
71
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
72
|
+
|
|
73
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
74
|
+
assert_equal 'M', response.cvv_result['code']
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
def successful_purchase_response
|
|
79
|
+
<<-XML
|
|
80
|
+
<?xml version="1.0"?>
|
|
81
|
+
<Reply>
|
|
82
|
+
<TransactionReply>
|
|
83
|
+
<ResponseCode>0</ResponseCode>
|
|
84
|
+
<ResultCode>00</ResultCode>
|
|
85
|
+
<ResultMessage>APPROVED</ResultMessage>
|
|
86
|
+
<TransactionID>100018347764</TransactionID>
|
|
87
|
+
<AVSResponseCode>N</AVSResponseCode>
|
|
88
|
+
<CVVResponseCode>M</CVVResponseCode>
|
|
89
|
+
<ApprovalNumber>123456</ApprovalNumber>
|
|
90
|
+
<AuthorizationNumber>123456</AuthorizationNumber>
|
|
91
|
+
<TransactionDate>080117</TransactionDate>
|
|
92
|
+
<TransactionTime>163222</TransactionTime>
|
|
93
|
+
<ReferenceNumber>1</ReferenceNumber>
|
|
94
|
+
<AccountNumber>XXXXXXXXXXXX2224</AccountNumber>
|
|
95
|
+
<TransactionAmount>1.00</TransactionAmount>
|
|
96
|
+
</TransactionReply>
|
|
97
|
+
</Reply>
|
|
98
|
+
XML
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def unsuccessful_purchase_response
|
|
102
|
+
<<-XML
|
|
103
|
+
<?xml version="1.0"?>
|
|
104
|
+
<Reply>
|
|
105
|
+
<TransactionReply>
|
|
106
|
+
<ResponseCode>256</ResponseCode>
|
|
107
|
+
<ResultCode>04</ResultCode>
|
|
108
|
+
<ResultMessage>DECLINED</ResultMessage>
|
|
109
|
+
<TransactionID>100018347784</TransactionID>
|
|
110
|
+
<AVSResponseCode>N</AVSResponseCode>
|
|
111
|
+
<CVVResponseCode/>
|
|
112
|
+
<ApprovalNumber/>
|
|
113
|
+
<AuthorizationNumber/>
|
|
114
|
+
<TransactionDate>080117</TransactionDate>
|
|
115
|
+
<TransactionTime>163946</TransactionTime>
|
|
116
|
+
<ReferenceNumber>1</ReferenceNumber>
|
|
117
|
+
<AccountNumber>XXXXXXXXXXXX2224</AccountNumber>
|
|
118
|
+
<TransactionAmount>1.56</TransactionAmount>
|
|
119
|
+
</TransactionReply>
|
|
120
|
+
</Reply>
|
|
121
|
+
XML
|
|
69
122
|
end
|
|
70
123
|
end
|