active_merchant_ideal 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,704 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ module IdealTestCases
4
+ # This method is called at the end of the file when all fixture data has been loaded.
5
+ def self.setup_ideal_gateway!
6
+ ActiveMerchant::Billing::IdealGateway.class_eval do
7
+ self.merchant_id = '123456789'
8
+
9
+ self.passphrase = 'passphrase'
10
+ self.private_key = PRIVATE_KEY
11
+ self.private_certificate = PRIVATE_CERTIFICATE
12
+ self.ideal_certificate = IDEAL_CERTIFICATE
13
+
14
+ self.test_url = "https://idealtest.example.com:443/ideal/iDeal"
15
+ self.live_url = "https://ideal.example.com:443/ideal/iDeal"
16
+ end
17
+ end
18
+
19
+ VALID_PURCHASE_OPTIONS = {
20
+ :issuer_id => '0001',
21
+ :expiration_period => 'PT10M',
22
+ :return_url => 'http://return_to.example.com',
23
+ :order_id => '12345678901',
24
+ :description => 'A classic Dutch windmill',
25
+ :entrance_code => '1234'
26
+ }
27
+
28
+ ###
29
+ #
30
+ # Actual test cases
31
+ #
32
+
33
+ class ClassMethodsTest < Test::Unit::TestCase
34
+ def test_merchant_id
35
+ assert_equal IdealGateway.merchant_id, '123456789'
36
+ end
37
+
38
+ def test_private_certificate_returns_a_loaded_Certificate_instance
39
+ assert_equal IdealGateway.private_certificate.to_text,
40
+ OpenSSL::X509::Certificate.new(PRIVATE_CERTIFICATE).to_text
41
+ end
42
+
43
+ def test_private_key_returns_a_loaded_PKey_RSA_instance
44
+ assert_equal IdealGateway.private_key.to_text,
45
+ OpenSSL::PKey::RSA.new(PRIVATE_KEY, IdealGateway.passphrase).to_text
46
+ end
47
+
48
+ def test_ideal_certificate_returns_a_loaded_Certificate_instance
49
+ assert_equal IdealGateway.ideal_certificate.to_text,
50
+ OpenSSL::X509::Certificate.new(IDEAL_CERTIFICATE).to_text
51
+ end
52
+ end
53
+
54
+ class GeneralTest < Test::Unit::TestCase
55
+ def setup
56
+ @gateway = IdealGateway.new
57
+ end
58
+
59
+ def test_optional_initialization_options
60
+ assert_equal 0, IdealGateway.new.sub_id
61
+ assert_equal 1, IdealGateway.new(:sub_id => 1).sub_id
62
+ end
63
+
64
+ def test_returns_the_test_url_when_in_the_test_env
65
+ @gateway.stubs(:test?).returns(true)
66
+ assert_equal IdealGateway.test_url, @gateway.send(:acquirer_url)
67
+ end
68
+
69
+ def test_returns_the_live_url_when_not_in_the_test_env
70
+ @gateway.stubs(:test?).returns(false)
71
+ assert_equal IdealGateway.live_url, @gateway.send(:acquirer_url)
72
+ end
73
+
74
+ def test_returns_created_at_timestamp
75
+ timestamp = '2001-12-17T09:30:47.000Z'
76
+ Time.any_instance.stubs(:gmtime).returns(DateTime.parse(timestamp))
77
+
78
+ assert_equal timestamp, @gateway.send(:created_at_timestamp)
79
+ end
80
+
81
+ def test_ruby_to_java_keys_conversion
82
+ keys = [
83
+ [:acquirer_transaction_request, 'AcquirerTrxReq'],
84
+ [:acquirer_status_request, 'AcquirerStatusReq'],
85
+ [:directory_request, 'DirectoryReq'],
86
+ [:created_at, 'createDateTimeStamp'],
87
+ [:issuer, 'Issuer'],
88
+ [:merchant, 'Merchant'],
89
+ [:transaction, 'Transaction'],
90
+ [:issuer_id, 'issuerID'],
91
+ [:merchant_id, 'merchantID'],
92
+ [:sub_id, 'subID'],
93
+ [:token_code, 'tokenCode'],
94
+ [:merchant_return_url, 'merchantReturnURL'],
95
+ [:purchase_id, 'purchaseID'],
96
+ [:expiration_period, 'expirationPeriod'],
97
+ [:entrance_code, 'entranceCode']
98
+ ]
99
+
100
+ keys.each do |key, expected_key|
101
+ assert_equal expected_key, @gateway.send(:javaize_key, key)
102
+ end
103
+ end
104
+
105
+ def test_does_not_convert_unknown_key_to_java_key
106
+ assert_equal 'not_a_registered_key', @gateway.send(:javaize_key, :not_a_registered_key)
107
+ end
108
+
109
+ def test_token_generation
110
+ expected_token = Digest::SHA1.hexdigest(OpenSSL::X509::Certificate.new(PRIVATE_CERTIFICATE).to_der).upcase
111
+ assert_equal expected_token, @gateway.send(:token)
112
+ end
113
+
114
+ def test_token_code_generation
115
+ message = "Top\tsecret\tman.\nI could tell you, but then I'd have to kill you…"
116
+ stripped_message = message.gsub(/\s/m, '')
117
+
118
+ sha1 = OpenSSL::Digest::SHA1.new
119
+ OpenSSL::Digest::SHA1.stubs(:new).returns(sha1)
120
+
121
+ signature = IdealGateway.private_key.sign(sha1, stripped_message)
122
+ encoded_signature = Base64.encode64(signature).strip.gsub(/\n/, '')
123
+
124
+ assert_equal encoded_signature, @gateway.send(:token_code, message)
125
+ end
126
+
127
+ def test_posts_data_with_ssl_to_acquirer_url_and_return_the_correct_response
128
+ IdealResponse.expects(:new).with('response', :test => true)
129
+ @gateway.expects(:ssl_post).with(@gateway.acquirer_url, 'data').returns('response')
130
+ @gateway.send(:post_data, 'data', IdealResponse)
131
+
132
+ @gateway.stubs(:test?).returns(false)
133
+ IdealResponse.expects(:new).with('response', :test => false)
134
+ @gateway.expects(:ssl_post).with(@gateway.acquirer_url, 'data').returns('response')
135
+ @gateway.send(:post_data, 'data', IdealResponse)
136
+ end
137
+ end
138
+
139
+ class XMLBuildingTest < Test::Unit::TestCase
140
+ def setup
141
+ @gateway = IdealGateway.new
142
+ end
143
+
144
+ def test_contains_correct_info_in_root_node
145
+ expected_xml = Builder::XmlMarkup.new
146
+ expected_xml.instruct!
147
+ expected_xml.tag!('AcquirerTrxReq', 'xmlns' => IdealGateway::XML_NAMESPACE, 'version' => IdealGateway::API_VERSION) {}
148
+
149
+ assert_equal expected_xml.target!, @gateway.send(:xml_for, :acquirer_transaction_request, [])
150
+ end
151
+
152
+ def test_creates_correct_xml_with_java_keys_from_array_with_ruby_keys
153
+ expected_xml = Builder::XmlMarkup.new
154
+ expected_xml.instruct!
155
+ expected_xml.tag!('AcquirerTrxReq', 'xmlns' => IdealGateway::XML_NAMESPACE, 'version' => IdealGateway::API_VERSION) do
156
+ expected_xml.tag!('a_parent') do
157
+ expected_xml.tag!('createDateTimeStamp', '2009-01-26')
158
+ end
159
+ end
160
+
161
+ assert_equal expected_xml.target!, @gateway.send(:xml_for, :acquirer_transaction_request, [[:a_parent, [[:created_at, '2009-01-26']]]])
162
+ end
163
+ end
164
+
165
+ class RequestBodyBuildingTest < Test::Unit::TestCase
166
+ def setup
167
+ @gateway = IdealGateway.new
168
+
169
+ @gateway.stubs(:created_at_timestamp).returns('created_at_timestamp')
170
+ @gateway.stubs(:token).returns('the_token')
171
+ @gateway.stubs(:token_code)
172
+
173
+ @transaction_id = '0001023456789112'
174
+ end
175
+
176
+ def test_build_transaction_request_body_raises_ArgumentError_with_missing_required_options
177
+ options = VALID_PURCHASE_OPTIONS.dup
178
+ options.keys.each do |key|
179
+ options.delete(key)
180
+
181
+ assert_raise(ArgumentError) do
182
+ @gateway.send(:build_transaction_request_body, 100, options)
183
+ end
184
+ end
185
+ end
186
+
187
+ def test_valid_with_valid_options
188
+ assert_not_nil @gateway.send(:build_transaction_request_body, 4321, VALID_PURCHASE_OPTIONS)
189
+ end
190
+
191
+ def test_checks_that_fields_are_not_too_long
192
+ assert_raise ArgumentError do
193
+ @gateway.send(:build_transaction_request_body, 1234567890123, VALID_PURCHASE_OPTIONS) # 13 chars
194
+ end
195
+
196
+ [
197
+ [:order_id, '12345678901234567'], # 17 chars,
198
+ [:description, '123456789012345678901234567890123'], # 33 chars
199
+ [:entrance_code, '12345678901234567890123456789012345678901'] # 41
200
+ ].each do |key, value|
201
+ options = VALID_PURCHASE_OPTIONS.dup
202
+ options[key] = value
203
+
204
+ assert_raise ArgumentError do
205
+ @gateway.send(:build_transaction_request_body, 4321, options)
206
+ end
207
+ end
208
+ end
209
+
210
+ def test_checks_that_fields_do_not_contain_diacritical_characters
211
+ assert_raise ArgumentError do
212
+ @gateway.send(:build_transaction_request_body, 'graphème', VALID_PURCHASE_OPTIONS)
213
+ end
214
+
215
+ [:order_id, :description, :entrance_code].each do |key, value|
216
+ options = VALID_PURCHASE_OPTIONS.dup
217
+ options[key] = 'graphème'
218
+
219
+ assert_raise ArgumentError do
220
+ @gateway.send(:build_transaction_request_body, 4321, options)
221
+ end
222
+ end
223
+ end
224
+
225
+ def test_builds_a_transaction_request_body
226
+ money = 4321
227
+
228
+ message = 'created_at_timestamp' +
229
+ VALID_PURCHASE_OPTIONS[:issuer_id] +
230
+ IdealGateway.merchant_id +
231
+ @gateway.sub_id.to_s +
232
+ VALID_PURCHASE_OPTIONS[:return_url] +
233
+ VALID_PURCHASE_OPTIONS[:order_id] +
234
+ money.to_s +
235
+ IdealGateway::CURRENCY +
236
+ IdealGateway::LANGUAGE +
237
+ VALID_PURCHASE_OPTIONS[:description] +
238
+ VALID_PURCHASE_OPTIONS[:entrance_code]
239
+
240
+ @gateway.expects(:token_code).with(message).returns('the_token_code')
241
+
242
+ @gateway.expects(:xml_for).with(:acquirer_transaction_request, [
243
+ [:created_at, 'created_at_timestamp'],
244
+ [:issuer, [[:issuer_id, VALID_PURCHASE_OPTIONS[:issuer_id]]]],
245
+
246
+ [:merchant, [
247
+ [:merchant_id, IdealGateway.merchant_id],
248
+ [:sub_id, @gateway.sub_id],
249
+ [:authentication, IdealGateway::AUTHENTICATION_TYPE],
250
+ [:token, 'the_token'],
251
+ [:token_code, 'the_token_code'],
252
+ [:merchant_return_url, VALID_PURCHASE_OPTIONS[:return_url]]
253
+ ]],
254
+
255
+ [:transaction, [
256
+ [:purchase_id, VALID_PURCHASE_OPTIONS[:order_id]],
257
+ [:amount, money],
258
+ [:currency, IdealGateway::CURRENCY],
259
+ [:expiration_period, VALID_PURCHASE_OPTIONS[:expiration_period]],
260
+ [:language, IdealGateway::LANGUAGE],
261
+ [:description, VALID_PURCHASE_OPTIONS[:description]],
262
+ [:entrance_code, VALID_PURCHASE_OPTIONS[:entrance_code]]
263
+ ]]
264
+ ])
265
+
266
+ @gateway.send(:build_transaction_request_body, money, VALID_PURCHASE_OPTIONS)
267
+ end
268
+
269
+ def test_builds_a_directory_request_body
270
+ message = 'created_at_timestamp' + IdealGateway.merchant_id + @gateway.sub_id.to_s
271
+ @gateway.expects(:token_code).with(message).returns('the_token_code')
272
+
273
+ @gateway.expects(:xml_for).with(:directory_request, [
274
+ [:created_at, 'created_at_timestamp'],
275
+ [:merchant, [
276
+ [:merchant_id, IdealGateway.merchant_id],
277
+ [:sub_id, @gateway.sub_id],
278
+ [:authentication, IdealGateway::AUTHENTICATION_TYPE],
279
+ [:token, 'the_token'],
280
+ [:token_code, 'the_token_code']
281
+ ]]
282
+ ])
283
+
284
+ @gateway.send(:build_directory_request_body)
285
+ end
286
+
287
+ def test_builds_a_status_request_body_raises_ArgumentError_with_missing_required_options
288
+ assert_raise(ArgumentError) do
289
+ @gateway.send(:build_status_request_body, {})
290
+ end
291
+ end
292
+
293
+ def test_builds_a_status_request_body
294
+ options = { :transaction_id => @transaction_id }
295
+
296
+ message = 'created_at_timestamp' + IdealGateway.merchant_id + @gateway.sub_id.to_s + options[:transaction_id]
297
+ @gateway.expects(:token_code).with(message).returns('the_token_code')
298
+
299
+ @gateway.expects(:xml_for).with(:acquirer_status_request, [
300
+ [:created_at, 'created_at_timestamp'],
301
+ [:merchant, [
302
+ [:merchant_id, IdealGateway.merchant_id],
303
+ [:sub_id, @gateway.sub_id],
304
+ [:authentication, IdealGateway::AUTHENTICATION_TYPE],
305
+ [:token, 'the_token'],
306
+ [:token_code, 'the_token_code']
307
+ ]],
308
+
309
+ [:transaction, [
310
+ [:transaction_id, options[:transaction_id]]
311
+ ]],
312
+ ])
313
+
314
+ @gateway.send(:build_status_request_body, options)
315
+ end
316
+ end
317
+
318
+ class GeneralResponseTest < Test::Unit::TestCase
319
+ def test_resturns_if_it_is_a_test_request
320
+ assert IdealResponse.new(DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS, :test => true).test?
321
+
322
+ assert !IdealResponse.new(DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS, :test => false).test?
323
+ assert !IdealResponse.new(DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS).test?
324
+ end
325
+ end
326
+
327
+ class SuccessfulResponseTest < Test::Unit::TestCase
328
+ def setup
329
+ @response = IdealResponse.new(DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS)
330
+ end
331
+
332
+ def test_initializes_with_only_response_body
333
+ assert_equal REXML::Document.new(DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS).root.to_s,
334
+ @response.instance_variable_get(:@response).to_s
335
+ end
336
+
337
+ def test_successful
338
+ assert @response.success?
339
+ end
340
+
341
+ def test_returns_no_error_messages
342
+ assert_nil @response.error_message
343
+ end
344
+
345
+ def test_returns_no_error_code
346
+ assert_nil @response.error_code
347
+ end
348
+ end
349
+
350
+ class ErrorResponseTest < Test::Unit::TestCase
351
+ def setup
352
+ @response = IdealResponse.new(ERROR_RESPONSE)
353
+ end
354
+
355
+ def test_unsuccessful
356
+ assert !@response.success?
357
+ end
358
+
359
+ def test_returns_error_messages
360
+ assert_equal 'Failure in system', @response.error_message
361
+ assert_equal 'System generating error: issuer', @response.error_details
362
+ assert_equal 'Betalen met iDEAL is nu niet mogelijk.', @response.consumer_error_message
363
+ end
364
+
365
+ def test_returns_error_code
366
+ assert_equal 'SO1000', @response.error_code
367
+ end
368
+
369
+ def test_returns_error_type
370
+ [
371
+ ['IX1000', :xml],
372
+ ['SO1000', :system],
373
+ ['SE2000', :security],
374
+ ['BR1200', :value],
375
+ ['AP1000', :application]
376
+ ].each do |code, type|
377
+ @response.stubs(:error_code).returns(code)
378
+ assert_equal type, @response.error_type
379
+ end
380
+ end
381
+ end
382
+
383
+ class DirectoryTest < Test::Unit::TestCase
384
+ def setup
385
+ @gateway = IdealGateway.new
386
+ end
387
+
388
+ def test_returns_a_list_with_only_one_issuer
389
+ @gateway.stubs(:build_directory_request_body).returns('the request body')
390
+ @gateway.expects(:ssl_post).with(@gateway.acquirer_url, 'the request body').returns(DIRECTORY_RESPONSE_WITH_ONE_ISSUER)
391
+
392
+ expected_issuers = [{ :id => '1006', :name => 'ABN AMRO Bank' }]
393
+
394
+ directory_response = @gateway.issuers
395
+ assert_instance_of IdealDirectoryResponse, directory_response
396
+ assert_equal expected_issuers, directory_response.list
397
+ end
398
+
399
+ def test_returns_list_of_issuers_from_response
400
+ @gateway.stubs(:build_directory_request_body).returns('the request body')
401
+ @gateway.expects(:ssl_post).with(@gateway.acquirer_url, 'the request body').returns(DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS)
402
+
403
+ expected_issuers = [
404
+ { :id => '1006', :name => 'ABN AMRO Bank' },
405
+ { :id => '1003', :name => 'Postbank' },
406
+ { :id => '1005', :name => 'Rabobank' },
407
+ { :id => '1017', :name => 'Asr bank' },
408
+ { :id => '1023', :name => 'Van Lanschot' }
409
+ ]
410
+
411
+ directory_response = @gateway.issuers
412
+ assert_instance_of IdealDirectoryResponse, directory_response
413
+ assert_equal expected_issuers, directory_response.list
414
+ end
415
+ end
416
+
417
+ class SetupPurchaseTest < Test::Unit::TestCase
418
+ def setup
419
+ @gateway = IdealGateway.new
420
+
421
+ @gateway.stubs(:build_transaction_request_body).with(4321, VALID_PURCHASE_OPTIONS).returns('the request body')
422
+ @gateway.expects(:ssl_post).with(@gateway.acquirer_url, 'the request body').returns(ACQUIRER_TRANSACTION_RESPONSE)
423
+
424
+ @setup_purchase_response = @gateway.setup_purchase(4321, VALID_PURCHASE_OPTIONS)
425
+ end
426
+
427
+ def test_setup_purchase_returns_IdealTransactionResponse
428
+ assert_instance_of IdealTransactionResponse, @setup_purchase_response
429
+ end
430
+
431
+ def test_setup_purchase_returns_response_with_service_url
432
+ assert_equal 'https://ideal.example.com/long_service_url', @setup_purchase_response.service_url
433
+ end
434
+
435
+ def test_setup_purchase_returns_response_with_transaction_and_order_ids
436
+ assert_equal '0001023456789112', @setup_purchase_response.transaction_id
437
+ assert_equal 'iDEAL-aankoop 21', @setup_purchase_response.order_id
438
+ end
439
+ end
440
+
441
+ class CapturePurchaseTest < Test::Unit::TestCase
442
+ def setup
443
+ @gateway = IdealGateway.new
444
+
445
+ @gateway.stubs(:build_status_request_body).
446
+ with(:transaction_id => '0001023456789112').returns('the request body')
447
+ end
448
+
449
+ def test_setup_purchase_returns_IdealStatusResponse
450
+ expects_request_and_returns ACQUIRER_SUCCEEDED_STATUS_RESPONSE
451
+ assert_instance_of IdealStatusResponse, @gateway.capture('0001023456789112')
452
+ end
453
+
454
+ # Because we don't have a real private key and certificate we stub
455
+ # verified? to return true. However, this is properly tested in the remote
456
+ # tests.
457
+ def test_capture_of_successful_payment
458
+ IdealStatusResponse.any_instance.stubs(:verified?).returns(true)
459
+
460
+ expects_request_and_returns ACQUIRER_SUCCEEDED_STATUS_RESPONSE
461
+ capture_response = @gateway.capture('0001023456789112')
462
+
463
+ assert capture_response.success?
464
+ end
465
+
466
+ def test_capture_of_failed_payment
467
+ expects_request_and_returns ACQUIRER_FAILED_STATUS_RESPONSE
468
+ capture_response = @gateway.capture('0001023456789112')
469
+
470
+ assert !capture_response.success?
471
+ end
472
+
473
+ def test_capture_of_successful_payment_but_message_does_not_match_signature
474
+ expects_request_and_returns ACQUIRER_SUCCEEDED_BUT_WRONG_SIGNATURE_STATUS_RESPONSE
475
+ capture_response = @gateway.capture('0001023456789112')
476
+
477
+ assert !capture_response.success?
478
+ end
479
+
480
+ def test_returns_status
481
+ response = IdealStatusResponse.new(ACQUIRER_SUCCEEDED_STATUS_RESPONSE)
482
+ [
483
+ ['Success', :success],
484
+ ['Cancelled', :cancelled],
485
+ ['Expired', :expired],
486
+ ['Open', :open],
487
+ ['Failure', :failure]
488
+ ].each do |raw_status, expected_status|
489
+ response.stubs(:text).with("//status").returns(raw_status)
490
+ assert_equal expected_status, response.status
491
+ end
492
+ end
493
+
494
+ private
495
+
496
+ def expects_request_and_returns(str)
497
+ @gateway.expects(:ssl_post).with(@gateway.acquirer_url, 'the request body').returns(str)
498
+ end
499
+ end
500
+
501
+ ###
502
+ #
503
+ # Fixture data
504
+ #
505
+
506
+ PRIVATE_CERTIFICATE = %{-----BEGIN CERTIFICATE-----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CpWpsQQPF45/R5Xp7rXWWsjxgip7qTBNpgTx+Z/VKQpuQsFjYCYq4UCf2Y=
523
+ -----END CERTIFICATE-----}
524
+
525
+ PRIVATE_KEY = %{-----BEGIN RSA PRIVATE KEY-----
526
+ MIICXAIBAAKBgQDmBpi+RVvZBA01kdP5lV5bDzu6Jp1zy78qhxxwlG8WMdUh0Qtg
527
+ 0kkYmeThFPoh2c3BYuFQ+AA6f1R0Spb+hTNrBxkZaRnHCfMMD9LXquFjJ/lvSGnw
528
+ kjvBmGzyTPZ1LIunpejm8hH0MJPqpp5AIeXjp1mv7BXA9y0FqObrrLAPaQIDAQAB
529
+ AoGAfkccz0ewVoDc5424+wk/FWpVdaoBQjKWLbiiqkMygNK2mKv0PSD0M+c4OUCU
530
+ 2MSDKikoXJTpOzPvny/bmLpzMMGn9YJiWEQ5WdaTdppffdylfGPBZXZkt5M9nxJA
531
+ NL3fPT79R79mkCF8cgNUbLtNL4woSoFKwRHDU2CGvtTbxqkCQQD+TY1sGJv1VTQi
532
+ MYYx3FlEOqw3jp/2q7QluTDDGmvmVOSFnAPfmX0rKEtnBmG4ID7IaG+IQFthDudL
533
+ 3trqGQdTAkEA54+RxyCZiXDfkh23cD0QaApZaBuk6cKkx6qeFxeg1T+/idGgtWJI
534
+ Qg3i9fHzOIFUXwk51R3xh5IimvMJZ9Ii0wJAb7yrsx9tB3MUoSGZkTb8kholqZOl
535
+ fcEcOqcQYemuF1qdvoc6vHi4osnlt7L6JOkmLPCWcQu2GwNtZczZ65pruQJBAJ3p
536
+ vbtzUuF01TKbC18Cda7N5/zkZUl5ENCNXTRYS7lBuQhuqc8okChjufSJpJlTMUuC
537
+ Sis5OV5/3ROYTEC+ADsCQCwq6VQ1kXRrM+3tkMwi2rZi73dsFVuFx8crlBOmvhkD
538
+ U7Ar9bW13qhBeH9px8RCRDMWTGQcxY/C/TEQc/qvhkI=
539
+ -----END RSA PRIVATE KEY-----}
540
+
541
+ IDEAL_CERTIFICATE = %{-----BEGI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CMDQGCCsGAQUFBwEBBCgwJjAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AudmVy
558
+ aXNpZ24uY29tMG0GCCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAh
559
+ MB8wBwYFKw4DAhoEFI/l0xqGrI2Oa8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dv
560
+ LnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMA0GCSqGSIb3DQEBBQUAA34AY7BYsNvj
561
+ i5fjnEHPlGOd2yxseCHU54HDPPCZOoP9a9kVWGX8tuj2b1oeiOsIbI1viIo+O4eQ
562
+ ilZjTJIlLOkXk6uE8vQGjZy0BUnjNPkXOQGkTyj4jDxZ2z+z9Vy8BwfothdcYbZK
563
+ 48ZOp3u74DdEfQejNxBeqLODzrxQTV4=
564
+ -----END CERTIFICATE-----}
565
+
566
+ DIRECTORY_RESPONSE_WITH_ONE_ISSUER = %{<?xml version="1.0" encoding="UTF-8"?>
567
+ <DirectoryRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
568
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
569
+ <Acquirer>
570
+ <acquirerID>0245</acquirerID>
571
+ </Acquirer>
572
+ <Directory>
573
+ <directoryDateTimeStamp>2004-11-10T10:15:12.145Z</directoryDateTimeStamp>
574
+ <Issuer>
575
+ <issuerID>1006</issuerID>
576
+ <issuerName>ABN AMRO Bank</issuerName>
577
+ <issuerList>Short</issuerList>
578
+ </Issuer>
579
+ </Directory>
580
+ </DirectoryRes>}
581
+
582
+ DIRECTORY_RESPONSE_WITH_MULTIPLE_ISSUERS = %{<?xml version="1.0" encoding="UTF-8"?>
583
+ <DirectoryRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
584
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
585
+ <Acquirer>
586
+ <acquirerID>0245</acquirerID>
587
+ </Acquirer>
588
+ <Directory>
589
+ <directoryDateTimeStamp>2004-11-10T10:15:12.145Z</directoryDateTimeStamp>
590
+ <Issuer>
591
+ <issuerID>1006</issuerID>
592
+ <issuerName>ABN AMRO Bank</issuerName>
593
+ <issuerList>Short</issuerList>
594
+ </Issuer>
595
+ <Issuer>
596
+ <issuerID>1003</issuerID>
597
+ <issuerName>Postbank</issuerName>
598
+ <issuerList>Short</issuerList>
599
+ </Issuer>
600
+ <Issuer>
601
+ <issuerID>1005</issuerID>
602
+ <issuerName>Rabobank</issuerName>
603
+ <issuerList>Short</issuerList>
604
+ </Issuer>
605
+ <Issuer>
606
+ <issuerID>1017</issuerID>
607
+ <issuerName>Asr bank</issuerName>
608
+ <issuerList>Long</issuerList>
609
+ </Issuer>
610
+ <Issuer>
611
+ <issuerID>1023</issuerID>
612
+ <issuerName>Van Lanschot</issuerName>
613
+ <issuerList>Long</issuerList>
614
+ </Issuer>
615
+ </Directory>
616
+ </DirectoryRes>}
617
+
618
+ ACQUIRER_TRANSACTION_RESPONSE = %{<?xml version="1.0" encoding="UTF-8"?>
619
+ <AcquirerTrxRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
620
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
621
+ <Acquirer>
622
+ <acquirerID>1545</acquirerID>
623
+ </Acquirer>
624
+ <Issuer>
625
+ <issuerAuthenticationURL>https://ideal.example.com/long_service_url</issuerAuthenticationURL>
626
+ </Issuer>
627
+ <Transaction>
628
+ <transactionID>0001023456789112</transactionID>
629
+ <purchaseID>iDEAL-aankoop 21</purchaseID>
630
+ </Transaction>
631
+ </AcquirerTrxRes>}
632
+
633
+ ACQUIRER_SUCCEEDED_STATUS_RESPONSE = %{<?xml version="1.0" encoding="UTF-8"?>
634
+ <AcquirerStatusRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
635
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
636
+ <Acquirer>
637
+ <acquirerID>1234</acquirerID>
638
+ </Acquirer>
639
+ <Transaction>
640
+ <transactionID>0001023456789112</transactionID>
641
+ <status>Success</status>
642
+ <consumerName>Onderheuvel</consumerName>
643
+ <consumerAccountNumber>0949298989</consumerAccountNumber>
644
+ <consumerCity>DEN HAAG</consumerCity>
645
+ </Transaction>
646
+ <Signature>
647
+ <signatureValue>db82/jpJRvKQKoiDvu33X0yoDAQpayJOaW2Y8zbR1qk1i3epvTXi+6g+QVBY93YzGv4w+Va+vL3uNmzyRjYsm2309d1CWFVsn5Mk24NLSvhYfwVHEpznyMqizALEVUNSoiSHRkZUDfXowBAyLT/tQVGbuUuBj+TKblY826nRa7U=</signatureValue>
648
+ <fingerprint>1E15A00E3D7DF085768749D4ABBA3284794D8AE9</fingerprint>
649
+ </Signature>
650
+ </AcquirerStatusRes>}
651
+
652
+ ACQUIRER_SUCCEEDED_BUT_WRONG_SIGNATURE_STATUS_RESPONSE = %{<?xml version="1.0" encoding="UTF-8"?>
653
+ <AcquirerStatusRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
654
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
655
+ <Acquirer>
656
+ <acquirerID>1234</acquirerID>
657
+ </Acquirer>
658
+ <Transaction>
659
+ <transactionID>0001023456789112</transactionID>
660
+ <status>Success</status>
661
+ <consumerName>Onderheuvel</consumerName>
662
+ <consumerAccountNumber>0949298989</consumerAccountNumber>
663
+ <consumerCity>DEN HAAG</consumerCity>
664
+ </Transaction>
665
+ <Signature>
666
+ <signatureValue>WRONG</signatureValue>
667
+ <fingerprint>1E15A00E3D7DF085768749D4ABBA3284794D8AE9</fingerprint>
668
+ </Signature>
669
+ </AcquirerStatusRes>}
670
+
671
+ ACQUIRER_FAILED_STATUS_RESPONSE = %{<?xml version="1.0" encoding="UTF-8"?>
672
+ <AcquirerStatusRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
673
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
674
+ <Acquirer>
675
+ <acquirerID>1234</acquirerID>
676
+ </Acquirer>
677
+ <Transaction>
678
+ <transactionID>0001023456789112</transactionID>
679
+ <status>Failed</status>
680
+ <consumerName>Onderheuvel</consumerName>
681
+ <consumerAccountNumber>0949298989</consumerAccountNumber>
682
+ <consumerCity>DEN HAAG</consumerCity>
683
+ </Transaction>
684
+ <Signature>
685
+ <signatureValue>db82/jpJRvKQKoiDvu33X0yoDAQpayJOaW2Y8zbR1qk1i3epvTXi+6g+QVBY93YzGv4w+Va+vL3uNmzyRjYsm2309d1CWFVsn5Mk24NLSvhYfwVHEpznyMqizALEVUNSoiSHRkZUDfXowBAyLT/tQVGbuUuBj+TKblY826nRa7U=</signatureValue>
686
+ <fingerprint>1E15A00E3D7DF085768749D4ABBA3284794D8AE9</fingerprint>
687
+ </Signature>
688
+ </AcquirerStatusRes>}
689
+
690
+ ERROR_RESPONSE = %{<?xml version="1.0" encoding="UTF-8"?>
691
+ <ErrorRes xmlns="http://www.idealdesk.com/Message" version="1.1.0">
692
+ <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
693
+ <Error>
694
+ <errorCode>SO1000</errorCode>
695
+ <errorMessage>Failure in system</errorMessage>
696
+ <errorDetail>System generating error: issuer</errorDetail>
697
+ <suggestedAction></suggestedAction>
698
+ <suggestedExpirationPeriod></suggestedExpirationPeriod>
699
+ <consumerMessage>Betalen met iDEAL is nu niet mogelijk.</consumerMessage>
700
+ </Error>
701
+ </ErrorRes>}
702
+
703
+ setup_ideal_gateway!
704
+ end