smulube-activemerchant 1.5.1.1 → 1.5.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Rakefile +85 -0
- data/generators/gateway/USAGE +5 -0
- data/generators/gateway/gateway_generator.rb +61 -0
- data/generators/gateway/templates/gateway.rb +77 -0
- data/generators/gateway/templates/gateway_test.rb +49 -0
- data/generators/gateway/templates/remote_gateway_test.rb +57 -0
- data/generators/integration/USAGE +5 -0
- data/generators/integration/integration_generator.rb +68 -0
- data/generators/integration/templates/helper.rb +34 -0
- data/generators/integration/templates/helper_test.rb +54 -0
- data/generators/integration/templates/integration.rb +18 -0
- data/generators/integration/templates/module_test.rb +9 -0
- data/generators/integration/templates/notification.rb +100 -0
- data/generators/integration/templates/notification_test.rb +41 -0
- data/init.rb +3 -0
- data/lib/active_merchant/billing/gateways/payflow_nvp_uk.rb +18 -11
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +1 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/fixtures.yml +355 -0
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +460 -0
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
- data/test/remote/gateways/remote_beanstream_test.rb +150 -0
- data/test/remote/gateways/remote_braintree_test.rb +147 -0
- data/test/remote/gateways/remote_card_stream_test.rb +148 -0
- data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
- data/test/remote/gateways/remote_data_cash_test.rb +356 -0
- data/test/remote/gateways/remote_efsnet_test.rb +81 -0
- data/test/remote/gateways/remote_elavon_test.rb +66 -0
- data/test/remote/gateways/remote_eway_test.rb +74 -0
- data/test/remote/gateways/remote_exact_test.rb +60 -0
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_instapay_test.rb +61 -0
- data/test/remote/gateways/remote_jetpay_test.rb +103 -0
- data/test/remote/gateways/remote_linkpoint_test.rb +121 -0
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
- data/test/remote/gateways/remote_modern_payments_test.rb +57 -0
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/remote/gateways/remote_net_registry_test.rb +85 -0
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/remote/gateways/remote_ogone_test.rb +115 -0
- data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
- data/test/remote/gateways/remote_payflow_nvp_uk_test.rb +57 -0
- data/test/remote/gateways/remote_payflow_test.rb +237 -0
- data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
- data/test/remote/gateways/remote_payment_express_test.rb +136 -0
- data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
- data/test/remote/gateways/remote_paypal_test.rb +191 -0
- data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/remote/gateways/remote_psl_card_test.rb +123 -0
- data/test/remote/gateways/remote_quickpay_test.rb +190 -0
- data/test/remote/gateways/remote_realex_test.rb +224 -0
- data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
- data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
- data/test/remote/gateways/remote_sage_test.rb +87 -0
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
- data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
- data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
- 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/gateways/remote_trans_first_test.rb +34 -0
- data/test/remote/gateways/remote_transax_test.rb +112 -0
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
- data/test/remote/gateways/remote_verifi_test.rb +107 -0
- data/test/remote/gateways/remote_viaklix_test.rb +43 -0
- data/test/remote/gateways/remote_wirecard_test.rb +111 -0
- data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
- data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
- data/test/test_helper.rb +184 -0
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +54 -0
- data/test/unit/check_test.rb +88 -0
- data/test/unit/connection_test.rb +129 -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 +19 -0
- data/test/unit/credit_card_methods_test.rb +179 -0
- data/test/unit/credit_card_test.rb +318 -0
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +32 -0
- data/test/unit/gateways/authorize_net_cim_test.rb +676 -0
- data/test/unit/gateways/authorize_net_test.rb +290 -0
- data/test/unit/gateways/beanstream_interac_test.rb +51 -0
- data/test/unit/gateways/beanstream_test.rb +144 -0
- data/test/unit/gateways/bogus_test.rb +58 -0
- data/test/unit/gateways/braintree_test.rb +118 -0
- data/test/unit/gateways/card_stream_test.rb +90 -0
- data/test/unit/gateways/cyber_source_test.rb +188 -0
- data/test/unit/gateways/data_cash_test.rb +133 -0
- data/test/unit/gateways/efsnet_test.rb +123 -0
- data/test/unit/gateways/elavon_test.rb +139 -0
- data/test/unit/gateways/eway_test.rb +118 -0
- data/test/unit/gateways/exact_test.rb +156 -0
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +48 -0
- data/test/unit/gateways/instapay_test.rb +102 -0
- data/test/unit/gateways/jetpay_test.rb +185 -0
- data/test/unit/gateways/linkpoint_test.rb +197 -0
- data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/modern_payments_cim_test.rb +162 -0
- data/test/unit/gateways/moneris_test.rb +158 -0
- data/test/unit/gateways/net_registry_test.rb +416 -0
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/ogone_test.rb +319 -0
- data/test/unit/gateways/pay_junction_test.rb +123 -0
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +173 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
- data/test/unit/gateways/payflow_nvp_uk_test.rb +201 -0
- data/test/unit/gateways/payflow_test.rb +305 -0
- data/test/unit/gateways/payflow_uk_test.rb +30 -0
- data/test/unit/gateways/payment_express_test.rb +195 -0
- data/test/unit/gateways/paypal_express_test.rb +382 -0
- data/test/unit/gateways/paypal_test.rb +569 -0
- data/test/unit/gateways/plugnpay_test.rb +86 -0
- data/test/unit/gateways/psigate_test.rb +169 -0
- data/test/unit/gateways/psl_card_test.rb +64 -0
- data/test/unit/gateways/quickpay_test.rb +112 -0
- data/test/unit/gateways/realex_test.rb +151 -0
- data/test/unit/gateways/sage_bankcard_test.rb +196 -0
- data/test/unit/gateways/sage_pay_test.rb +139 -0
- data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
- data/test/unit/gateways/sallie_mae_test.rb +53 -0
- data/test/unit/gateways/secure_pay_au_test.rb +207 -0
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +101 -0
- data/test/unit/gateways/skip_jack_test.rb +228 -0
- data/test/unit/gateways/trans_first_test.rb +112 -0
- data/test/unit/gateways/trust_commerce_test.rb +90 -0
- data/test/unit/gateways/usa_epay_test.rb +128 -0
- data/test/unit/gateways/verifi_test.rb +96 -0
- data/test/unit/gateways/viaklix_test.rb +78 -0
- data/test/unit/gateways/wirecard_test.rb +250 -0
- 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 +50 -0
- data/test/unit/integrations/bogus_module_test.rb +20 -0
- data/test/unit/integrations/chronopay_module_test.rb +13 -0
- data/test/unit/integrations/gestpay_module_test.rb +14 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +110 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +171 -0
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +13 -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/hi_trust_notification_test.rb +59 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +54 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +28 -0
- data/test/unit/integrations/quickpay_module_test.rb +9 -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 +13 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/posts_data_test.rb +48 -0
- data/test/unit/response_test.rb +28 -0
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +60 -0
- data.tar.gz.sig +0 -0
- metadata +453 -107
- metadata.gz.sig +0 -0
@@ -0,0 +1,356 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteDataCashTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
# gateway to connect to Datacash
|
7
|
+
@gateway = DataCashGateway.new(fixtures(:data_cash))
|
8
|
+
|
9
|
+
@mastercard = CreditCard.new(
|
10
|
+
:number => '5473000000000007',
|
11
|
+
:month => 3,
|
12
|
+
:year => Date.today.year + 2,
|
13
|
+
:first_name => 'Mark',
|
14
|
+
:last_name => 'McBride',
|
15
|
+
:type => :master,
|
16
|
+
:verification_value => '547'
|
17
|
+
)
|
18
|
+
|
19
|
+
@mastercard_declined = CreditCard.new(
|
20
|
+
:number => '5473000000000106',
|
21
|
+
:month => 3,
|
22
|
+
:year => Date.today.year + 2,
|
23
|
+
:first_name => 'Mark',
|
24
|
+
:last_name => 'McBride',
|
25
|
+
:type => :master,
|
26
|
+
:verification_value => '547'
|
27
|
+
)
|
28
|
+
|
29
|
+
@visa_delta = CreditCard.new(
|
30
|
+
:number => '4539792100000003',
|
31
|
+
:month => 3,
|
32
|
+
:year => Date.today.year + 2,
|
33
|
+
:first_name => 'Mark',
|
34
|
+
:last_name => 'McBride',
|
35
|
+
:type => :visa,
|
36
|
+
:verification_value => '444'
|
37
|
+
)
|
38
|
+
|
39
|
+
@solo = CreditCard.new(
|
40
|
+
:first_name => 'Cody',
|
41
|
+
:last_name => 'Fauser',
|
42
|
+
:number => '633499100000000004',
|
43
|
+
:month => 3,
|
44
|
+
:year => Date.today.year + 2,
|
45
|
+
:type => :solo,
|
46
|
+
:issue_number => 5,
|
47
|
+
:start_month => 12,
|
48
|
+
:start_year => 2006,
|
49
|
+
:verification_value => 444
|
50
|
+
)
|
51
|
+
|
52
|
+
@address = {
|
53
|
+
:name => 'Mark McBride',
|
54
|
+
:address1 => 'Flat 12/3',
|
55
|
+
:address2 => '45 Main Road',
|
56
|
+
:city => 'Sometown',
|
57
|
+
:state => 'Somecounty',
|
58
|
+
:zip => 'A987AA',
|
59
|
+
:phone => '(555)555-5555'
|
60
|
+
}
|
61
|
+
|
62
|
+
@params = {
|
63
|
+
:order_id => generate_unique_id,
|
64
|
+
:billing_address => @address
|
65
|
+
}
|
66
|
+
|
67
|
+
@amount = 198
|
68
|
+
end
|
69
|
+
|
70
|
+
# Testing that we can successfully make a purchase in a one step
|
71
|
+
# operation
|
72
|
+
def test_successful_purchase
|
73
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
74
|
+
assert_success response
|
75
|
+
assert response.test?
|
76
|
+
end
|
77
|
+
|
78
|
+
#the amount is changed to £1.99 - the DC test server won't check the
|
79
|
+
#address details - this is more a check on the passed ExtendedPolicy
|
80
|
+
def test_successful_purchase_without_address_check
|
81
|
+
response = @gateway.purchase(199, @mastercard, @params)
|
82
|
+
assert_success response
|
83
|
+
assert response.test?
|
84
|
+
end
|
85
|
+
|
86
|
+
# Note the Datacash test server regularly times out on switch requests
|
87
|
+
def test_successful_purchase_with_solo_card
|
88
|
+
response = @gateway.purchase(@amount, @solo, @params)
|
89
|
+
assert_success response
|
90
|
+
assert response.test?
|
91
|
+
end
|
92
|
+
|
93
|
+
# this card number won't check the address details - testing extended
|
94
|
+
# policy
|
95
|
+
def test_successful_purchase_without_address_check2
|
96
|
+
@solo.number = '633499110000000003'
|
97
|
+
|
98
|
+
response = @gateway.purchase(@amount, @solo, @params)
|
99
|
+
assert_success response
|
100
|
+
assert response.test?
|
101
|
+
end
|
102
|
+
|
103
|
+
# Testing purchase with request to set up recurring payment account
|
104
|
+
def test_successful_purchase_without_account_set_up_and_repeat_payments
|
105
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
106
|
+
assert_success response
|
107
|
+
assert response.authorization.to_s.split(';')[2].blank?
|
108
|
+
assert response.test?
|
109
|
+
end
|
110
|
+
|
111
|
+
# Testing purchase with request to set up recurring payment account
|
112
|
+
def test_successful_purchase_with_account_set_up_and_repeat_payments
|
113
|
+
@params[:set_up_continuous_authority] = true
|
114
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
115
|
+
assert_success response
|
116
|
+
assert !response.authorization.to_s.split(';')[2].blank?
|
117
|
+
assert response.test?
|
118
|
+
|
119
|
+
#Make second payment on the continuous authorization that was set up in the first purchase
|
120
|
+
second_order_params = { :order_id => generate_unique_id }
|
121
|
+
purchase = @gateway.purchase(201, response.params['ca_reference'], second_order_params)
|
122
|
+
assert_success purchase
|
123
|
+
assert purchase.test?
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_successful_purchase_with_account_set_up_and_repeat_payments_with_visa_delta_card
|
127
|
+
@params[:set_up_continuous_authority] = true
|
128
|
+
response = @gateway.purchase(@amount, @visa_delta, @params)
|
129
|
+
assert_success response
|
130
|
+
assert !response.authorization.to_s.split(';')[2].blank?
|
131
|
+
assert response.test?
|
132
|
+
|
133
|
+
#Make second payment on the continuous authorization that was set up in the first purchase
|
134
|
+
second_order_params = { :order_id => generate_unique_id }
|
135
|
+
purchase = @gateway.purchase(201, response.params['ca_reference'], second_order_params)
|
136
|
+
assert_success purchase
|
137
|
+
assert purchase.test?
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_purchase_with_account_set_up_for_repeat_payments_fails_for_solo_card
|
141
|
+
@params[:set_up_continuous_authority] = true
|
142
|
+
response = @gateway.purchase(@amount, @solo, @params)
|
143
|
+
assert_equal '92', response.params['status'] # Error code for CA not supported
|
144
|
+
assert_equal 'CA Not Supported', response.message
|
145
|
+
assert response.test?
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_successful_authorization_and_capture_with_account_set_up_and_second_purchase
|
149
|
+
#Authorize first payment
|
150
|
+
@params[:set_up_continuous_authority] = true
|
151
|
+
first_authorization = @gateway.authorize(@amount, @mastercard, @params)
|
152
|
+
assert_success first_authorization
|
153
|
+
assert !first_authorization.authorization.to_s.split(';')[2].blank?
|
154
|
+
assert first_authorization.test?
|
155
|
+
|
156
|
+
#Capture first payment
|
157
|
+
capture = @gateway.capture(@amount, first_authorization.authorization, @params)
|
158
|
+
assert_success capture
|
159
|
+
assert capture.test?
|
160
|
+
|
161
|
+
#Collect second purchase
|
162
|
+
second_order_params = { :order_id => generate_unique_id }
|
163
|
+
purchase = @gateway.purchase(201, first_authorization.authorization, second_order_params)
|
164
|
+
assert_success purchase
|
165
|
+
assert purchase.test?
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_duplicate_order_id
|
169
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
170
|
+
assert_success response
|
171
|
+
|
172
|
+
duplicate_response = @gateway.purchase(@amount, @mastercard, @params)
|
173
|
+
assert_failure duplicate_response
|
174
|
+
assert_equal 'Duplicate reference', duplicate_response.message
|
175
|
+
assert duplicate_response.test?
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_invalid_verification_number
|
179
|
+
@mastercard.verification_value = 123
|
180
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
181
|
+
assert_failure response
|
182
|
+
assert_equal 'CV2AVS DECLINED', response.message
|
183
|
+
assert response.test?
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_invalid_expiry_month
|
187
|
+
@mastercard.month = 13
|
188
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
189
|
+
assert_failure response
|
190
|
+
assert_equal 'Expiry date invalid', response.message
|
191
|
+
assert response.test?
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_invalid_expiry_year
|
195
|
+
@mastercard.year = 1999
|
196
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
197
|
+
assert_failure response
|
198
|
+
assert_equal 'Card has already expired', response.message
|
199
|
+
assert response.test?
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_declined_card
|
203
|
+
response = @gateway.purchase(@amount, @mastercard_declined, @params)
|
204
|
+
assert_failure response
|
205
|
+
assert_equal 'DECLINED', response.message
|
206
|
+
assert response.test?
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_successful_authorization_and_capture
|
210
|
+
authorization = @gateway.authorize(@amount, @mastercard, @params)
|
211
|
+
assert_success authorization
|
212
|
+
assert authorization.test?
|
213
|
+
|
214
|
+
capture = @gateway.capture(@amount, authorization.authorization, @params)
|
215
|
+
assert_success capture
|
216
|
+
assert capture.test?
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_unsuccessful_capture
|
220
|
+
response = @gateway.capture(@amount, ';1234', @params)
|
221
|
+
assert_failure response
|
222
|
+
assert_equal 'AUTHCODE field required', response.message
|
223
|
+
assert response.test?
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_successful_authorization_and_void
|
227
|
+
authorization = @gateway.authorize(@amount, @mastercard, @params)
|
228
|
+
assert_success authorization
|
229
|
+
assert authorization.test?
|
230
|
+
|
231
|
+
void = @gateway.void(authorization.authorization, @params)
|
232
|
+
assert_success void
|
233
|
+
assert void.test?
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_successfully_purchase_and_void
|
237
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
238
|
+
assert_success purchase
|
239
|
+
assert purchase.test?
|
240
|
+
|
241
|
+
void = @gateway.void(purchase.authorization, @params)
|
242
|
+
assert_success void
|
243
|
+
assert void.test?
|
244
|
+
end
|
245
|
+
|
246
|
+
|
247
|
+
def test_successful_refund
|
248
|
+
response = @gateway.credit(@amount, @mastercard, @params)
|
249
|
+
assert_success response
|
250
|
+
assert !response.params['datacash_reference'].blank?
|
251
|
+
assert !response.params['merchantreference'].blank?
|
252
|
+
|
253
|
+
assert response.test?
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_successful_transaction_refund
|
257
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
258
|
+
assert_success purchase
|
259
|
+
assert purchase.test?
|
260
|
+
|
261
|
+
refund = @gateway.credit(@amount, purchase.params['datacash_reference'])
|
262
|
+
assert_success refund
|
263
|
+
assert !refund.params['datacash_reference'].blank?
|
264
|
+
assert !refund.params['merchantreference'].blank?
|
265
|
+
|
266
|
+
assert refund.test?
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_successful_transaction_refund_with_money_set_to_nil
|
270
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
271
|
+
assert_success purchase
|
272
|
+
assert purchase.test?
|
273
|
+
|
274
|
+
refund = @gateway.credit(nil, purchase.params['datacash_reference'])
|
275
|
+
assert_success refund
|
276
|
+
assert refund.test?
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_successful_transaction_refund_in_two_stages
|
280
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
281
|
+
assert_success purchase
|
282
|
+
assert purchase.test?
|
283
|
+
|
284
|
+
first_partial_refund = @gateway.credit(100, purchase.params['datacash_reference'])
|
285
|
+
assert_success first_partial_refund
|
286
|
+
assert first_partial_refund.test?
|
287
|
+
|
288
|
+
second_partial_refund = @gateway.credit(98, purchase.params['datacash_reference'])
|
289
|
+
assert_success second_partial_refund
|
290
|
+
assert second_partial_refund.test?
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_successful_partial_transaction_refund
|
294
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
295
|
+
assert_success purchase
|
296
|
+
assert purchase.test?
|
297
|
+
|
298
|
+
partial_refund = @gateway.credit(100, purchase.params['datacash_reference'])
|
299
|
+
assert_success partial_refund
|
300
|
+
assert partial_refund.test?
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_fail_to_refund_too_much
|
304
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
305
|
+
assert_success purchase
|
306
|
+
assert purchase.test?
|
307
|
+
|
308
|
+
refund_too_much = @gateway.credit(500, purchase.params['datacash_reference'])
|
309
|
+
assert_failure refund_too_much
|
310
|
+
assert_equal 'Refund amount > orig 1.98', refund_too_much.message
|
311
|
+
assert refund_too_much.test?
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_fail_to_refund_with_declined_purchase_reference
|
315
|
+
declined_purchase = @gateway.purchase(@amount, @mastercard_declined, @params)
|
316
|
+
assert_failure declined_purchase
|
317
|
+
assert declined_purchase.test?
|
318
|
+
|
319
|
+
refund = @gateway.credit(@amount, declined_purchase.params['datacash_reference'])
|
320
|
+
assert_failure refund
|
321
|
+
assert_equal 'Cannot refund transaction', refund.message
|
322
|
+
assert refund.test?
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_fail_to_refund_purchase_which_is_already_refunded
|
326
|
+
purchase = @gateway.purchase(@amount, @mastercard, @params)
|
327
|
+
assert_success purchase
|
328
|
+
assert purchase.test?
|
329
|
+
|
330
|
+
first_refund = @gateway.credit(nil, purchase.params['datacash_reference'])
|
331
|
+
assert_success first_refund
|
332
|
+
assert first_refund.test?
|
333
|
+
|
334
|
+
second_refund = @gateway.credit(@amount, purchase.params['datacash_reference'])
|
335
|
+
assert_failure second_refund
|
336
|
+
assert_equal '1.98 > remaining funds 0.00', second_refund.message
|
337
|
+
assert second_refund.test?
|
338
|
+
end
|
339
|
+
|
340
|
+
# Check short merchant references are reformatted
|
341
|
+
def test_merchant_reference_that_is_too_short
|
342
|
+
@params[:order_id] = @params[:order_id].first(5)
|
343
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
344
|
+
assert_success response
|
345
|
+
assert response.test?
|
346
|
+
end
|
347
|
+
|
348
|
+
# Check long merchant references are reformatted
|
349
|
+
def test_merchant_reference_that_is_too_long
|
350
|
+
@params[:order_id] = "#{@params[:order_id]}1234356"
|
351
|
+
response = @gateway.purchase(@amount, @mastercard, @params)
|
352
|
+
assert_success response
|
353
|
+
assert response.test?
|
354
|
+
end
|
355
|
+
|
356
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteEfsnetTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Base.gateway_mode = :test
|
7
|
+
|
8
|
+
@gateway = EfsnetGateway.new(fixtures(:efsnet))
|
9
|
+
|
10
|
+
@credit_card = credit_card('4000100011112224')
|
11
|
+
|
12
|
+
@amount = 100
|
13
|
+
@declined_amount = 156
|
14
|
+
|
15
|
+
@options = { :order_id => generate_unique_id,
|
16
|
+
:billing_address => address
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_successful_purchase
|
21
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
22
|
+
assert_success response
|
23
|
+
assert_equal 'Approved', response.message
|
24
|
+
assert response.test?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_successful_force
|
28
|
+
assert response = @gateway.force(@amount, '123456', @credit_card, @options)
|
29
|
+
assert_success response
|
30
|
+
assert_equal 'Approved', response.message
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_successful_voice_authorize
|
34
|
+
assert response = @gateway.voice_authorize(@amount, '123456', @credit_card, @options)
|
35
|
+
assert_success response
|
36
|
+
assert_equal 'Accepted', response.message
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_unsuccessful_purchase
|
40
|
+
assert response = @gateway.purchase(@declined_amount, @credit_card, @options)
|
41
|
+
assert_failure response
|
42
|
+
assert_equal 'Declined', response.message
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_authorize_and_capture
|
46
|
+
amount = @amount
|
47
|
+
assert auth = @gateway.authorize(amount, @credit_card, @options)
|
48
|
+
assert_success auth
|
49
|
+
assert_equal 'Approved', auth.message
|
50
|
+
assert auth.authorization
|
51
|
+
|
52
|
+
assert capture = @gateway.capture(amount, auth.authorization, @options)
|
53
|
+
assert_success capture
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_purchase_and_void
|
57
|
+
amount = @amount
|
58
|
+
assert purchase = @gateway.purchase(amount, @credit_card, @options)
|
59
|
+
assert_success purchase
|
60
|
+
assert_equal 'Approved', purchase.message
|
61
|
+
assert purchase.authorization
|
62
|
+
assert void = @gateway.void(purchase.authorization, @options)
|
63
|
+
assert_success void
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_failed_capture
|
67
|
+
assert response = @gateway.capture(@amount, '1;1', @options)
|
68
|
+
assert_failure response
|
69
|
+
assert_equal 'Bad original transaction', response.message
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_invalid_login
|
73
|
+
gateway = EfsnetGateway.new(
|
74
|
+
:login => '',
|
75
|
+
:password => ''
|
76
|
+
)
|
77
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
78
|
+
assert_equal 'Invalid credentials', response.message
|
79
|
+
assert_failure response
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteElavonTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@gateway = ElavonGateway.new(fixtures(:elavon))
|
6
|
+
|
7
|
+
@credit_card = credit_card
|
8
|
+
@bad_credit_card = credit_card('invalid')
|
9
|
+
|
10
|
+
@options = {
|
11
|
+
:email => "paul@domain.com",
|
12
|
+
:description => 'Test Transaction',
|
13
|
+
:billing_address => address
|
14
|
+
}
|
15
|
+
@amount = 100
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_successful_purchase
|
19
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
20
|
+
|
21
|
+
assert_success response
|
22
|
+
assert response.test?
|
23
|
+
assert_equal 'APPROVED', response.message
|
24
|
+
assert response.authorization
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_unsuccessful_purchase
|
28
|
+
assert response = @gateway.purchase(@amount, @bad_credit_card, @options)
|
29
|
+
|
30
|
+
assert_failure response
|
31
|
+
assert response.test?
|
32
|
+
assert_equal 'The Credit Card Number supplied in the authorization request appears to be invalid.', response.message
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_authorize_and_capture
|
36
|
+
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
37
|
+
assert_success auth
|
38
|
+
assert_equal 'APPROVED', auth.message
|
39
|
+
assert auth.authorization
|
40
|
+
assert capture = @gateway.capture(@amount, auth.authorization, :credit_card => @credit_card)
|
41
|
+
assert_success capture
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_unsuccessful_capture
|
45
|
+
assert response = @gateway.capture(@amount, '', :credit_card => @credit_card)
|
46
|
+
assert_failure response
|
47
|
+
assert_equal 'The FORCE Approval Code supplied in the authorization request appears to be invalid or blank. The FORCE Approval Code must be 6 or less alphanumeric characters.', response.message
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_unsuccessful_authorization
|
51
|
+
@credit_card.number = "1234567890123"
|
52
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
53
|
+
assert_failure response
|
54
|
+
assert_equal 'The Credit Card Number supplied in the authorization request appears to be invalid.', response.message
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_purchase_and_credit
|
58
|
+
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
|
59
|
+
assert_success purchase
|
60
|
+
assert purchase.authorization
|
61
|
+
|
62
|
+
assert credit = @gateway.credit(@amount, @credit_card, @options)
|
63
|
+
assert_success credit
|
64
|
+
assert credit.authorization
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class EwayTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Base.gateway_mode = :test
|
6
|
+
@gateway = EwayGateway.new(fixtures(:eway))
|
7
|
+
|
8
|
+
@credit_card_success = credit_card('4444333322221111')
|
9
|
+
|
10
|
+
@credit_card_fail = credit_card('1234567812345678',
|
11
|
+
:month => Time.now.month,
|
12
|
+
:year => Time.now.year
|
13
|
+
)
|
14
|
+
|
15
|
+
@params = {
|
16
|
+
:order_id => '1230123',
|
17
|
+
:email => 'bob@testbob.com',
|
18
|
+
:billing_address => { :address1 => '47 Bobway',
|
19
|
+
:city => 'Bobville',
|
20
|
+
:state => 'WA',
|
21
|
+
:country => 'AU',
|
22
|
+
:zip => '2000'
|
23
|
+
} ,
|
24
|
+
:description => 'purchased items'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_invalid_amount
|
29
|
+
assert response = @gateway.purchase(101, @credit_card_success, @params)
|
30
|
+
assert_failure response
|
31
|
+
assert response.test?
|
32
|
+
assert_equal EwayGateway::MESSAGES["01"], response.message
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_purchase_success_with_verification_value
|
36
|
+
assert response = @gateway.purchase(100, @credit_card_success, @params)
|
37
|
+
assert_equal '123456', response.authorization
|
38
|
+
assert_success response
|
39
|
+
assert response.test?
|
40
|
+
assert_equal EwayGateway::MESSAGES["00"], response.message
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_invalid_expiration_date
|
44
|
+
@credit_card_success.year = 2005
|
45
|
+
assert response = @gateway.purchase(100, @credit_card_success, @params)
|
46
|
+
assert_failure response
|
47
|
+
assert response.test?
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_purchase_with_invalid_verification_value
|
51
|
+
@credit_card_success.verification_value = 'AAA'
|
52
|
+
assert response = @gateway.purchase(100, @credit_card_success, @params)
|
53
|
+
assert_nil response.authorization
|
54
|
+
assert_failure response
|
55
|
+
assert response.test?
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_purchase_success_without_verification_value
|
59
|
+
@credit_card_success.verification_value = nil
|
60
|
+
|
61
|
+
assert response = @gateway.purchase(100, @credit_card_success, @params)
|
62
|
+
assert_equal '123456', response.authorization
|
63
|
+
assert_success response
|
64
|
+
assert response.test?
|
65
|
+
assert_equal EwayGateway::MESSAGES["00"], response.message
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_purchase_error
|
69
|
+
assert response = @gateway.purchase(100, @credit_card_fail, @params)
|
70
|
+
assert_nil response.authorization
|
71
|
+
assert_equal false, response.success?
|
72
|
+
assert response.test?
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteExactTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
|
7
|
+
@gateway = ExactGateway.new(fixtures(:exact))
|
8
|
+
@credit_card = credit_card
|
9
|
+
@amount = 100
|
10
|
+
@options = {
|
11
|
+
:order_id => '1',
|
12
|
+
:billing_address => address,
|
13
|
+
:description => 'Store Purchase'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_successful_purchase
|
18
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
19
|
+
assert_match /Transaction Normal/, response.message
|
20
|
+
assert_success response
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_unsuccessful_purchase
|
24
|
+
# ask for error 13 response (Amount Error) via dollar amount 5,000 + error
|
25
|
+
@amount = 501300
|
26
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options )
|
27
|
+
assert_match /Transaction Normal/, response.message
|
28
|
+
assert_failure response
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_purchase_and_credit
|
32
|
+
assert purchase = @gateway.purchase(@amount, @credit_card, @options)
|
33
|
+
assert_success purchase
|
34
|
+
assert purchase.authorization
|
35
|
+
assert credit = @gateway.credit(@amount, purchase.authorization)
|
36
|
+
assert_success credit
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_authorize_and_capture
|
40
|
+
assert auth = @gateway.authorize(@amount, @credit_card, @options)
|
41
|
+
assert_success auth
|
42
|
+
assert auth.authorization
|
43
|
+
assert capture = @gateway.capture(@amount, auth.authorization)
|
44
|
+
assert_success capture
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_failed_capture
|
48
|
+
assert response = @gateway.capture(@amount, '')
|
49
|
+
assert_failure response
|
50
|
+
assert_match /Precondition Failed/i, response.message
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_invalid_login
|
54
|
+
gateway = ExactGateway.new( :login => "NotARealUser",
|
55
|
+
:password => "NotARealPassword" )
|
56
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
57
|
+
assert_equal "Invalid Logon", response.message
|
58
|
+
assert_failure response
|
59
|
+
end
|
60
|
+
end
|