-
Notifications
You must be signed in to change notification settings - Fork 14
/
request_apm_payments_integration_spec.rb
514 lines (435 loc) · 21.6 KB
/
request_apm_payments_integration_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
RSpec.describe CheckoutSdk::Payments do
describe '.request_payments (APMs)' do
context 'when requesting AfterPay source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::AfterPaySource.new
source.account_holder = common_account_holder
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 10
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }.to raise_error(CheckoutSdk::CheckoutApiException)
end
end
context 'when requesting AliPay source payment' do
it 'type:CN - raises an error' do
source = CheckoutSdk::Payments::AlipayPlusSource.alipay_plus_cn_source
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }.to raise_error(CheckoutSdk::CheckoutApiException)
end
end
context 'when requesting Bancontact source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::BancontactSource.new
source.payment_country = CheckoutSdk::Common::Country::BE
source.account_holder_name = Helpers::DataFactory::NAME
source.billing_descriptor = 'CKO Demo - bancontact'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
response = default_sdk.payments.request_payment(request)
expect(response).not_to be nil
expect(response.id).not_to be nil
end
end
context 'when requesting Benefit source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::BenefitSource.new
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::BHD
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting EPS source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::EPSSource.new
source.purpose = 'test purpose'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Giropay source payment' do
skip 'Until it is fixed in Sandbox'
skip 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::GiropaySource.new
shipping = CheckoutSdk::Payments::ShippingDetails.new
shipping.address = address
shipping.phone = phone
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.description = Helpers::DataFactory::DESCRIPTION
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.shipping = shipping
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Ideal source payment' do
it 'should request payment correctly' do
source = CheckoutSdk::Payments::IdealSource.new
source.bic = 'INGBNL2A'
source.description = 'ORD50234E89'
source.language = 'nl'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 1000
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
response = default_sdk.payments.request_payment(request)
expect(response).not_to be nil
expect(response.id).not_to be nil
payment_details = default_sdk.payments.get_payment_details(response.id)
expect(payment_details).not_to be nil
expect(payment_details.id).to eq response.id
expect(payment_details.source.type).to eq CheckoutSdk::Common::PaymentSourceType::IDEAL
end
end
context 'when requesting Knet source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::KnetSource.new
source.language = 'en'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::KWD
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
skip 'Mbway - processing channel invalid' do
context 'when requesting Mbway source payment' do
it 'raises an error (apm_service_unavailable)' do
source = CheckoutSdk::Payments::MbwaySource.new
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::GBP
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'apm_service_unavailable' }
end
end
end
context 'when requesting MultiBanco source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::MultiBancoSource.new
source.payment_country = CheckoutSdk::Common::Country::PT
source.account_holder_name = Helpers::DataFactory::NAME
source.billing_descriptor = 'CKO Demo - MultiBanco'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
skip 'when requesting P24 source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::P24Source.new
source.payment_country = CheckoutSdk::Common::Country::PL
source.account_holder_name = Helpers::DataFactory::NAME
source.account_holder_email = generate_random_email
source.billing_descriptor = 'CKO Demo - P24'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::PLN
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting PostFinance source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::PostFinanceSource.new
source.payment_country = CheckoutSdk::Common::Country::CH
source.account_holder_name = Helpers::DataFactory::NAME
source.billing_descriptor = 'CKO Demo - PostFinance'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting QPay source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::QPaySource.new
source.description = Helpers::DataFactory::DESCRIPTION
source.language = 'en'
source.quantity = 1
source.national_id = '070AYY010BU234M'
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::QAR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Sofort source payment' do
it 'should request payment correctly' do
source = CheckoutSdk::Payments::SofortSource.new
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 1000
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
response = default_sdk.payments.request_payment(request)
expect(response).not_to be nil
expect(response.id).not_to be nil
payment_details = default_sdk.payments.get_payment_details(response.id)
expect(payment_details).not_to be nil
expect(payment_details.id).to eq response.id
expect(payment_details.source.type).to eq CheckoutSdk::Common::PaymentSourceType::SOFORT
end
end
context 'when requesting StcPay source payment' do
it 'raises an error (apm_service_unavailable)' do
source = CheckoutSdk::Payments::StcPaySource.new
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::QAR
request.amount = 100
request.capture = true
request.customer = common_customer_request
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException)
end
end
context 'when requesting WeChatPay source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::WeChatPaySource.new
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 100
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Alma source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::AlmaSource.new
source.billing_address = address
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 10
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Klarna source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::KlarnaSource.new
source.account_holder = common_account_holder
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 10
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'custom_data_required' }
end
end
context 'when requesting Paypal source payment', skip: 'unavailable' do
it 'raises an error (payee_not_onboarded)' do
plan = CheckoutSdk::Payments::BillingPlan.new
plan.type = CheckoutSdk::Payments::BillingPlanType::CHANNEL_INITIATED_BILLING
plan.immutable_shipping_address = false
plan.skip_shipping_address = true
source = CheckoutSdk::Payments::PayPalSource.new
source.plan = plan
product = CheckoutSdk::Payments::Product.new
product.name = 'laptop'
product.unit_price = 10
product.quantity = 1
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EUR
request.amount = 10
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
request.items = [product]
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Fawry source payment' do
it 'raises an error (payee_not_onboarded)' do
product = CheckoutSdk::Payments::FawryProduct.new
product.product_id = '0123456789'
product.quantity = 1
product.price = 10
product.description = 'Fawry Demo Product'
source = CheckoutSdk::Payments::FawrySource.new
source.description = 'Fawry Demo Payment'
source.customer_email = 'bruce@wayne-enterprises.com'
source.customer_mobile = '01058375055'
source.products = [product]
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.reference = Helpers::DataFactory::REFERENCE
request.currency = CheckoutSdk::Common::Currency::EGP
request.amount = 10
request.capture = true
request.success_url = 'https://testing.checkout.com/sucess'
request.failure_url = 'https://testing.checkout.com/failure'
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e| expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
end
context 'when requesting CvConnect source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::CvConnectSource.new
source.billing_address = address
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.amount = 100
request.currency = CheckoutSdk::Common::Currency::EUR
request.capture = true
request.success_url = Helpers::DataFactory::SUCCESS_URL
request.failure_url = Helpers::DataFactory::FAILURE_URL
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e|
expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Trustly source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::TrustlySource.new
source.billing_address = address
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.amount = 100
request.currency = CheckoutSdk::Common::Currency::EUR
request.capture = true
request.success_url = Helpers::DataFactory::SUCCESS_URL
request.failure_url = Helpers::DataFactory::FAILURE_URL
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e|
expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Illicado source payment' do
it 'raises an error (payee_not_onboarded)' do
source = CheckoutSdk::Payments::IllicadoSource.new
source.billing_address = address
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.amount = 100
request.currency = CheckoutSdk::Common::Currency::EUR
request.capture = true
request.success_url = Helpers::DataFactory::SUCCESS_URL
request.failure_url = Helpers::DataFactory::FAILURE_URL
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e|
expect(e.error_details[:error_codes].first).to eq 'payee_not_onboarded' }
end
end
context 'when requesting Sepa source payment' do
it 'raises an error (apm_service_unavailable)' do
source = CheckoutSdk::Payments::SepaSource.new
source.country = CheckoutSdk::Common::Country::ES
source.account_number = "HU93116000060000000012345676"
source.bank_code = "37040044"
source.currency = CheckoutSdk::Common::Currency::EUR
source.mandate_id = "man_12321233211"
source.date_of_signature = "2023-01-01"
source.account_holder = common_account_holder
request = CheckoutSdk::Payments::PaymentRequest.new
request.source = source
request.amount = 100
request.currency = CheckoutSdk::Common::Currency::EUR
request.capture = true
request.success_url = Helpers::DataFactory::SUCCESS_URL
request.failure_url = Helpers::DataFactory::FAILURE_URL
expect { default_sdk.payments.request_payment(request) }
.to raise_error(CheckoutSdk::CheckoutApiException) { |e|
expect(e.error_details[:error_codes].first).to eq 'apm_service_unavailable' }
end
end
end