adyen-ruby-api-library 11.3.0 → 12.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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -2
  3. data/Gemfile +2 -2
  4. data/README.md +30 -7
  5. data/VERSION +1 -1
  6. data/adyen-ruby-api-library.gemspec +1 -1
  7. data/lib/adyen/client.rb +6 -11
  8. data/lib/adyen/deprecation.rb +34 -0
  9. data/lib/adyen/services/balanceControl/balance_control_api.rb +2 -0
  10. data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +0 -40
  11. data/lib/adyen/services/balancePlatform/custom_payout_schedules_sweeps_api.rb +56 -0
  12. data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +2 -0
  13. data/lib/adyen/services/balancePlatform/grant_offers_api.rb +4 -0
  14. data/lib/adyen/services/balancePlatform/managed_payout_schedules_api.rb +80 -0
  15. data/lib/adyen/services/balancePlatform/recurring_top_ups_api.rb +48 -0
  16. data/lib/adyen/services/balancePlatform/sca_device_management_api.rb +8 -0
  17. data/lib/adyen/services/balancePlatform.rb +15 -0
  18. data/lib/adyen/services/checkout/payments_api.rb +8 -0
  19. data/lib/adyen/services/checkout/utility_api.rb +2 -0
  20. data/lib/adyen/services/checkout.rb +1 -1
  21. data/lib/adyen/services/management/donation_campaigns_api.rb +64 -0
  22. data/lib/adyen/services/management.rb +5 -0
  23. data/lib/adyen/services/payment/modifications_api.rb +2 -0
  24. data/lib/adyen/services/posMobile/pos_mobile_api.rb +5 -0
  25. data/lib/adyen/services/posTerminalManagement.rb +10 -0
  26. data/lib/adyen/services/recurring/recurring_api.rb +4 -0
  27. data/lib/adyen/services/service.rb +2 -0
  28. data/lib/adyen/services/transfers/capital_api.rb +6 -0
  29. data/lib/adyen/services/transfers/cash_out_api.rb +24 -0
  30. data/lib/adyen/services/transfers.rb +5 -0
  31. data/lib/adyen/utils/hmac_validator.rb +15 -17
  32. data/lib/adyen/version.rb +1 -1
  33. data/sdk-generation-log/balanceplatform.json +4 -4
  34. data/sdk-generation-log/checkout.json +4 -4
  35. data/sdk-generation-log/management.json +4 -4
  36. data/sdk-generation-log/posmobile.json +4 -4
  37. data/sdk-generation-log/transfers.json +4 -4
  38. data/spec/balance_control_spec.rb +41 -0
  39. data/spec/balance_platform_spec.rb +498 -4
  40. data/spec/checkout-oauth_spec.rb +220 -10
  41. data/spec/checkout_spec.rb +245 -10
  42. data/spec/client_spec.rb +1 -5
  43. data/spec/deprecation_spec.rb +112 -0
  44. data/spec/management_spec.rb +184 -0
  45. data/spec/mocks/requests/BalancePlatform/apply_managed_schedule.json +14 -0
  46. data/spec/mocks/requests/BalancePlatform/begin_sca_device_registration.json +4 -0
  47. data/spec/mocks/requests/BalancePlatform/create_recurring_top_up.json +21 -0
  48. data/spec/mocks/requests/BalancePlatform/create_sweep.json +10 -0
  49. data/spec/mocks/requests/BalancePlatform/finish_sca_device_registration.json +3 -0
  50. data/spec/mocks/requests/BalancePlatform/submit_sca_association.json +8 -0
  51. data/spec/mocks/requests/BalancePlatform/update_balance_account_managed_schedule.json +5 -0
  52. data/spec/mocks/requests/BalancePlatform/update_recurring_top_ups.json +3 -0
  53. data/spec/mocks/requests/BalancePlatform/update_sweep.json +6 -0
  54. data/spec/mocks/requests/Checkout/amount_updates.json +1 -1
  55. data/spec/mocks/requests/Checkout/card_details.json +3 -0
  56. data/spec/mocks/requests/Checkout/create_stored_payment_method.json +10 -0
  57. data/spec/mocks/requests/Checkout/donation_campaigns.json +4 -0
  58. data/spec/mocks/requests/Checkout/donations.json +9 -0
  59. data/spec/mocks/requests/Checkout/orders.json +5 -3
  60. data/spec/mocks/requests/Checkout/payment-details.json +2 -14
  61. data/spec/mocks/requests/Checkout/payment_methods_balance.json +5 -2
  62. data/spec/mocks/requests/Checkout/payments.json +9 -10
  63. data/spec/mocks/requests/Checkout/paypal_update_order.json +5 -0
  64. data/spec/mocks/requests/Checkout/reversals.json +3 -0
  65. data/spec/mocks/requests/Checkout/update_session.json +7 -0
  66. data/spec/mocks/requests/Management/create_donation_campaign.json +7 -0
  67. data/spec/mocks/requests/Management/list_nonprofits.json +5 -0
  68. data/spec/mocks/requests/Management/update_donation_campaign.json +6 -0
  69. data/spec/mocks/requests/Transfers/initiate_cashout.json +12 -0
  70. data/spec/mocks/responses/BalancePlatform/apply_managed_schedule.json +17 -0
  71. data/spec/mocks/responses/BalancePlatform/begin_sca_device_registration.json +8 -0
  72. data/spec/mocks/responses/BalancePlatform/create_recurring_top_up.json +23 -0
  73. data/spec/mocks/responses/BalancePlatform/create_sweep.json +12 -0
  74. data/spec/mocks/responses/BalancePlatform/finish_sca_device_registration.json +7 -0
  75. data/spec/mocks/responses/BalancePlatform/get_all_sweeps_for_balance_account.json +31 -0
  76. data/spec/mocks/responses/BalancePlatform/get_balance_account_managed_schedule_by_id.json +17 -0
  77. data/spec/mocks/responses/BalancePlatform/get_balance_account_managed_schedules.json +26 -0
  78. data/spec/mocks/responses/BalancePlatform/get_balance_platform_managed_schedule_by_id.json +27 -0
  79. data/spec/mocks/responses/BalancePlatform/get_balance_platform_managed_schedules.json +31 -0
  80. data/spec/mocks/responses/BalancePlatform/get_payout_schedule_executions.json +21 -0
  81. data/spec/mocks/responses/BalancePlatform/get_recurring_top_ups.json +35 -0
  82. data/spec/mocks/responses/BalancePlatform/get_sweep.json +12 -0
  83. data/spec/mocks/responses/BalancePlatform/submit_sca_association.json +10 -0
  84. data/spec/mocks/responses/BalancePlatform/update_balance_account_managed_schedule.json +18 -0
  85. data/spec/mocks/responses/BalancePlatform/update_recurring_top_ups.json +23 -0
  86. data/spec/mocks/responses/BalancePlatform/update_sweep.json +12 -0
  87. data/spec/mocks/responses/Checkout/amount_updates.json +1 -1
  88. data/spec/mocks/responses/Checkout/card_details.json +5 -0
  89. data/spec/mocks/responses/Checkout/create_stored_payment_method.json +5 -0
  90. data/spec/mocks/responses/Checkout/donation_campaigns.json +1 -0
  91. data/spec/mocks/responses/Checkout/donations.json +5 -0
  92. data/spec/mocks/responses/Checkout/orders.json +6 -1
  93. data/spec/mocks/responses/Checkout/orders_cancel.json +1 -1
  94. data/spec/mocks/responses/Checkout/payment-details.json +2 -13
  95. data/spec/mocks/responses/Checkout/payment_links.json +3 -0
  96. data/spec/mocks/responses/Checkout/payment_methods.json +2 -2
  97. data/spec/mocks/responses/Checkout/payment_methods_balance.json +5 -1
  98. data/spec/mocks/responses/Checkout/payments.json +4 -94
  99. data/spec/mocks/responses/Checkout/paypal_update_order.json +4 -0
  100. data/spec/mocks/responses/Checkout/reversals.json +6 -0
  101. data/spec/mocks/responses/Checkout/update_session.json +3 -0
  102. data/spec/mocks/responses/Management/donation_campaign.json +13 -0
  103. data/spec/mocks/responses/Management/list_donation_campaigns.json +19 -0
  104. data/spec/mocks/responses/Management/list_nonprofits.json +34 -0
  105. data/spec/mocks/responses/Transfers/initiate_cashout.json +31 -0
  106. data/spec/spec_helper.rb +2 -2
  107. data/spec/transfers_spec.rb +28 -0
  108. data/spec/utils/consumer_smoke.rb +23 -0
  109. data/spec/utils/hmac_validator_spec.rb +55 -0
  110. data/templates/api-small.mustache +4 -2
  111. data/templates/api.mustache +4 -2
  112. metadata +58 -2
@@ -12,7 +12,7 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
12
12
  end
13
13
 
14
14
  # must be created manually because every field in the response is an array
15
- it "makes a payment_methods call", focus: true do
15
+ it "makes a payment_methods call" do
16
16
  request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods.json"))
17
17
 
18
18
  response_body = json_from_file("mocks/responses/Checkout/payment_methods.json")
@@ -67,8 +67,8 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
67
67
  to be_a Adyen::HashWithAccessors
68
68
  expect(response_hash).
69
69
  to be_a_kind_of Hash
70
- expect(response_hash["balance"]).
71
- to eq("100")
70
+ expect(response_hash["balance"]["value"]).
71
+ to eq(100)
72
72
  end
73
73
 
74
74
  # must be created manually due to payments/details format
@@ -118,14 +118,15 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
118
118
  headers: @auth_header
119
119
  ).
120
120
  to_return(
121
- body: response_body
121
+ body: response_body,
122
+ status: 201
122
123
  )
123
124
 
124
125
  result = @shared_values[:client].checkout.payment_links_api.payment_links(request_body)
125
126
  response_hash = result.response
126
127
 
127
128
  expect(result.status).
128
- to eq(200)
129
+ to eq(201)
129
130
  expect(response_hash).
130
131
  to eq(JSON.parse(response_body))
131
132
  expect(response_hash).
@@ -256,7 +257,7 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
256
257
  expect(response_hash).
257
258
  to be_a_kind_of Hash
258
259
  expect(response_hash["resultCode"]).
259
- to eq("cancelled")
260
+ to eq("Received")
260
261
  end
261
262
 
262
263
  it "makes an applePay/sessions call" do
@@ -315,6 +316,214 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
315
316
  to be_a_kind_of Hash
316
317
  end
317
318
 
319
+ it "makes an update_session PATCH call" do
320
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/update_session.json"))
321
+
322
+ response_body = json_from_file("mocks/responses/Checkout/update_session.json")
323
+
324
+ url = @shared_values[:client].service_url(@shared_values[:service], "sessions/CS0123456789ABCDEF", @shared_values[:client].checkout.version)
325
+ WebMock.stub_request(:patch, url).
326
+ with(
327
+ body: request_body,
328
+ headers: @auth_header
329
+ ).
330
+ to_return(body: response_body)
331
+
332
+ result = @shared_values[:client].checkout.payments_api.update_session(request_body, "CS0123456789ABCDEF")
333
+ response_hash = result.response
334
+
335
+ expect(result.status).
336
+ to eq(200)
337
+ expect(response_hash).
338
+ to eq(JSON.parse(response_body))
339
+ expect(response_hash).
340
+ to be_a Adyen::HashWithAccessors
341
+ expect(response_hash).
342
+ to be_a_kind_of Hash
343
+ end
344
+
345
+ it "makes a cardDetails call" do
346
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/card_details.json"))
347
+
348
+ response_body = json_from_file("mocks/responses/Checkout/card_details.json")
349
+
350
+ url = @shared_values[:client].service_url(@shared_values[:service], "cardDetails", @shared_values[:client].checkout.version)
351
+ WebMock.stub_request(:post, url).
352
+ with(
353
+ body: request_body,
354
+ headers: @auth_header
355
+ ).
356
+ to_return(body: response_body)
357
+
358
+ result = @shared_values[:client].checkout.payments_api.card_details(request_body)
359
+ response_hash = result.response
360
+
361
+ expect(result.status).
362
+ to eq(200)
363
+ expect(response_hash).
364
+ to eq(JSON.parse(response_body))
365
+ expect(response_hash).
366
+ to be_a Adyen::HashWithAccessors
367
+ expect(response_hash).
368
+ to be_a_kind_of Hash
369
+ end
370
+
371
+ it "makes a donationCampaigns call" do
372
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/donation_campaigns.json"))
373
+
374
+ response_body = json_from_file("mocks/responses/Checkout/donation_campaigns.json")
375
+
376
+ url = @shared_values[:client].service_url(@shared_values[:service], "donationCampaigns", @shared_values[:client].checkout.version)
377
+ WebMock.stub_request(:post, url).
378
+ with(
379
+ body: request_body,
380
+ headers: @auth_header
381
+ ).
382
+ to_return(body: response_body)
383
+
384
+ result = @shared_values[:client].checkout.donations_api.donation_campaigns(request_body)
385
+ response_hash = result.response
386
+
387
+ expect(result.status).
388
+ to eq(200)
389
+ expect(response_hash).
390
+ to eq(JSON.parse(response_body))
391
+ expect(response_hash).
392
+ to be_a Adyen::HashWithAccessors
393
+ expect(response_hash).
394
+ to be_a_kind_of Hash
395
+ end
396
+
397
+ it "makes a donations call" do
398
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/donations.json"))
399
+
400
+ response_body = json_from_file("mocks/responses/Checkout/donations.json")
401
+
402
+ url = @shared_values[:client].service_url(@shared_values[:service], "donations", @shared_values[:client].checkout.version)
403
+ WebMock.stub_request(:post, url).
404
+ with(
405
+ body: request_body,
406
+ headers: @auth_header
407
+ ).
408
+ to_return(body: response_body)
409
+
410
+ result = @shared_values[:client].checkout.donations_api.donations(request_body)
411
+ response_hash = result.response
412
+
413
+ expect(result.status).
414
+ to eq(200)
415
+ expect(response_hash).
416
+ to eq(JSON.parse(response_body))
417
+ expect(response_hash).
418
+ to be_a Adyen::HashWithAccessors
419
+ expect(response_hash).
420
+ to be_a_kind_of Hash
421
+ end
422
+
423
+ it "makes a payments call" do
424
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payments.json"))
425
+
426
+ response_body = json_from_file("mocks/responses/Checkout/payments.json")
427
+
428
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments", @shared_values[:client].checkout.version)
429
+ WebMock.stub_request(:post, url).
430
+ with(
431
+ body: request_body,
432
+ headers: @auth_header
433
+ ).
434
+ to_return(body: response_body)
435
+
436
+ result = @shared_values[:client].checkout.payments_api.payments(request_body)
437
+ response_hash = result.response
438
+
439
+ expect(result.status).
440
+ to eq(200)
441
+ expect(response_hash).
442
+ to eq(JSON.parse(response_body))
443
+ expect(response_hash).
444
+ to be_a Adyen::HashWithAccessors
445
+ expect(response_hash).
446
+ to be_a_kind_of Hash
447
+ end
448
+
449
+ it "makes a reversals call" do
450
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/reversals.json"))
451
+
452
+ response_body = json_from_file("mocks/responses/Checkout/reversals.json")
453
+
454
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments/8535678901234567/reversals", @shared_values[:client].checkout.version)
455
+ WebMock.stub_request(:post, url).
456
+ with(
457
+ body: request_body,
458
+ headers: @auth_header
459
+ ).
460
+ to_return(body: response_body, status: 201)
461
+
462
+ result = @shared_values[:client].checkout.modifications_api.refund_or_cancel_payment(request_body, "8535678901234567")
463
+ response_hash = result.response
464
+
465
+ expect(result.status).
466
+ to eq(201)
467
+ expect(response_hash).
468
+ to eq(JSON.parse(response_body))
469
+ expect(response_hash).
470
+ to be_a Adyen::HashWithAccessors
471
+ expect(response_hash).
472
+ to be_a_kind_of Hash
473
+ end
474
+
475
+ it "makes a paypal/updateOrder call" do
476
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/paypal_update_order.json"))
477
+
478
+ response_body = json_from_file("mocks/responses/Checkout/paypal_update_order.json")
479
+
480
+ url = @shared_values[:client].service_url(@shared_values[:service], "paypal/updateOrder", @shared_values[:client].checkout.version)
481
+ WebMock.stub_request(:post, url).
482
+ with(
483
+ body: request_body,
484
+ headers: @auth_header
485
+ ).
486
+ to_return(body: response_body)
487
+
488
+ result = @shared_values[:client].checkout.utility_api.updates_order_for_paypal_express_checkout(request_body)
489
+ response_hash = result.response
490
+
491
+ expect(result.status).
492
+ to eq(200)
493
+ expect(response_hash).
494
+ to eq(JSON.parse(response_body))
495
+ expect(response_hash).
496
+ to be_a Adyen::HashWithAccessors
497
+ expect(response_hash).
498
+ to be_a_kind_of Hash
499
+ end
500
+
501
+ it "makes a storedPaymentMethods POST call" do
502
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/create_stored_payment_method.json"))
503
+
504
+ response_body = json_from_file("mocks/responses/Checkout/create_stored_payment_method.json")
505
+
506
+ url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods", @shared_values[:client].checkout.version)
507
+ WebMock.stub_request(:post, url).
508
+ with(
509
+ body: request_body,
510
+ headers: @auth_header
511
+ ).
512
+ to_return(body: response_body, status: 201)
513
+
514
+ result = @shared_values[:client].checkout.recurring_api.stored_payment_methods(request_body)
515
+ response_hash = result.response
516
+
517
+ expect(result.status).
518
+ to eq(201)
519
+ expect(response_hash).
520
+ to eq(JSON.parse(response_body))
521
+ expect(response_hash).
522
+ to be_a Adyen::HashWithAccessors
523
+ expect(response_hash).
524
+ to be_a_kind_of Hash
525
+ end
526
+
318
527
  it "makes a capture call" do
319
528
  request_body = JSON.parse(json_from_file("mocks/requests/Checkout/capture.json"))
320
529
 
@@ -530,14 +739,15 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
530
739
  headers: @auth_header
531
740
  ).
532
741
  to_return(
533
- body: "{}"
742
+ status: 204,
743
+ body: ""
534
744
  )
535
745
 
536
746
  result = @shared_values[:client].checkout.recurring_api.delete_token_for_stored_payment_details("RL8FW7WZM6KXWD82", query_params:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
537
747
  response_hash = result.response
538
748
 
539
749
  expect(result.status).
540
- to eq(200)
750
+ to eq(204)
541
751
  end
542
752
 
543
753
  it "tests sending the application headers" do
@@ -554,7 +764,7 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
554
764
 
555
765
  result = @shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(query_params:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
556
766
  expect(
557
- a_request(:get, "http://localhost:3001/v71/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234")
767
+ a_request(:get, "http://localhost:3001/v72/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234")
558
768
  .with(headers: {
559
769
  'Accept' => '*/*',
560
770
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
@@ -580,7 +790,7 @@ RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
580
790
  url = adyen.service_url("Checkout", "paymentMethods", @shared_values[:client].checkout.version)
581
791
 
582
792
  expect(url).
583
- to eq("https://prefix-checkout-live.adyenpayments.com/checkout/v71/paymentMethods")
793
+ to eq("https://prefix-checkout-live.adyenpayments.com/checkout/v72/paymentMethods")
584
794
 
585
795
  end
586
796
  end
@@ -10,7 +10,7 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
10
10
  end
11
11
 
12
12
  it 'uses the correct PaymentsApi for the Checkout service' do
13
- # Load both API files to ensure there's no conflict after the fix.
13
+ # Load both API files to ensure there's no conflict.
14
14
  load File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__)
15
15
  load File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__)
16
16
 
@@ -84,8 +84,8 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
84
84
  .to be_a Adyen::HashWithAccessors
85
85
  expect(response_hash)
86
86
  .to be_a_kind_of Hash
87
- expect(response_hash['balance'])
88
- .to eq('100')
87
+ expect(response_hash['balance']['value'])
88
+ .to eq(100)
89
89
  end
90
90
 
91
91
  # must be created manually due to payments/details format
@@ -141,14 +141,15 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
141
141
  }
142
142
  )
143
143
  .to_return(
144
- body: response_body
144
+ body: response_body,
145
+ status: 201
145
146
  )
146
147
 
147
148
  result = @shared_values[:client].checkout.payment_links_api.payment_links(request_body)
148
149
  response_hash = result.response
149
150
 
150
151
  expect(result.status)
151
- .to eq(200)
152
+ .to eq(201)
152
153
  expect(response_hash)
153
154
  .to eq(JSON.parse(response_body))
154
155
  expect(response_hash)
@@ -291,7 +292,7 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
291
292
  expect(response_hash)
292
293
  .to be_a_kind_of Hash
293
294
  expect(response_hash['resultCode'])
294
- .to eq('cancelled')
295
+ .to eq('Received')
295
296
  end
296
297
 
297
298
  it 'makes an applePay/sessions call' do
@@ -356,6 +357,239 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
356
357
  .to be_a_kind_of Hash
357
358
  end
358
359
 
360
+ it 'makes an update_session PATCH call' do
361
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/update_session.json'))
362
+
363
+ response_body = json_from_file('mocks/responses/Checkout/update_session.json')
364
+
365
+ url = @shared_values[:client].service_url(@shared_values[:service], 'sessions/CS0123456789ABCDEF',
366
+ @shared_values[:client].checkout.version)
367
+ WebMock.stub_request(:patch, url)
368
+ .with(
369
+ body: request_body,
370
+ headers: {
371
+ 'x-api-key' => @shared_values[:client].api_key
372
+ }
373
+ )
374
+ .to_return(body: response_body)
375
+
376
+ result = @shared_values[:client].checkout.payments_api.update_session(request_body, 'CS0123456789ABCDEF')
377
+ response_hash = result.response
378
+
379
+ expect(result.status)
380
+ .to eq(200)
381
+ expect(response_hash)
382
+ .to eq(JSON.parse(response_body))
383
+ expect(response_hash)
384
+ .to be_a Adyen::HashWithAccessors
385
+ expect(response_hash)
386
+ .to be_a_kind_of Hash
387
+ end
388
+
389
+ it 'makes a cardDetails call' do
390
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/card_details.json'))
391
+
392
+ response_body = json_from_file('mocks/responses/Checkout/card_details.json')
393
+
394
+ url = @shared_values[:client].service_url(@shared_values[:service], 'cardDetails',
395
+ @shared_values[:client].checkout.version)
396
+ WebMock.stub_request(:post, url)
397
+ .with(
398
+ body: request_body,
399
+ headers: {
400
+ 'x-api-key' => @shared_values[:client].api_key
401
+ }
402
+ )
403
+ .to_return(body: response_body)
404
+
405
+ result = @shared_values[:client].checkout.payments_api.card_details(request_body)
406
+ response_hash = result.response
407
+
408
+ expect(result.status)
409
+ .to eq(200)
410
+ expect(response_hash)
411
+ .to eq(JSON.parse(response_body))
412
+ expect(response_hash)
413
+ .to be_a Adyen::HashWithAccessors
414
+ expect(response_hash)
415
+ .to be_a_kind_of Hash
416
+ end
417
+
418
+ it 'makes a donationCampaigns call' do
419
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/donation_campaigns.json'))
420
+
421
+ response_body = json_from_file('mocks/responses/Checkout/donation_campaigns.json')
422
+
423
+ url = @shared_values[:client].service_url(@shared_values[:service], 'donationCampaigns',
424
+ @shared_values[:client].checkout.version)
425
+ WebMock.stub_request(:post, url)
426
+ .with(
427
+ body: request_body,
428
+ headers: {
429
+ 'x-api-key' => @shared_values[:client].api_key
430
+ }
431
+ )
432
+ .to_return(body: response_body)
433
+
434
+ result = @shared_values[:client].checkout.donations_api.donation_campaigns(request_body)
435
+ response_hash = result.response
436
+
437
+ expect(result.status)
438
+ .to eq(200)
439
+ expect(response_hash)
440
+ .to eq(JSON.parse(response_body))
441
+ expect(response_hash)
442
+ .to be_a Adyen::HashWithAccessors
443
+ expect(response_hash)
444
+ .to be_a_kind_of Hash
445
+ end
446
+
447
+ it 'makes a donations call' do
448
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/donations.json'))
449
+
450
+ response_body = json_from_file('mocks/responses/Checkout/donations.json')
451
+
452
+ url = @shared_values[:client].service_url(@shared_values[:service], 'donations',
453
+ @shared_values[:client].checkout.version)
454
+ WebMock.stub_request(:post, url)
455
+ .with(
456
+ body: request_body,
457
+ headers: {
458
+ 'x-api-key' => @shared_values[:client].api_key
459
+ }
460
+ )
461
+ .to_return(body: response_body)
462
+
463
+ result = @shared_values[:client].checkout.donations_api.donations(request_body)
464
+ response_hash = result.response
465
+
466
+ expect(result.status)
467
+ .to eq(200)
468
+ expect(response_hash)
469
+ .to eq(JSON.parse(response_body))
470
+ expect(response_hash)
471
+ .to be_a Adyen::HashWithAccessors
472
+ expect(response_hash)
473
+ .to be_a_kind_of Hash
474
+ end
475
+
476
+ it 'makes a payments call' do
477
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/payments.json'))
478
+
479
+ response_body = json_from_file('mocks/responses/Checkout/payments.json')
480
+
481
+ url = @shared_values[:client].service_url(@shared_values[:service], 'payments',
482
+ @shared_values[:client].checkout.version)
483
+ WebMock.stub_request(:post, url)
484
+ .with(
485
+ body: request_body,
486
+ headers: {
487
+ 'x-api-key' => @shared_values[:client].api_key
488
+ }
489
+ )
490
+ .to_return(body: response_body)
491
+
492
+ result = @shared_values[:client].checkout.payments_api.payments(request_body)
493
+ response_hash = result.response
494
+
495
+ expect(result.status)
496
+ .to eq(200)
497
+ expect(response_hash)
498
+ .to eq(JSON.parse(response_body))
499
+ expect(response_hash)
500
+ .to be_a Adyen::HashWithAccessors
501
+ expect(response_hash)
502
+ .to be_a_kind_of Hash
503
+ end
504
+
505
+ it 'makes a reversals call' do
506
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/reversals.json'))
507
+
508
+ response_body = json_from_file('mocks/responses/Checkout/reversals.json')
509
+
510
+ url = @shared_values[:client].service_url(@shared_values[:service], 'payments/8535678901234567/reversals',
511
+ @shared_values[:client].checkout.version)
512
+ WebMock.stub_request(:post, url)
513
+ .with(
514
+ body: request_body,
515
+ headers: {
516
+ 'x-api-key' => @shared_values[:client].api_key
517
+ }
518
+ )
519
+ .to_return(body: response_body, status: 201)
520
+
521
+ result = @shared_values[:client].checkout.modifications_api.refund_or_cancel_payment(request_body,
522
+ '8535678901234567')
523
+ response_hash = result.response
524
+
525
+ expect(result.status)
526
+ .to eq(201)
527
+ expect(response_hash)
528
+ .to eq(JSON.parse(response_body))
529
+ expect(response_hash)
530
+ .to be_a Adyen::HashWithAccessors
531
+ expect(response_hash)
532
+ .to be_a_kind_of Hash
533
+ end
534
+
535
+ it 'makes a paypal/updateOrder call' do
536
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/paypal_update_order.json'))
537
+
538
+ response_body = json_from_file('mocks/responses/Checkout/paypal_update_order.json')
539
+
540
+ url = @shared_values[:client].service_url(@shared_values[:service], 'paypal/updateOrder',
541
+ @shared_values[:client].checkout.version)
542
+ WebMock.stub_request(:post, url)
543
+ .with(
544
+ body: request_body,
545
+ headers: {
546
+ 'x-api-key' => @shared_values[:client].api_key
547
+ }
548
+ )
549
+ .to_return(body: response_body)
550
+
551
+ result = @shared_values[:client].checkout.utility_api.updates_order_for_paypal_express_checkout(request_body)
552
+ response_hash = result.response
553
+
554
+ expect(result.status)
555
+ .to eq(200)
556
+ expect(response_hash)
557
+ .to eq(JSON.parse(response_body))
558
+ expect(response_hash)
559
+ .to be_a Adyen::HashWithAccessors
560
+ expect(response_hash)
561
+ .to be_a_kind_of Hash
562
+ end
563
+
564
+ it 'makes a storedPaymentMethods POST call' do
565
+ request_body = JSON.parse(json_from_file('mocks/requests/Checkout/create_stored_payment_method.json'))
566
+
567
+ response_body = json_from_file('mocks/responses/Checkout/create_stored_payment_method.json')
568
+
569
+ url = @shared_values[:client].service_url(@shared_values[:service], 'storedPaymentMethods',
570
+ @shared_values[:client].checkout.version)
571
+ WebMock.stub_request(:post, url)
572
+ .with(
573
+ body: request_body,
574
+ headers: {
575
+ 'x-api-key' => @shared_values[:client].api_key
576
+ }
577
+ )
578
+ .to_return(body: response_body, status: 201)
579
+
580
+ result = @shared_values[:client].checkout.recurring_api.stored_payment_methods(request_body)
581
+ response_hash = result.response
582
+
583
+ expect(result.status)
584
+ .to eq(201)
585
+ expect(response_hash)
586
+ .to eq(JSON.parse(response_body))
587
+ expect(response_hash)
588
+ .to be_a Adyen::HashWithAccessors
589
+ expect(response_hash)
590
+ .to be_a_kind_of Hash
591
+ end
592
+
359
593
  it 'makes a capture call' do
360
594
  request_body = JSON.parse(json_from_file('mocks/requests/Checkout/capture.json'))
361
595
 
@@ -607,7 +841,8 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
607
841
  }
608
842
  )
609
843
  .to_return(
610
- body: '{}'
844
+ status: 204,
845
+ body: ''
611
846
  )
612
847
 
613
848
  result = @shared_values[:client].checkout.recurring_api.delete_token_for_stored_payment_details(
@@ -620,7 +855,7 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
620
855
  result.response
621
856
 
622
857
  expect(result.status)
623
- .to eq(200)
858
+ .to eq(204)
624
859
  end
625
860
 
626
861
  it 'tests sending the application headers' do
@@ -647,7 +882,7 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
647
882
  'shopperReference' => 'test-1234'
648
883
  })
649
884
  expect(
650
- a_request(:get, 'http://localhost:3001/v71/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234')
885
+ a_request(:get, 'http://localhost:3001/v72/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234')
651
886
  .with(headers: {
652
887
  'Accept' => '*/*',
653
888
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
@@ -673,7 +908,7 @@ RSpec.describe Adyen::Checkout, service: 'checkout' do
673
908
  url = adyen.service_url('Checkout', 'paymentMethods', @shared_values[:client].checkout.version)
674
909
 
675
910
  expect(url)
676
- .to eq('https://prefix-checkout-live.adyenpayments.com/checkout/v71/paymentMethods')
911
+ .to eq('https://prefix-checkout-live.adyenpayments.com/checkout/v72/paymentMethods')
677
912
  end
678
913
  end
679
914
 
data/spec/client_spec.rb CHANGED
@@ -169,9 +169,7 @@ RSpec.describe Adyen do
169
169
  Adyen::Client.new(env: :test, connection_options: connection_options)
170
170
  end
171
171
 
172
- # test with Ruby 3.2+ only (where Faraday requestOptions timeout is supported)
173
172
  it 'initiates a Faraday connection with the provided options' do
174
- skip 'Only runs on Ruby >= 3.2' unless RUBY_VERSION >= '3.2'
175
173
  connection_options = Faraday::ConnectionOptions.new(
176
174
  request: {
177
175
  open_timeout: 5,
@@ -190,15 +188,13 @@ RSpec.describe Adyen do
190
188
  mock_response = Faraday::Response.new(status: 200)
191
189
 
192
190
  expect(Adyen::AdyenResult).to receive(:new)
193
- expect(Faraday).to receive(:new).with('http://localhost:3001/v71/payments/details',
191
+ expect(Faraday).to receive(:new).with('http://localhost:3001/v72/payments/details',
194
192
  connection_options).and_return(mock_faraday_connection)
195
193
  expect(mock_faraday_connection).to receive(:post).and_return(mock_response)
196
194
  client.checkout.payments_api.payments_details(request_body)
197
195
  end
198
196
 
199
- # test with Ruby 3.2+ only (where Faraday requestOptions timeout is supported)
200
197
  it 'initiates a Faraday connection with the expected default timeouts' do
201
- skip 'Only runs on Ruby >= 3.2' unless RUBY_VERSION >= '3.2'
202
198
  client = Adyen::Client.new(env: :test)
203
199
  expect(client.connection_options[:request][:open_timeout]).to eq(30)
204
200
  expect(client.connection_options[:request][:timeout]).to eq(60)