activemerchant 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +226 -0
- data/CONTRIBUTERS +52 -0
- data/README +34 -24
- data/Rakefile +152 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +3 -1
- data/lib/active_merchant/billing/credit_card.rb +21 -17
- data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
- data/lib/active_merchant/billing/gateway.rb +160 -44
- data/lib/active_merchant/billing/gateways.rb +2 -15
- data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
- data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
- data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
- data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
- data/lib/active_merchant/billing/gateways/eway.rb +77 -29
- data/lib/active_merchant/billing/gateways/exact.rb +230 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
- data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
- data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
- data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
- data/lib/active_merchant/billing/gateways/protx.rb +285 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
- data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
- data/lib/active_merchant/billing/gateways/realex.rb +212 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
- data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
- data/lib/active_merchant/billing/integrations/helper.rb +8 -1
- data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
- data/lib/active_merchant/billing/integrations/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +23 -5
- data/lib/active_merchant/lib/requires_parameters.rb +2 -2
- data/lib/active_merchant/lib/validateable.rb +1 -1
- data/lib/support/gateway_support.rb +45 -0
- data/lib/tasks/cia.rb +1 -1
- data/script/generate +14 -0
- data/script/generator/base.rb +45 -0
- data/script/generator/generator.rb +24 -0
- data/script/generator/generators/gateway/gateway_generator.rb +14 -0
- data/script/generator/generators/gateway/templates/gateway.rb +73 -0
- data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
- data/script/generator/generators/integration/integration_generator.rb +25 -0
- data/script/generator/generators/integration/templates/helper.rb +34 -0
- data/script/generator/generators/integration/templates/helper_test.rb +54 -0
- data/script/generator/generators/integration/templates/integration.rb +18 -0
- data/script/generator/generators/integration/templates/module_test.rb +9 -0
- data/script/generator/generators/integration/templates/notification.rb +100 -0
- data/script/generator/generators/integration/templates/notification_test.rb +41 -0
- data/script/generator/manifest.rb +20 -0
- data/test/extra/binding_of_caller.rb +80 -0
- data/test/extra/breakpoint.rb +547 -0
- data/test/fixtures.yml +251 -0
- data/test/remote_tests/remote_authorize_net_test.rb +113 -0
- data/test/remote_tests/remote_brain_tree_test.rb +78 -0
- data/test/remote_tests/remote_card_stream_test.rb +160 -0
- data/test/remote_tests/remote_cyber_source_test.rb +130 -0
- data/test/remote_tests/remote_data_cash_test.rb +155 -0
- data/test/remote_tests/remote_efsnet_test.rb +93 -0
- data/test/remote_tests/remote_eway_test.rb +71 -0
- data/test/remote_tests/remote_exact_test.rb +59 -0
- data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
- data/test/remote_tests/remote_linkpoint_test.rb +144 -0
- data/test/remote_tests/remote_moneris_test.rb +110 -0
- data/test/remote_tests/remote_net_registry_test.rb +120 -0
- data/test/remote_tests/remote_pay_junction_test.rb +162 -0
- data/test/remote_tests/remote_payflow_express_test.rb +50 -0
- data/test/remote_tests/remote_payflow_test.rb +241 -0
- data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
- data/test/remote_tests/remote_payment_express_test.rb +136 -0
- data/test/remote_tests/remote_paypal_express_test.rb +49 -0
- data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
- data/test/remote_tests/remote_paypal_test.rb +163 -0
- data/test/remote_tests/remote_plugnpay_test.rb +70 -0
- data/test/remote_tests/remote_protx_test.rb +184 -0
- data/test/remote_tests/remote_psigate_test.rb +87 -0
- data/test/remote_tests/remote_psl_card_test.rb +105 -0
- data/test/remote_tests/remote_quickpay_test.rb +182 -0
- data/test/remote_tests/remote_realex_test.rb +227 -0
- data/test/remote_tests/remote_secure_pay_test.rb +36 -0
- data/test/remote_tests/remote_trans_first_test.rb +37 -0
- data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
- data/test/remote_tests/remote_usa_epay_test.rb +57 -0
- data/test/remote_tests/remote_verifi_test.rb +107 -0
- data/test/remote_tests/remote_viaklix_test.rb +53 -0
- data/test/test_helper.rb +132 -0
- data/test/unit/base_test.rb +61 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +24 -0
- data/test/unit/credit_card_methods_test.rb +37 -0
- data/test/unit/credit_card_test.rb +365 -0
- data/test/unit/gateways/authorize_net_test.rb +140 -0
- data/test/unit/gateways/bogus_test.rb +43 -0
- data/test/unit/gateways/brain_tree_test.rb +77 -0
- data/test/unit/gateways/card_stream_test.rb +37 -0
- data/test/unit/gateways/cyber_source_test.rb +151 -0
- data/test/unit/gateways/data_cash_test.rb +23 -0
- data/test/unit/gateways/efsnet_test.rb +70 -0
- data/test/unit/gateways/eway_test.rb +105 -0
- data/test/unit/gateways/exact_test.rb +118 -0
- data/test/unit/gateways/gateway_test.rb +24 -0
- data/test/unit/gateways/linkpoint_test.rb +165 -0
- data/test/unit/gateways/moneris_test.rb +167 -0
- data/test/unit/gateways/net_registry_test.rb +478 -0
- data/test/unit/gateways/pay_junction_test.rb +61 -0
- data/test/unit/gateways/payflow_express_test.rb +165 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
- data/test/unit/gateways/payflow_test.rb +230 -0
- data/test/unit/gateways/payflow_uk_test.rb +68 -0
- data/test/unit/gateways/payment_express_test.rb +215 -0
- data/test/unit/gateways/paypal_express_test.rb +222 -0
- data/test/unit/gateways/paypal_test.rb +241 -0
- data/test/unit/gateways/plugnpay_test.rb +79 -0
- data/test/unit/gateways/protx_test.rb +110 -0
- data/test/unit/gateways/psigate_test.rb +110 -0
- data/test/unit/gateways/psl_card_test.rb +51 -0
- data/test/unit/gateways/quickpay_test.rb +125 -0
- data/test/unit/gateways/realex_test.rb +150 -0
- data/test/unit/gateways/secure_pay_test.rb +78 -0
- data/test/unit/gateways/trans_first_test.rb +125 -0
- data/test/unit/gateways/trust_commerce_test.rb +57 -0
- data/test/unit/gateways/usa_epay_test.rb +117 -0
- data/test/unit/gateways/verifi_test.rb +91 -0
- data/test/unit/gateways/viaklix_test.rb +72 -0
- data/test/unit/integrations/action_view_helper_test.rb +54 -0
- data/test/unit/integrations/bogus_module_test.rb +16 -0
- data/test/unit/integrations/chronopay_module_test.rb +9 -0
- data/test/unit/integrations/gestpay_module_test.rb +10 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/nochex_module_test.rb +9 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +41 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +9 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/response_test.rb +14 -0
- data/test/unit/validateable_test.rb +56 -0
- metadata +160 -7
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class PslCardTest < Test::Unit::TestCase
|
|
4
|
+
# 100 Cents
|
|
5
|
+
AMOUNT = 100
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@gateway = PslCardGateway.new(
|
|
9
|
+
:login => 'LOGIN',
|
|
10
|
+
:password => 'PASSWORD'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@creditcard = credit_card('4242424242424242')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_successful_purchase
|
|
17
|
+
@creditcard.number = 1
|
|
18
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, {})
|
|
19
|
+
assert_success response
|
|
20
|
+
assert_equal '5555', response.authorization
|
|
21
|
+
assert response.test?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_successful_authorization
|
|
25
|
+
@creditcard.number = 1
|
|
26
|
+
assert response = @gateway.authorize(AMOUNT, @creditcard, {})
|
|
27
|
+
assert_success response
|
|
28
|
+
assert_equal '5555', response.authorization
|
|
29
|
+
assert response.test?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_unsuccessful_request
|
|
33
|
+
@creditcard.number = 2
|
|
34
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, {})
|
|
35
|
+
assert_failure response
|
|
36
|
+
assert response.test?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_request_error
|
|
40
|
+
@creditcard.number = 3
|
|
41
|
+
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_supported_countries
|
|
45
|
+
assert_equal ['GB'], PslCardGateway.supported_countries
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_supported_card_types
|
|
49
|
+
assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ], PslCardGateway.supported_cardtypes
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class QuickpayTest < Test::Unit::TestCase
|
|
4
|
+
# 100 Cents
|
|
5
|
+
AMOUNT = 100
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@gateway = QuickpayGateway.new(
|
|
9
|
+
:login => 'LOGIN',
|
|
10
|
+
:password => 'PASSWORD'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@creditcard = CreditCard.new(
|
|
14
|
+
:number => '4242424242424242',
|
|
15
|
+
:month => 8,
|
|
16
|
+
:year => 2008,
|
|
17
|
+
:first_name => 'Longbob',
|
|
18
|
+
:last_name => 'Longsen'
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_successful_purchase
|
|
23
|
+
@creditcard.number = 1
|
|
24
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, {})
|
|
25
|
+
assert_success response
|
|
26
|
+
assert_equal '5555', response.authorization
|
|
27
|
+
assert response.test?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_successful_authorization
|
|
31
|
+
@creditcard.number = 1
|
|
32
|
+
assert response = @gateway.authorize(AMOUNT, @creditcard, {})
|
|
33
|
+
assert_success response
|
|
34
|
+
assert_equal '5555', response.authorization
|
|
35
|
+
assert response.test?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_unsuccessful_request
|
|
39
|
+
@creditcard.number = 2
|
|
40
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, {})
|
|
41
|
+
assert_failure response
|
|
42
|
+
assert response.test?
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_request_error
|
|
46
|
+
@creditcard.number = 3
|
|
47
|
+
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_parsing_response_with_errors
|
|
51
|
+
@gateway.expects(:ssl_post).returns(error_response)
|
|
52
|
+
|
|
53
|
+
response = @gateway.purchase(AMOUNT, @creditcard, :order_id => '1000')
|
|
54
|
+
assert_failure response
|
|
55
|
+
assert_equal '008', response.params['qpstat']
|
|
56
|
+
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']
|
|
57
|
+
assert_equal 'Missing/error in cardnumber, Missing/error in expirationdate, Missing/error in card verification data, Missing/error in amount, Missing/error in ordernum, and Missing/error in currency', response.message
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_merchant_error
|
|
61
|
+
@gateway.expects(:ssl_post).returns(merchant_error)
|
|
62
|
+
|
|
63
|
+
response = @gateway.purchase(AMOUNT, @creditcard, :order_id => '1000')
|
|
64
|
+
assert_failure response
|
|
65
|
+
assert_equal response.message, 'Missing/error in merchant'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_parsing_successful_response
|
|
69
|
+
@gateway.expects(:ssl_post).returns(successful_response)
|
|
70
|
+
|
|
71
|
+
response = @gateway.authorize(AMOUNT, @creditcard, :order_id => '1000')
|
|
72
|
+
|
|
73
|
+
assert_success response
|
|
74
|
+
assert_equal 'OK', response.message
|
|
75
|
+
|
|
76
|
+
assert_equal '2865261', response.authorization
|
|
77
|
+
assert_equal '000', response.params['qpstat']
|
|
78
|
+
assert_equal '000', response.params['pbsstat']
|
|
79
|
+
assert_equal '2865261', response.params['transaction']
|
|
80
|
+
assert_equal '070425223705', response.params['time']
|
|
81
|
+
assert_equal '104680', response.params['ordernum']
|
|
82
|
+
assert_equal 'cody@example.com', response.params['merchantemail']
|
|
83
|
+
assert_equal 'Visa', response.params['cardtype']
|
|
84
|
+
assert_equal AMOUNT.to_s, response.params['amount']
|
|
85
|
+
assert_equal 'OK', response.params['qpstatmsg']
|
|
86
|
+
assert_equal 'Shopify', response.params['merchant']
|
|
87
|
+
assert_equal '1110', response.params['msgtype']
|
|
88
|
+
assert_equal 'USD', response.params['currency']
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_supported_countries
|
|
92
|
+
assert_equal ['DK'], QuickpayGateway.supported_countries
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_supported_card_types
|
|
96
|
+
assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], QuickpayGateway.supported_cardtypes
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
private
|
|
101
|
+
|
|
102
|
+
def error_response
|
|
103
|
+
<<-XML
|
|
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
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def merchant_error
|
|
111
|
+
<<-XML
|
|
112
|
+
<?xml version='1.0' encoding='ISO-8859-1'?>
|
|
113
|
+
|
|
114
|
+
<values qpstat='008' qpstatmsg='Missing/error in merchant'/>
|
|
115
|
+
XML
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def successful_response
|
|
119
|
+
<<-XML
|
|
120
|
+
<?xml version='1.0' encoding='ISO-8859-1'?>
|
|
121
|
+
|
|
122
|
+
<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'/>
|
|
123
|
+
XML
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
require 'digest/sha1'
|
|
3
|
+
|
|
4
|
+
class RealexTest < Test::Unit::TestCase
|
|
5
|
+
AMOUNT = 100
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@login = 'your_merchant_id'
|
|
9
|
+
@password = 'your_secret'
|
|
10
|
+
|
|
11
|
+
@gateway = RealexGateway.new(
|
|
12
|
+
:login => @merchant_id,
|
|
13
|
+
:password => @secret,
|
|
14
|
+
:account => ''
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
@gateway_with_account = RealexGateway.new(
|
|
18
|
+
:login => @merchant_id,
|
|
19
|
+
:password => @secret,
|
|
20
|
+
:account => 'bill_web_cengal'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@creditcard = CreditCard.new(
|
|
24
|
+
:number => '4263971921001307',
|
|
25
|
+
:month => 8,
|
|
26
|
+
:year => 2008,
|
|
27
|
+
:first_name => 'Longbob',
|
|
28
|
+
:last_name => 'Longsen',
|
|
29
|
+
:type => 'visa'
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_in_test
|
|
35
|
+
assert_equal :test, ActiveMerchant::Billing::Base.gateway_mode
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_hash
|
|
39
|
+
result = Digest::SHA1.hexdigest("20061213105925.your_merchant_id.1.400.EUR.4263971921001307")
|
|
40
|
+
assert_equal "6bbce4d13f8e830401db4ee530eecb060bc50f64", result
|
|
41
|
+
|
|
42
|
+
#add the secret to the end
|
|
43
|
+
result = Digest::SHA1.hexdigest(result + "." + @password)
|
|
44
|
+
assert_equal "06a8b619cbd76024676401e5a83e7e5453521af3", result
|
|
45
|
+
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
|
+
|
|
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
|
+
def test_successful_purchase
|
|
69
|
+
@gateway.expects(:ssl_post).returns(successful_response)
|
|
70
|
+
|
|
71
|
+
response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
|
|
72
|
+
assert_success response
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_unsuccessful_purchase
|
|
76
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_response)
|
|
77
|
+
|
|
78
|
+
response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
|
|
79
|
+
assert_failure response
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_supported_countries
|
|
83
|
+
assert_equal ['IE', 'GB'], RealexGateway.supported_countries
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_supported_card_types
|
|
87
|
+
assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def successful_response
|
|
94
|
+
<<-RESPONSE
|
|
95
|
+
<response timestamp='20010427043422'>
|
|
96
|
+
<merchantid>your merchant id</merchantid>
|
|
97
|
+
<account>account to use</account>
|
|
98
|
+
<orderid>order id from request</orderid>
|
|
99
|
+
<authcode>authcode received</authcode>
|
|
100
|
+
<result>00</result>
|
|
101
|
+
<message>[ test system ] message returned from system</message>
|
|
102
|
+
<pasref> realex payments reference</pasref>
|
|
103
|
+
<cvnresult>M</cvnresult>
|
|
104
|
+
<batchid>batch id for this transaction (if any)</batchid>
|
|
105
|
+
<cardissuer>
|
|
106
|
+
<bank>Issuing Bank Name</bank>
|
|
107
|
+
<country>Issuing Bank Country</country>
|
|
108
|
+
<countrycode>Issuing Bank Country Code</countrycode>
|
|
109
|
+
<region>Issuing Bank Region</region>
|
|
110
|
+
</cardissuer>
|
|
111
|
+
<tss>
|
|
112
|
+
<result>89</result>
|
|
113
|
+
<check id="1000">9</check>
|
|
114
|
+
<check id="1001">9</check>
|
|
115
|
+
</tss>
|
|
116
|
+
<sha1hash>7384ae67....ac7d7d</sha1hash>
|
|
117
|
+
<md5hash>34e7....a77d</md5hash>
|
|
118
|
+
</response>"
|
|
119
|
+
RESPONSE
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def unsuccessful_response
|
|
123
|
+
<<-RESPONSE
|
|
124
|
+
<response timestamp='20010427043422'>
|
|
125
|
+
<merchantid>your merchant id</merchantid>
|
|
126
|
+
<account>account to use</account>
|
|
127
|
+
<orderid>order id from request</orderid>
|
|
128
|
+
<authcode>authcode received</authcode>
|
|
129
|
+
<result>01</result>
|
|
130
|
+
<message>message returned from system</message>
|
|
131
|
+
<pasref> realex payments reference</pasref>
|
|
132
|
+
<cvnresult>M</cvnresult>
|
|
133
|
+
<batchid>batch id for this transaction (if any)</batchid>
|
|
134
|
+
<cardissuer>
|
|
135
|
+
<bank>Issuing Bank Name</bank>
|
|
136
|
+
<country>Issuing Bank Country</country>
|
|
137
|
+
<countrycode>Issuing Bank Country Code</countrycode>
|
|
138
|
+
<region>Issuing Bank Region</region>
|
|
139
|
+
</cardissuer>
|
|
140
|
+
<tss>
|
|
141
|
+
<result>89</result>
|
|
142
|
+
<check id="1000">9</check>
|
|
143
|
+
<check id="1001">9</check>
|
|
144
|
+
</tss>
|
|
145
|
+
<sha1hash>7384ae67....ac7d7d</sha1hash>
|
|
146
|
+
<md5hash>34e7....a77d</md5hash>
|
|
147
|
+
</response>"
|
|
148
|
+
RESPONSE
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class SecurePayTest < Test::Unit::TestCase
|
|
4
|
+
include ActiveMerchant::Billing
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@gateway = SecurePayGateway.new(
|
|
8
|
+
:login => 'X',
|
|
9
|
+
:password => 'Y'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@creditcard = CreditCard.new(
|
|
13
|
+
:number => '4242424242424242',
|
|
14
|
+
:month => 8,
|
|
15
|
+
:year => 2006,
|
|
16
|
+
:first_name => 'Longbob',
|
|
17
|
+
:last_name => 'Longsen'
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_failed_purchase
|
|
22
|
+
@gateway.stubs(:ssl_post).returns(failure_response)
|
|
23
|
+
|
|
24
|
+
assert response = @gateway.purchase(100, @creditcard,
|
|
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
|
+
)
|
|
37
|
+
assert_failure response
|
|
38
|
+
assert response.test?
|
|
39
|
+
assert_equal 'This transaction has been declined', response.message
|
|
40
|
+
assert_equal '3377475', response.authorization
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_successful_purchase
|
|
44
|
+
@gateway.stubs(:ssl_post).returns(successful_purchase_response)
|
|
45
|
+
|
|
46
|
+
assert response = @gateway.purchase(100, @creditcard,
|
|
47
|
+
:order_id => generate_order_id,
|
|
48
|
+
:description => 'Store purchase'
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
assert_success response
|
|
52
|
+
assert response.test?
|
|
53
|
+
assert_equal 'This transaction has been approved', response.message
|
|
54
|
+
assert response.authorization
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_undefine_unsupported_methods
|
|
58
|
+
assert @gateway.respond_to?(:purchase)
|
|
59
|
+
|
|
60
|
+
[ :authorize, :capture, :void, :credit ].each do |m|
|
|
61
|
+
assert !@gateway.respond_to?(m)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def successful_purchase_response
|
|
68
|
+
'1%%1%This transaction has been approved.%100721%X%3377575%f6af895031c07d88399ed9fdb48c8476%Store+purchase%0.01%%AUTH_CAPTURE%%Cody%Fauser%%100+Example+St.%Ottawa%ON%K2A5P7%Canada%%%%%%%%%%%%%%%%%%%'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def failure_response
|
|
72
|
+
'2%%2%This transaction has been declined.%NOT APPROVED%U%3377475%55adbbaed13aa7e2526846d672fdb594%Store+purchase%1.00%%AUTH_CAPTURE%%Longbob%Longsen%%1234+Test+St.%Ottawa%ON%K1N5P8%Canada%%%%%%%%%%%%%%%%%%%'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def failed_capture_response
|
|
76
|
+
'3%%6%The credit card number is invalid.%%%%%%0.01%%PRIOR_AUTH_CAPTURE%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
|
2
|
+
|
|
3
|
+
class TransFirstTest < Test::Unit::TestCase
|
|
4
|
+
AMOUNT = 100
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@gateway = TransFirstGateway.new(
|
|
8
|
+
:login => 'LOGIN',
|
|
9
|
+
:password => 'PASSWORD'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
@creditcard = credit_card('4242424242424242')
|
|
13
|
+
|
|
14
|
+
@address = { :address1 => '1234 My Street',
|
|
15
|
+
:address2 => 'Apt 1',
|
|
16
|
+
:company => 'Widgets Inc',
|
|
17
|
+
:city => 'Ottawa',
|
|
18
|
+
:state => 'ON',
|
|
19
|
+
:zip => 'K1C2N6',
|
|
20
|
+
:country => 'Canada',
|
|
21
|
+
:phone => '(555)555-5555'
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_successful_request
|
|
26
|
+
@creditcard.number = 1
|
|
27
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, {})
|
|
28
|
+
assert_success response
|
|
29
|
+
assert_equal '5555', response.authorization
|
|
30
|
+
assert response.test?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_unsuccessful_request
|
|
34
|
+
@creditcard.number = 2
|
|
35
|
+
assert response = @gateway.purchase(AMOUNT, @creditcard, {})
|
|
36
|
+
assert_failure response
|
|
37
|
+
assert response.test?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_request_error
|
|
41
|
+
@creditcard.number = 3
|
|
42
|
+
assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_missing_field_response
|
|
46
|
+
@gateway.stubs(:ssl_post).returns(missing_field_response)
|
|
47
|
+
|
|
48
|
+
response = @gateway.purchase(AMOUNT, @creditcard)
|
|
49
|
+
|
|
50
|
+
assert_failure response
|
|
51
|
+
assert response.test?
|
|
52
|
+
assert_equal 'Missing parameter: UserId.', response.message
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_successful_purchase
|
|
56
|
+
@gateway.stubs(:ssl_post).returns(successful_purchase_response)
|
|
57
|
+
|
|
58
|
+
response = @gateway.purchase(AMOUNT, @creditcard)
|
|
59
|
+
|
|
60
|
+
assert_success response
|
|
61
|
+
assert response.test?
|
|
62
|
+
assert_equal 'test transaction', response.message
|
|
63
|
+
assert_equal '355', response.authorization
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_failed_purchase
|
|
67
|
+
@gateway.stubs(:ssl_post).returns(failed_purchase_response)
|
|
68
|
+
|
|
69
|
+
response = @gateway.purchase(AMOUNT, @creditcard)
|
|
70
|
+
|
|
71
|
+
assert_failure response
|
|
72
|
+
assert response.test?
|
|
73
|
+
assert_equal '29005716', response.authorization
|
|
74
|
+
assert_equal 'Invalid cardholder number', response.message
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
def missing_field_response
|
|
79
|
+
"Missing parameter: UserId.\r\n"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def successful_purchase_response
|
|
83
|
+
<<-XML
|
|
84
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
85
|
+
<CCSaleDebitResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.paymentresources.com/webservices/">
|
|
86
|
+
<TransID>355</TransID>
|
|
87
|
+
<RefID>c2535abbf0bb38005a14fd575553df65</RefID>
|
|
88
|
+
<Amount>1.00</Amount>
|
|
89
|
+
<AuthCode>Test00</AuthCode>
|
|
90
|
+
<Status>Authorized</Status>
|
|
91
|
+
<AVSCode />
|
|
92
|
+
<Message>test transaction</Message>
|
|
93
|
+
<CVV2Code />
|
|
94
|
+
<ACI />
|
|
95
|
+
<AuthSource />
|
|
96
|
+
<TransactionIdentifier />
|
|
97
|
+
<ValidationCode />
|
|
98
|
+
<CAVVResultCode />
|
|
99
|
+
</CCSaleDebitResponse>
|
|
100
|
+
XML
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def failed_purchase_response
|
|
104
|
+
<<-XML
|
|
105
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
|
106
|
+
<CCSaleDebitResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.paymentresources.com/webservices/">
|
|
107
|
+
<TransID>29005716</TransID>
|
|
108
|
+
<RefID>0610</RefID>
|
|
109
|
+
<PostedDate>2005-09-29T15:16:23.7297658-07:00</PostedDate>
|
|
110
|
+
<SettledDate>2005-09-29T15:16:23.9641468-07:00</SettledDate>
|
|
111
|
+
<Amount>0.02</Amount>
|
|
112
|
+
<AuthCode />
|
|
113
|
+
<Status>Declined</Status>
|
|
114
|
+
<AVSCode />
|
|
115
|
+
<Message>Invalid cardholder number</Message>
|
|
116
|
+
<CVV2Code />
|
|
117
|
+
<ACI />
|
|
118
|
+
<AuthSource />
|
|
119
|
+
<TransactionIdentifier />
|
|
120
|
+
<ValidationCode />
|
|
121
|
+
<CAVVResultCode />
|
|
122
|
+
</CCSaleDebitResponse>
|
|
123
|
+
XML
|
|
124
|
+
end
|
|
125
|
+
end
|