activemerchant 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,70 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class PlugnpayTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Billing
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@gateway = PlugnpayGateway.new(fixtures(:plugnpay))
|
8
|
+
@good_creditcard = credit_card('4242424242424242')
|
9
|
+
@bad_creditcard = credit_card('1234123412341234')
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_bad_credit_card
|
13
|
+
assert response = @gateway.authorize(1000, @bad_creditcard)
|
14
|
+
assert_failure response
|
15
|
+
assert_equal 'Invalid Credit Card No.', response.message
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_good_credit_card
|
19
|
+
assert response = @gateway.authorize(1000, @good_creditcard)
|
20
|
+
assert_success response
|
21
|
+
assert !response.authorization.blank?
|
22
|
+
assert_equal 'Success', response.message
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_purchase_transaction
|
26
|
+
assert response = @gateway.purchase(1000, @good_creditcard)
|
27
|
+
assert_success response
|
28
|
+
assert !response.authorization.blank?
|
29
|
+
assert_equal 'Success', response.message
|
30
|
+
end
|
31
|
+
|
32
|
+
# Capture, and Void require that you Whitelist your IP address.
|
33
|
+
# In the gateway admin tool, you must add your IP address to the allowed addresses and uncheck "Remote client" under the
|
34
|
+
# "Auth Transactions" section of the "Security Requirements" area in the test account Security Administration Area.
|
35
|
+
def test_authorization_and_capture
|
36
|
+
assert authorization = @gateway.authorize(100, @good_creditcard)
|
37
|
+
assert_success authorization
|
38
|
+
|
39
|
+
assert capture = @gateway.capture(100, authorization.authorization)
|
40
|
+
assert_success capture
|
41
|
+
assert_equal 'Success', capture.message
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_authorization_and_void
|
45
|
+
assert authorization = @gateway.authorize(100, @good_creditcard)
|
46
|
+
assert_success authorization
|
47
|
+
|
48
|
+
assert void = @gateway.void(authorization.authorization)
|
49
|
+
assert_success void
|
50
|
+
assert_equal 'Success', void.message
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_purchase_and_credit
|
54
|
+
amount = 100
|
55
|
+
|
56
|
+
assert purchase = @gateway.purchase(amount, @good_creditcard)
|
57
|
+
assert_success purchase
|
58
|
+
|
59
|
+
assert credit = @gateway.credit(amount, purchase.authorization)
|
60
|
+
assert_success credit
|
61
|
+
assert_equal 'Success', credit.message
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_credit_with_no_previous_transaction
|
65
|
+
assert credit = @gateway.credit(100, @good_creditcard)
|
66
|
+
|
67
|
+
assert_success credit
|
68
|
+
assert_equal 'Success', credit.message
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
# Some of the standard tests have been removed at Protx test
|
4
|
+
# server is pants and accepts anything and says Status=OK. (shift)
|
5
|
+
class RemoteProtxTest < Test::Unit::TestCase
|
6
|
+
include ActiveMerchant::Billing
|
7
|
+
|
8
|
+
# Run the tests in the simulated environment
|
9
|
+
# set to false to run the tests in the test environment
|
10
|
+
ProtxGateway.simulate = true
|
11
|
+
|
12
|
+
AMOUNT = 100
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@gateway = ProtxGateway.new(fixtures(:protx))
|
16
|
+
|
17
|
+
@amex = CreditCard.new(
|
18
|
+
:number => '374245455400001',
|
19
|
+
:month => 12,
|
20
|
+
:year => 2009,
|
21
|
+
:verification_value => 4887,
|
22
|
+
:first_name => 'Longbob',
|
23
|
+
:last_name => 'Longsen',
|
24
|
+
:type => :american_express
|
25
|
+
)
|
26
|
+
|
27
|
+
@maestro = CreditCard.new(
|
28
|
+
:number => '6759016800000120097',
|
29
|
+
:month => 6,
|
30
|
+
:year => 2009,
|
31
|
+
:issue_number => 1,
|
32
|
+
:verification_value => 701,
|
33
|
+
:first_name => 'Longbob',
|
34
|
+
:last_name => 'Longsen',
|
35
|
+
:type => :maestro
|
36
|
+
)
|
37
|
+
|
38
|
+
@solo = CreditCard.new(
|
39
|
+
:number => '6334960300099354',
|
40
|
+
:month => 6,
|
41
|
+
:year => 2008,
|
42
|
+
:issue_number => 1,
|
43
|
+
:verification_value => 227,
|
44
|
+
:first_name => 'Longbob',
|
45
|
+
:last_name => 'Longsen',
|
46
|
+
:type => :solo
|
47
|
+
)
|
48
|
+
|
49
|
+
@mastercard = CreditCard.new(
|
50
|
+
:number => '5301250070000191',
|
51
|
+
:month => 12,
|
52
|
+
:year => 2009,
|
53
|
+
:verification_value => 419,
|
54
|
+
:first_name => 'Longbob',
|
55
|
+
:last_name => 'Longsen',
|
56
|
+
:type => :master
|
57
|
+
)
|
58
|
+
|
59
|
+
@declined_card = CreditCard.new(
|
60
|
+
:number => '4000300011112220',
|
61
|
+
:month => 9,
|
62
|
+
:year => 2009,
|
63
|
+
:first_name => 'Longbob',
|
64
|
+
:last_name => 'Longsen'
|
65
|
+
)
|
66
|
+
|
67
|
+
@electron = credit_card('4917300000000008',
|
68
|
+
:type => 'electron',
|
69
|
+
:verification_value => '123'
|
70
|
+
)
|
71
|
+
|
72
|
+
@mastercard_options = {
|
73
|
+
:address => { :address1 => '25 The Larches',
|
74
|
+
:city => "Narborough",
|
75
|
+
:state => "Leicester",
|
76
|
+
:zip => 'LE10 2RT'
|
77
|
+
},
|
78
|
+
:order_id => generate_order_id,
|
79
|
+
:description => 'Store purchase'
|
80
|
+
}
|
81
|
+
|
82
|
+
@maestro_options = {
|
83
|
+
:address => { :address1 => 'The Parkway',
|
84
|
+
:address2 => "Larches Approach",
|
85
|
+
:city => "Hull",
|
86
|
+
:state => "North Humberside",
|
87
|
+
:zip => 'HU7 9OP'
|
88
|
+
},
|
89
|
+
:order_id => generate_order_id,
|
90
|
+
:description => 'Store purchase'
|
91
|
+
}
|
92
|
+
|
93
|
+
@solo_options = {
|
94
|
+
:address => {
|
95
|
+
:address1 => '5 Zigzag Road',
|
96
|
+
:city => 'Isleworth',
|
97
|
+
:state => 'Middlesex',
|
98
|
+
:zip => 'TW7 8FF'
|
99
|
+
},
|
100
|
+
:order_id => generate_order_id,
|
101
|
+
:description => 'Store purchase'
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_successful_mastercard_purchase
|
106
|
+
assert response = @gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
|
107
|
+
assert_success response
|
108
|
+
assert response.test?
|
109
|
+
assert !response.authorization.blank?
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_successful_authorization_and_capture
|
113
|
+
assert auth = @gateway.authorize(AMOUNT, @mastercard, @mastercard_options)
|
114
|
+
assert_success auth
|
115
|
+
|
116
|
+
assert capture = @gateway.capture(AMOUNT, auth.authorization)
|
117
|
+
assert_success capture
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_successful_authorization_and_void
|
121
|
+
assert auth = @gateway.authorize(AMOUNT, @mastercard, @mastercard_options)
|
122
|
+
assert_success auth
|
123
|
+
|
124
|
+
assert void = @gateway.void(auth.authorization)
|
125
|
+
assert_success void
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_successful_purchase_and_void
|
129
|
+
assert purchase = @gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
|
130
|
+
assert_success purchase
|
131
|
+
|
132
|
+
assert void = @gateway.void(purchase.authorization)
|
133
|
+
assert_success void
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_successful_purchase_and_credit
|
137
|
+
assert purchase = @gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
|
138
|
+
assert_success purchase
|
139
|
+
|
140
|
+
assert credit = @gateway.credit(AMOUNT, purchase.authorization,
|
141
|
+
:description => 'Crediting trx',
|
142
|
+
:order_id => generate_order_id
|
143
|
+
)
|
144
|
+
|
145
|
+
assert_success credit
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_successful_maestro_purchase
|
149
|
+
assert response = @gateway.purchase(AMOUNT, @maestro, @maestro_options)
|
150
|
+
assert_success response
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_successful_solo_purchase
|
154
|
+
assert response = @gateway.purchase(AMOUNT, @solo, @solo_options)
|
155
|
+
assert_success response
|
156
|
+
assert response.test?
|
157
|
+
assert !response.authorization.blank?
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_successful_amex_purchase
|
161
|
+
assert response = @gateway.purchase(AMOUNT, @amex, :order_id => generate_order_id)
|
162
|
+
assert_success response
|
163
|
+
assert response.test?
|
164
|
+
assert !response.authorization.blank?
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_successful_electron_purchase
|
168
|
+
assert response = @gateway.purchase(AMOUNT, @electron, :order_id => generate_order_id)
|
169
|
+
assert_success response
|
170
|
+
assert response.test?
|
171
|
+
assert !response.authorization.blank?
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_invalid_login
|
175
|
+
message = ProtxGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.'
|
176
|
+
|
177
|
+
gateway = ProtxGateway.new(
|
178
|
+
:login => ''
|
179
|
+
)
|
180
|
+
assert response = gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
|
181
|
+
assert_equal message, response.message
|
182
|
+
assert_failure response
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class PsigateRemoteTest < Test::Unit::TestCase
|
4
|
+
# set up order numbers as contants because even a test credit must match an
|
5
|
+
# existing purchase in psigate's test system
|
6
|
+
ORDER_NUM1 = Time.now.to_i.to_s
|
7
|
+
ORDER_NUM2 = (Time.now.to_i + 1).to_s
|
8
|
+
ORDER_NUM3 = (Time.now.to_i + 2).to_s
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Base.gateway_mode = :test
|
12
|
+
@gateway = PsigateGateway.new(fixtures(:psigate))
|
13
|
+
|
14
|
+
@creditcard = credit_card('4242424242424242')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_remote_authorize
|
18
|
+
assert response = @gateway.authorize(2400, @creditcard,
|
19
|
+
:order_id => ORDER_NUM1,
|
20
|
+
:billing_address => {
|
21
|
+
:address1 => '123 fairweather Lane',
|
22
|
+
:address2 => 'Apt B',
|
23
|
+
:city => 'New York',
|
24
|
+
:state => 'NY',
|
25
|
+
:country => 'U.S.A.',
|
26
|
+
:zip => '10010'},
|
27
|
+
:email => 'jack@yahoo.com'
|
28
|
+
)
|
29
|
+
assert_equal Response, response.class
|
30
|
+
assert_equal true, response.success?
|
31
|
+
assert_equal "APPROVED", response.params["approved"]
|
32
|
+
assert_equal ORDER_NUM1, response.authorization
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_remote_capture
|
36
|
+
assert response = @gateway.capture(2400, ORDER_NUM1 )
|
37
|
+
assert_equal Response, response.class
|
38
|
+
assert_equal true, response.success?
|
39
|
+
assert_equal "APPROVED", response.params["approved"]
|
40
|
+
assert_equal "APPROVED", response.params["approved"]
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# named test_remote_apurchase (with an a) so that it executes prior to the
|
45
|
+
# test_remote_credit method. Otherwise the credit won't reference an existing
|
46
|
+
# purchase and the test will fail
|
47
|
+
def test_remote_apurchase
|
48
|
+
assert response = @gateway.purchase(2400, @creditcard, {:order_id => ORDER_NUM2,
|
49
|
+
:billing_address => {
|
50
|
+
:address1 => '123 fairweather Lane',
|
51
|
+
:address2 => 'Apt B',
|
52
|
+
:city => 'New York',
|
53
|
+
:state => 'NY',
|
54
|
+
:country => 'U.S.A.',
|
55
|
+
:zip => '10010'},
|
56
|
+
:email => 'jack@yahoo.com'
|
57
|
+
})
|
58
|
+
assert_equal Response, response.class
|
59
|
+
assert_equal true, response.success?
|
60
|
+
assert_equal "APPROVED", response.params["approved"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_remote_credit
|
64
|
+
assert response = @gateway.credit(2400, ORDER_NUM2)
|
65
|
+
assert_equal Response, response.class
|
66
|
+
assert_equal true, response.success?
|
67
|
+
assert_equal "APPROVED", response.params["approved"]
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_remote_decline
|
71
|
+
assert response = @gateway.purchase(2400, @creditcard, {:order_id => ORDER_NUM3,
|
72
|
+
:billing_address => {
|
73
|
+
:address1 => '123 fairweather Lane',
|
74
|
+
:address2 => 'Apt B',
|
75
|
+
:city => 'New York',
|
76
|
+
:state => 'NY',
|
77
|
+
:country => 'U.S.A.',
|
78
|
+
:zip => '10010'},
|
79
|
+
:email => 'jack@yahoo.com',
|
80
|
+
:test_result => 'D'
|
81
|
+
})
|
82
|
+
assert_equal Response, response.class
|
83
|
+
assert_equal false, response.success?
|
84
|
+
assert_equal "DECLINED", response.params["approved"]
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# Author:: MoneySpyder, http://moneyspyder.co.uk
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
+
|
5
|
+
class RemotePslCardTest < Test::Unit::TestCase
|
6
|
+
# The test results are determined by the amount of the transaction
|
7
|
+
ACCEPT_AMOUNT = 1000
|
8
|
+
REFERRED_AMOUNT = 6000
|
9
|
+
DECLINED_AMOUNT = 11000
|
10
|
+
KEEP_CARD_AMOUNT = 15000
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@gateway = PslCardGateway.new(fixtures(:psl_card))
|
14
|
+
|
15
|
+
@uk_maestro = CreditCard.new(fixtures(:psl_maestro))
|
16
|
+
@uk_maestro_address = fixtures(:psl_maestro_address)
|
17
|
+
|
18
|
+
@solo = CreditCard.new(fixtures(:psl_solo))
|
19
|
+
@solo_address = fixtures(:psl_solo_address)
|
20
|
+
|
21
|
+
@visa = CreditCard.new(fixtures(:psl_visa))
|
22
|
+
@visa_address = fixtures(:psl_visa_address)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_successful_visa_purchase
|
26
|
+
response = @gateway.purchase(ACCEPT_AMOUNT, @visa,
|
27
|
+
:address => @visa_address
|
28
|
+
)
|
29
|
+
assert_success response
|
30
|
+
assert response.test?
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_successful_visa_purchase_specifying_currency
|
34
|
+
response = @gateway.purchase(ACCEPT_AMOUNT, @visa,
|
35
|
+
:address => @visa_address,
|
36
|
+
:currency => 'GBP'
|
37
|
+
)
|
38
|
+
assert_success response
|
39
|
+
assert response.test?
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_successful_solo_purchase
|
43
|
+
response = @gateway.purchase(ACCEPT_AMOUNT, @solo,
|
44
|
+
:address => @solo_address
|
45
|
+
)
|
46
|
+
assert_success response
|
47
|
+
assert response.test?
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_referred_purchase
|
51
|
+
response = @gateway.purchase(REFERRED_AMOUNT, @uk_maestro,
|
52
|
+
:address => @uk_maestro_address
|
53
|
+
)
|
54
|
+
assert_failure response
|
55
|
+
assert response.test?
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_declined_purchase
|
59
|
+
response = @gateway.purchase(DECLINED_AMOUNT, @uk_maestro,
|
60
|
+
:address => @uk_maestro_address
|
61
|
+
)
|
62
|
+
assert_failure response
|
63
|
+
assert response.test?
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_declined_keep_card_purchase
|
67
|
+
response = @gateway.purchase(KEEP_CARD_AMOUNT, @uk_maestro,
|
68
|
+
:address => @uk_maestro_address
|
69
|
+
)
|
70
|
+
assert_failure response
|
71
|
+
assert response.test?
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_successful_authorization
|
75
|
+
response = @gateway.authorize(ACCEPT_AMOUNT, @uk_maestro,
|
76
|
+
:address => @uk_maestro_address
|
77
|
+
)
|
78
|
+
assert_success response
|
79
|
+
assert response.test?
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_no_login
|
83
|
+
@gateway = PslCardGateway.new(
|
84
|
+
:login => ''
|
85
|
+
)
|
86
|
+
response = @gateway.authorize(ACCEPT_AMOUNT, @uk_maestro,
|
87
|
+
:address => @uk_maestro_address
|
88
|
+
)
|
89
|
+
assert_failure response
|
90
|
+
assert response.test?
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_successful_authorization_and_capture
|
94
|
+
authorization = @gateway.authorize(ACCEPT_AMOUNT, @uk_maestro,
|
95
|
+
:address => @uk_maestro_address
|
96
|
+
)
|
97
|
+
assert_success authorization
|
98
|
+
assert authorization.test?
|
99
|
+
|
100
|
+
capture = @gateway.capture(ACCEPT_AMOUNT, authorization.authorization)
|
101
|
+
|
102
|
+
assert_success capture
|
103
|
+
assert capture.test?
|
104
|
+
end
|
105
|
+
end
|