activemerchant-realex3ds 1.0.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/Gemfile +2 -0
- data/Gemfile.lock +60 -0
- data/MIT-LICENSE +20 -0
- data/README.md +25 -0
- data/Rakefile +58 -0
- data/activemerchant-realex3ds.gemspec +28 -0
- data/lib/active_merchant/billing/gateways/realex3ds.rb +610 -0
- data/lib/active_merchant/billing/gateways/realex3ds_development.rb +111 -0
- data/test/assert_equal_xml.rb +5 -0
- data/test/comm_stub.rb +40 -0
- data/test/fixtures.yml +71 -0
- data/test/remote/gateways/remote_realex3ds_test.rb +476 -0
- data/test/test_helper.rb +265 -0
- data/test/unit/gateways/realex3ds_test.rb +975 -0
- metadata +149 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# Realex Development Gateway
|
4
|
+
#
|
5
|
+
# Because the Realex gateway does not have a separate :test environment,
|
6
|
+
# we are unable to really work with it in a development environment.
|
7
|
+
#
|
8
|
+
# The Bogus gateway was my initial choice for testing, however it does not take valid card data as
|
9
|
+
# giving successful responses therefore not enabling it to work if you have significant pre-validation
|
10
|
+
# of card data.
|
11
|
+
#
|
12
|
+
# Realex also expects some extra parameters and therefore I thought it better to encapsulate them all
|
13
|
+
# here in a working development gateway that will act like Realex in production.
|
14
|
+
#
|
15
|
+
class RealexDevelopmentGateway < Gateway
|
16
|
+
AUTHORIZATION = '53433'
|
17
|
+
|
18
|
+
SUCCESSFUL_CARD = '1111111111111111'
|
19
|
+
FAILING_CARD = '2222222222222222'
|
20
|
+
|
21
|
+
SUCCESS_MESSAGE = "Realex Development Gateway: Forced success"
|
22
|
+
FAILURE_MESSAGE = "Realex Development Gateway: Forced failure"
|
23
|
+
ERROR_MESSAGE = "Realex Development Gateway: Use CreditCard number #{SUCCESSFUL_CARD} for success, #{FAILING_CARD} for exception and anything else for error"
|
24
|
+
CREDIT_ERROR_MESSAGE = "Realex Development Gateway: Use trans_id 1 for success, 2 for exception and anything else for error"
|
25
|
+
UNSTORE_ERROR_MESSAGE = "Realex Development Gateway: Use trans_id 1 for success, 2 for exception and anything else for error"
|
26
|
+
CAPTURE_ERROR_MESSAGE = "Realex Development Gateway: Use authorization number 1 for exception, 2 for error and anything else for success"
|
27
|
+
VOID_ERROR_MESSAGE = "Realex Development Gateway: Use authorization number 1 for exception, 2 for error and anything else for success"
|
28
|
+
|
29
|
+
self.money_format = :cents
|
30
|
+
self.default_currency = 'EUR'
|
31
|
+
self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ]
|
32
|
+
self.supported_countries = [ 'IE', 'GB' ]
|
33
|
+
self.homepage_url = 'http://www.realexpayments.com/'
|
34
|
+
self.display_name = 'Realex Development'
|
35
|
+
|
36
|
+
def authorize(money, creditcard, options = {})
|
37
|
+
case creditcard.number
|
38
|
+
when SUCCESSFUL_CARD
|
39
|
+
Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money.to_s, :pasref => '1234'}, :test => true, :authorization => AUTHORIZATION )
|
40
|
+
when FAILING_CARD
|
41
|
+
Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true)
|
42
|
+
else
|
43
|
+
raise Error, ERROR_MESSAGE
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def purchase(money, creditcard, options = {})
|
48
|
+
case creditcard.number
|
49
|
+
when SUCCESSFUL_CARD
|
50
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s, :pasref => '1234'}, :test => true, :authorization => AUTHORIZATION)
|
51
|
+
when FAILING_CARD
|
52
|
+
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE },:test => true)
|
53
|
+
else
|
54
|
+
raise Error, ERROR_MESSAGE
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def credit(money, ident, options = {})
|
59
|
+
case ident
|
60
|
+
when '1'
|
61
|
+
raise Error, CREDIT_ERROR_MESSAGE
|
62
|
+
when '2'
|
63
|
+
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true)
|
64
|
+
else
|
65
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s, :orderid => '1234'}, :test => true)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def capture(money, ident, options = {})
|
70
|
+
case ident
|
71
|
+
when '1'
|
72
|
+
raise Error, CAPTURE_ERROR_MESSAGE
|
73
|
+
when '2'
|
74
|
+
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true)
|
75
|
+
else
|
76
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def void(ident, options = {})
|
81
|
+
case ident
|
82
|
+
when '1'
|
83
|
+
raise Error, VOID_ERROR_MESSAGE
|
84
|
+
when '2'
|
85
|
+
Response.new(false, FAILURE_MESSAGE, {:authorization => ident, :error => FAILURE_MESSAGE }, :test => true)
|
86
|
+
else
|
87
|
+
Response.new(true, SUCCESS_MESSAGE, {:authorization => ident}, :test => true)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def store(creditcard, options = {})
|
92
|
+
case creditcard.number
|
93
|
+
when SUCCESSFUL_CARD
|
94
|
+
Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION )
|
95
|
+
when FAILING_CARD
|
96
|
+
Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true)
|
97
|
+
else
|
98
|
+
raise Error, ERROR_MESSAGE
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def unstore(creditcard, options = {})
|
103
|
+
Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION )
|
104
|
+
end
|
105
|
+
|
106
|
+
def store_user(options = {})
|
107
|
+
Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION )
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/test/comm_stub.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module CommStub
|
2
|
+
class Stub
|
3
|
+
def initialize(gateway, method_to_stub, action)
|
4
|
+
@gateway = gateway
|
5
|
+
@action = action
|
6
|
+
@complete = false
|
7
|
+
@method_to_stub = method_to_stub
|
8
|
+
end
|
9
|
+
|
10
|
+
def check_request(&block)
|
11
|
+
@check = block
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def respond_with(*responses)
|
16
|
+
@complete = true
|
17
|
+
check = @check
|
18
|
+
(class << @gateway; self; end).send(:define_method, @method_to_stub) do |*args|
|
19
|
+
check.call(*args) if check
|
20
|
+
(responses.size == 1 ? responses.last : responses.shift)
|
21
|
+
end
|
22
|
+
@action.call
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete?
|
26
|
+
@complete
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def stub_comms(method_to_stub=:ssl_post, &action)
|
31
|
+
if @last_comm_stub
|
32
|
+
assert @last_comm_stub.complete?, "Tried to stub communications when there's a stub already in progress."
|
33
|
+
end
|
34
|
+
@last_comm_stub = Stub.new(@gateway, method_to_stub, action)
|
35
|
+
end
|
36
|
+
|
37
|
+
def teardown
|
38
|
+
assert(@last_comm_stub.complete?) if @last_comm_stub
|
39
|
+
end
|
40
|
+
end
|
data/test/fixtures.yml
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
realex:
|
2
|
+
login: X
|
3
|
+
password: Y
|
4
|
+
|
5
|
+
realex_with_account:
|
6
|
+
login: X
|
7
|
+
password: Y
|
8
|
+
account: testaccount
|
9
|
+
|
10
|
+
# Realex doesn't provide public testing data
|
11
|
+
# Fill in the card numbers with the Realex test
|
12
|
+
# data.
|
13
|
+
realex_visa:
|
14
|
+
number:
|
15
|
+
month: '6'
|
16
|
+
year: '2020'
|
17
|
+
verification_value: '123'
|
18
|
+
|
19
|
+
realex_visa_declined:
|
20
|
+
number:
|
21
|
+
month: '6'
|
22
|
+
year: '2020'
|
23
|
+
verification_value: '123'
|
24
|
+
|
25
|
+
realex_visa_referral_a:
|
26
|
+
number:
|
27
|
+
month: '6'
|
28
|
+
year: '2020'
|
29
|
+
verification_value: '123'
|
30
|
+
|
31
|
+
realex_visa_referral_b:
|
32
|
+
number:
|
33
|
+
month: '6'
|
34
|
+
year: '2020'
|
35
|
+
verification_value: '123'
|
36
|
+
|
37
|
+
realex_visa_coms_error:
|
38
|
+
number:
|
39
|
+
month: '6'
|
40
|
+
year: '2020'
|
41
|
+
verification_value: '123'
|
42
|
+
|
43
|
+
realex_mastercard:
|
44
|
+
number:
|
45
|
+
month: '6'
|
46
|
+
year: '2020'
|
47
|
+
verification_value: '123'
|
48
|
+
|
49
|
+
realex_mastercard_declined:
|
50
|
+
number:
|
51
|
+
month: '6'
|
52
|
+
year: '2020'
|
53
|
+
verification_value: '123'
|
54
|
+
|
55
|
+
realex_mastercard_referral_a:
|
56
|
+
number:
|
57
|
+
month: '6'
|
58
|
+
year: '2020'
|
59
|
+
verification_value: '123'
|
60
|
+
|
61
|
+
realex_mastercard_referral_b:
|
62
|
+
number:
|
63
|
+
month: '6'
|
64
|
+
year: '2020'
|
65
|
+
verification_value: '123'
|
66
|
+
|
67
|
+
realex_mastercard_coms_error:
|
68
|
+
number:
|
69
|
+
month: '6'
|
70
|
+
year: '2020'
|
71
|
+
verification_value: '123'
|
@@ -0,0 +1,476 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'active_merchant/billing/gateways/realex3ds'
|
4
|
+
|
5
|
+
class RemoteRealexTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def valid_card_attributes
|
8
|
+
{:first_name => 'Steve', :last_name => 'Smith', :month => '9', :year => '2010', :type => 'visa', :number => '4242424242424242'}
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_card(fixture)
|
12
|
+
CreditCard.new valid_card_attributes.merge(fixtures(fixture))
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
@gateway = Realex3dsGateway.new(fixtures(:realex_with_account))
|
17
|
+
|
18
|
+
@gateway_with_account = Realex3dsGateway.new(fixtures(:realex_with_account))
|
19
|
+
|
20
|
+
# Replace the card numbers with the test account numbers from Realex
|
21
|
+
@visa = create_card(:realex_visa)
|
22
|
+
@visa_declined = create_card(:realex_visa_declined)
|
23
|
+
@visa_referral_b = create_card(:realex_visa_referral_b)
|
24
|
+
@visa_referral_a = create_card(:realex_visa_referral_a)
|
25
|
+
@visa_coms_error = create_card(:realex_visa_coms_error)
|
26
|
+
|
27
|
+
@mastercard = create_card(:realex_mastercard)
|
28
|
+
@mastercard_declined = create_card(:realex_mastercard_declined)
|
29
|
+
@mastercard_referral_b = create_card(:realex_mastercard_referral_b)
|
30
|
+
@mastercard_referral_a = create_card(:realex_mastercard_referral_a)
|
31
|
+
@mastercard_coms_error = create_card(:realex_mastercard_coms_error)
|
32
|
+
|
33
|
+
@amount = 10000
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_realex_purchase
|
37
|
+
[ @visa, @mastercard ].each do |card|
|
38
|
+
|
39
|
+
response = @gateway.purchase(@amount, card,
|
40
|
+
:order_id => generate_unique_id,
|
41
|
+
:description => 'Test Realex Purchase',
|
42
|
+
:billing_address => {
|
43
|
+
:zip => '90210',
|
44
|
+
:country => 'US'
|
45
|
+
}
|
46
|
+
)
|
47
|
+
|
48
|
+
assert_not_nil response
|
49
|
+
assert_success response
|
50
|
+
assert response.test?
|
51
|
+
assert response.authorization.length > 0
|
52
|
+
assert_equal 'Successful', response.message
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_realex_purchase_with_invalid_login
|
57
|
+
gateway = Realex3dsGateway.new(
|
58
|
+
:login => 'invalid',
|
59
|
+
:password => 'invalid'
|
60
|
+
)
|
61
|
+
response = gateway.purchase(@amount, @visa,
|
62
|
+
:order_id => generate_unique_id,
|
63
|
+
:description => 'Invalid login test'
|
64
|
+
)
|
65
|
+
|
66
|
+
assert_not_nil response
|
67
|
+
assert_failure response
|
68
|
+
|
69
|
+
assert_equal '504', response.params['result']
|
70
|
+
assert_equal "There is no such merchant id. Please contact realex payments if you continue to experience this problem.", response.message
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_realex_purchase_with_invalid_account
|
74
|
+
@gateway_with_invalid_account = Realex3dsGateway.new(fixtures(:realex_with_account).merge(:account => "thisdoesnotexist"))
|
75
|
+
response = @gateway_with_invalid_account.purchase(@amount, @visa,
|
76
|
+
:order_id => generate_unique_id,
|
77
|
+
:description => 'Test Realex purchase with invalid acocunt'
|
78
|
+
)
|
79
|
+
|
80
|
+
assert_not_nil response
|
81
|
+
assert_failure response
|
82
|
+
|
83
|
+
assert_equal '506', response.params['result']
|
84
|
+
assert_equal "There is no such merchant account. Please contact realex payments if you continue to experience this problem.", response.message
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_realex_purchase_declined
|
88
|
+
|
89
|
+
[ @visa_declined, @mastercard_declined ].each do |card|
|
90
|
+
|
91
|
+
response = @gateway.purchase(@amount, card,
|
92
|
+
:order_id => generate_unique_id,
|
93
|
+
:description => 'Test Realex purchase declined'
|
94
|
+
)
|
95
|
+
assert_not_nil response
|
96
|
+
assert_failure response
|
97
|
+
|
98
|
+
assert_equal '101', response.params['result']
|
99
|
+
assert_equal response.params['message'], response.message
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_realex_purchase_referral_b
|
105
|
+
[ @visa_referral_b, @mastercard_referral_b ].each do |card|
|
106
|
+
|
107
|
+
response = @gateway.purchase(@amount, card,
|
108
|
+
:order_id => generate_unique_id,
|
109
|
+
:description => 'Test Realex Referral B'
|
110
|
+
)
|
111
|
+
assert_not_nil response
|
112
|
+
assert_failure response
|
113
|
+
assert response.test?
|
114
|
+
assert_equal '102', response.params['result']
|
115
|
+
assert_equal Realex3dsGateway::DECLINED, response.message
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_realex_purchase_referral_a
|
120
|
+
[ @visa_referral_a, @mastercard_referral_a ].each do |card|
|
121
|
+
|
122
|
+
response = @gateway.purchase(@amount, card,
|
123
|
+
:order_id => generate_unique_id,
|
124
|
+
:description => 'Test Realex Rqeferral A'
|
125
|
+
)
|
126
|
+
assert_not_nil response
|
127
|
+
assert_failure response
|
128
|
+
assert_equal '103', response.params['result']
|
129
|
+
assert_equal Realex3dsGateway::DECLINED, response.message
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_realex_purchase_coms_error
|
135
|
+
|
136
|
+
[ @visa_coms_error, @mastercard_coms_error ].each do |card|
|
137
|
+
|
138
|
+
response = @gateway.purchase(@amount, card,
|
139
|
+
:order_id => generate_unique_id,
|
140
|
+
:description => 'Test Realex coms error'
|
141
|
+
)
|
142
|
+
|
143
|
+
assert_not_nil response
|
144
|
+
assert_failure response
|
145
|
+
|
146
|
+
assert_equal '200', response.params['result']
|
147
|
+
# assert_equal '205', response.params['result']
|
148
|
+
# will be a 205 in production
|
149
|
+
# will be a 200 error in test arg.
|
150
|
+
assert_equal Realex3dsGateway::BANK_ERROR, response.message
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_realex_ccn_error
|
156
|
+
visa = @visa.clone
|
157
|
+
visa.number = '5'
|
158
|
+
|
159
|
+
response = @gateway.purchase(@amount, visa,
|
160
|
+
:order_id => generate_unique_id,
|
161
|
+
:description => 'Test Realex ccn error'
|
162
|
+
)
|
163
|
+
|
164
|
+
assert_not_nil response
|
165
|
+
assert_failure response
|
166
|
+
|
167
|
+
# Looking at the API this should actually be "509 - Invalid credit card length" but hey..
|
168
|
+
assert_equal '508', response.params['result']
|
169
|
+
assert_equal "Invalid data in CC number field.", response.message
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_realex_expiry_month_error
|
173
|
+
@visa.month = 13
|
174
|
+
|
175
|
+
response = @gateway.purchase(@amount, @visa,
|
176
|
+
:order_id => generate_unique_id,
|
177
|
+
:description => 'Test Realex expiry month error'
|
178
|
+
)
|
179
|
+
assert_not_nil response
|
180
|
+
assert_failure response
|
181
|
+
|
182
|
+
assert_equal '509', response.params['result']
|
183
|
+
assert_equal "Expiry date invalid", response.message
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_realex_expiry_year_error
|
187
|
+
@visa.year = 2005
|
188
|
+
|
189
|
+
response = @gateway.purchase(@amount, @visa,
|
190
|
+
:order_id => generate_unique_id,
|
191
|
+
:description => 'Test Realex expiry year error'
|
192
|
+
)
|
193
|
+
assert_not_nil response
|
194
|
+
assert_failure response
|
195
|
+
|
196
|
+
assert_equal '509', response.params['result']
|
197
|
+
assert_equal "Expiry date invalid", response.message
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_invalid_credit_card_name
|
201
|
+
@visa.first_name = ""
|
202
|
+
@visa.last_name = ""
|
203
|
+
|
204
|
+
response = @gateway.purchase(@amount, @visa,
|
205
|
+
:order_id => generate_unique_id,
|
206
|
+
:description => 'test_chname_error'
|
207
|
+
)
|
208
|
+
assert_not_nil response
|
209
|
+
assert_failure response
|
210
|
+
|
211
|
+
assert_equal '502', response.params['result']
|
212
|
+
assert_equal "Mandatory field not present - cannot continue. Please check the Developer Documentation for mandatory fields", response.message
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_cvn
|
216
|
+
@visa_cvn = @visa.clone
|
217
|
+
@visa_cvn.verification_value = "111"
|
218
|
+
response = @gateway.purchase(@amount, @visa_cvn,
|
219
|
+
:order_id => generate_unique_id,
|
220
|
+
:description => 'test_cvn'
|
221
|
+
)
|
222
|
+
assert_not_nil response
|
223
|
+
assert_success response
|
224
|
+
assert response.authorization.length > 0
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_customer_number
|
228
|
+
response = @gateway.purchase(@amount, @visa,
|
229
|
+
:order_id => generate_unique_id,
|
230
|
+
:description => 'test_cust_num',
|
231
|
+
:customer => 'my customer id'
|
232
|
+
)
|
233
|
+
assert_not_nil response
|
234
|
+
assert_success response
|
235
|
+
assert response.authorization.length > 0
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_realex_authorize
|
239
|
+
response = @gateway.authorize(@amount, @visa,
|
240
|
+
:order_id => generate_unique_id,
|
241
|
+
:description => 'Test Realex Purchase',
|
242
|
+
:billing_address => {
|
243
|
+
:zip => '90210',
|
244
|
+
:country => 'US'
|
245
|
+
}
|
246
|
+
)
|
247
|
+
|
248
|
+
assert_not_nil response
|
249
|
+
assert_success response
|
250
|
+
assert response.test?
|
251
|
+
assert response.authorization.length > 0
|
252
|
+
assert_equal 'Successful', response.message
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_realex_authorize_then_capture
|
256
|
+
order_id = generate_unique_id
|
257
|
+
|
258
|
+
auth_response = @gateway.authorize(@amount, @visa,
|
259
|
+
:order_id => order_id,
|
260
|
+
:description => 'Test Realex Purchase',
|
261
|
+
:billing_address => {
|
262
|
+
:zip => '90210',
|
263
|
+
:country => 'US'
|
264
|
+
}
|
265
|
+
)
|
266
|
+
|
267
|
+
capture_response = @gateway.capture(@amount, auth_response.authorization,
|
268
|
+
:order_id => order_id,
|
269
|
+
:pasref => auth_response.params['pasref']
|
270
|
+
)
|
271
|
+
|
272
|
+
assert_not_nil capture_response
|
273
|
+
assert_success capture_response
|
274
|
+
assert capture_response.test?
|
275
|
+
assert capture_response.authorization.length > 0
|
276
|
+
assert_equal 'Successful', capture_response.message
|
277
|
+
assert_match /Settled Successfully/, capture_response.params['message']
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_realex_purchase_then_void
|
281
|
+
order_id = generate_unique_id
|
282
|
+
|
283
|
+
purchase_response = @gateway.purchase(@amount, @visa,
|
284
|
+
:order_id => order_id,
|
285
|
+
:description => 'Test Realex Purchase',
|
286
|
+
:billing_address => {
|
287
|
+
:zip => '90210',
|
288
|
+
:country => 'US'
|
289
|
+
}
|
290
|
+
)
|
291
|
+
|
292
|
+
void_response = @gateway.void(purchase_response.authorization,
|
293
|
+
:order_id => order_id,
|
294
|
+
:pasref => purchase_response.params['pasref']
|
295
|
+
)
|
296
|
+
|
297
|
+
assert_not_nil void_response
|
298
|
+
assert_success void_response
|
299
|
+
assert void_response.test?
|
300
|
+
assert void_response.authorization.length > 0
|
301
|
+
assert_equal 'Successful', void_response.message
|
302
|
+
assert_match /Voided Successfully/, void_response.params['message']
|
303
|
+
end
|
304
|
+
|
305
|
+
def test_realex_purchase_then_credit
|
306
|
+
order_id = generate_unique_id
|
307
|
+
|
308
|
+
@gateway_with_refund_password = Realex3dsGateway.new(fixtures(:realex_with_account).merge(:rebate_secret => 'refund'))
|
309
|
+
|
310
|
+
purchase_response = @gateway_with_refund_password.purchase(@amount, @visa,
|
311
|
+
:order_id => order_id,
|
312
|
+
:description => 'Test Realex Purchase',
|
313
|
+
:billing_address => {
|
314
|
+
:zip => '90210',
|
315
|
+
:country => 'US'
|
316
|
+
}
|
317
|
+
)
|
318
|
+
|
319
|
+
rebate_response = @gateway_with_refund_password.credit(@amount, purchase_response.authorization,
|
320
|
+
:order_id => order_id,
|
321
|
+
:pasref => purchase_response.params['pasref']
|
322
|
+
)
|
323
|
+
|
324
|
+
assert_not_nil rebate_response
|
325
|
+
assert_success rebate_response
|
326
|
+
assert rebate_response.test?
|
327
|
+
assert rebate_response.authorization.length > 0
|
328
|
+
assert_equal 'Successful', rebate_response.message
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_realex_response_body
|
332
|
+
response = @gateway.authorize(@amount, @visa, :order_id => generate_unique_id)
|
333
|
+
assert_not_nil response.body
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_realex_authorize_with_3dsecure
|
337
|
+
response = @gateway.authorize(@amount, @visa,
|
338
|
+
:order_id => generate_unique_id,
|
339
|
+
:description => 'Test Realex Purchase',
|
340
|
+
:billing_address => {
|
341
|
+
:zip => '90210',
|
342
|
+
:country => 'US'
|
343
|
+
},
|
344
|
+
:three_d_secure => true
|
345
|
+
)
|
346
|
+
|
347
|
+
assert_not_nil response
|
348
|
+
assert_success response
|
349
|
+
assert response.params['pareq'].length > 0
|
350
|
+
assert response.params['enrolled'].length > 0
|
351
|
+
assert response.params['enrolled'] == "Y"
|
352
|
+
|
353
|
+
assert_equal response.params['url'], 'https://dropit.3dsecure.net:9443/PIT/ACS'
|
354
|
+
|
355
|
+
assert_equal 'Successful', response.message
|
356
|
+
end
|
357
|
+
|
358
|
+
# def test_realex_purchase_with_3dsecure
|
359
|
+
# order_id = generate_unique_id
|
360
|
+
# response = @gateway.authorize(@amount, @visa,
|
361
|
+
# :order_id => order_id,
|
362
|
+
# :description => 'Test Realex Purchase',
|
363
|
+
# :billing_address => {
|
364
|
+
# :zip => '90210',
|
365
|
+
# :country => 'US'
|
366
|
+
# },
|
367
|
+
# :three_d_secure => true
|
368
|
+
# )
|
369
|
+
#
|
370
|
+
# pareq = response.params['pareq']
|
371
|
+
#
|
372
|
+
# response = @gateway.purchase(@amount, @visa,
|
373
|
+
# :order_id => order_id,
|
374
|
+
# :description => 'Test Realex Purchase',
|
375
|
+
# :billing_address => {
|
376
|
+
# :zip => '90210',
|
377
|
+
# :country => 'US'
|
378
|
+
# },
|
379
|
+
# :three_d_secure_auth => {
|
380
|
+
# :pa_res => pareq
|
381
|
+
# }
|
382
|
+
# )
|
383
|
+
#
|
384
|
+
#
|
385
|
+
# assert_not_nil response
|
386
|
+
# assert_success response
|
387
|
+
# assert response.params['pareq'].length > 0
|
388
|
+
# assert response.params['enrolled'].length > 0
|
389
|
+
#
|
390
|
+
# assert_equal 'Successful', response.message
|
391
|
+
# end
|
392
|
+
|
393
|
+
# response timestamp=\"20100303191232\">\r\n<merchantid>exoftwaretest</merchantid>\r\n<account>internet</account>\r\n<orderid>edeac18e066b7208bbdec24c105c17e1</orderid>\r\n<result>00</result>\r\n<message>Successful</message>\r\n<pasref>69deeba5cc294cbba3e3becc016fd3ed</pasref>\r\n<authcode></authcode>\r\n<batchid></batchid>\r\n<timetaken>0</timetaken>\r\n<processingtimetaken></processingtimetaken>\r\n<md5hash>37f71f37cb3a7eb2e138f46d6fe9cbcb</md5hash>\r\n<sha1hash>1aa79d2d8621c8d2e4c80a752c19c75f717ff8b7</sha1hash>\r\n</response>\r\n", @authorization=nil, @success=true>
|
394
|
+
|
395
|
+
def test_realex_store_user
|
396
|
+
options = {
|
397
|
+
:order_id => generate_unique_id,
|
398
|
+
:user => {
|
399
|
+
:id => generate_unique_id,
|
400
|
+
:first_name => 'John',
|
401
|
+
:last_name => 'Smith'
|
402
|
+
}
|
403
|
+
}
|
404
|
+
response = @gateway.store_user(options)
|
405
|
+
|
406
|
+
assert_not_nil response
|
407
|
+
assert_success response
|
408
|
+
assert_equal 'Successful', response.message
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_realex_store_card
|
412
|
+
options = {
|
413
|
+
:order_id => generate_unique_id,
|
414
|
+
:user => {
|
415
|
+
:id => generate_unique_id,
|
416
|
+
:first_name => 'John',
|
417
|
+
:last_name => 'Smith'
|
418
|
+
}
|
419
|
+
}
|
420
|
+
response = @gateway.store_user(options)
|
421
|
+
|
422
|
+
options.merge!(:order_id => generate_unique_id)
|
423
|
+
store_card_response = @gateway.store(@visa, options)
|
424
|
+
|
425
|
+
assert_not_nil store_card_response
|
426
|
+
assert_success store_card_response
|
427
|
+
assert_equal 'Successful', store_card_response.message
|
428
|
+
end
|
429
|
+
|
430
|
+
def test_realex_receipt_in
|
431
|
+
options = {
|
432
|
+
:order_id => generate_unique_id,
|
433
|
+
:user => {
|
434
|
+
:id => generate_unique_id,
|
435
|
+
:first_name => 'John',
|
436
|
+
:last_name => 'Smith'
|
437
|
+
}
|
438
|
+
}
|
439
|
+
response = @gateway.store_user(options)
|
440
|
+
|
441
|
+
options.merge!(:order_id => generate_unique_id, :payment_method => 'visa01')
|
442
|
+
store_card_response = @gateway.store(@visa, options)
|
443
|
+
|
444
|
+
options.merge!({
|
445
|
+
:order_id => generate_unique_id,
|
446
|
+
:payment_method => 'visa01'
|
447
|
+
})
|
448
|
+
receipt_in_response = @gateway.recurring(@amount, @visa, options)
|
449
|
+
|
450
|
+
assert_not_nil receipt_in_response
|
451
|
+
assert_success receipt_in_response
|
452
|
+
assert_equal 'Successful', receipt_in_response.message
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_realex_unstore_card
|
456
|
+
options = {
|
457
|
+
:order_id => generate_unique_id,
|
458
|
+
:user => {
|
459
|
+
:id => generate_unique_id,
|
460
|
+
:first_name => 'John',
|
461
|
+
:last_name => 'Smith'
|
462
|
+
}
|
463
|
+
}
|
464
|
+
response = @gateway.store_user(options)
|
465
|
+
|
466
|
+
options.merge!(:order_id => generate_unique_id, :payment_method => generate_unique_id)
|
467
|
+
store_card_response = @gateway.store(@visa, options)
|
468
|
+
|
469
|
+
unstore_card_response = @gateway.unstore(@visa, options)
|
470
|
+
|
471
|
+
assert_not_nil unstore_card_response
|
472
|
+
assert_success unstore_card_response
|
473
|
+
assert_equal 'Successful', unstore_card_response.message
|
474
|
+
end
|
475
|
+
|
476
|
+
end
|