adyen-ruby-api-library 6.0.0 → 6.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61215b9de7ba034430b475ae7e70caaf9e28403e9932d7dee5c2092cab206843
4
- data.tar.gz: e0363ffc4090d847ecc2e1a7c976a91adf58d3f70d75d88609a51aee5f4dc518
3
+ metadata.gz: 1b091a2aaf201f3a22b41a22c069321d1d181daee6e33da275d94ab970b9b9ab
4
+ data.tar.gz: 1806d42c9f609c9ff3b6e84e31ff1be9f4d4503d15f5a0c300a664a779a5c295
5
5
  SHA512:
6
- metadata.gz: 2dc2019edf4bb02922b573b45e151a472cb3cb178b55677ffbb52d3867fb3514b1aabf76458338a8d832d1116a215fa0286c963a086c8ed2fd156ee94b4e5422
7
- data.tar.gz: 45dee79d7372364092e9b3a9fd789d2b7553ac4052ebf0d6701bed7f2c62ad0772b7eb25702233feffe9ed13d158af7c958fa0a71f07a5740e869dda88402351
6
+ metadata.gz: f9c9221b5d0c164cd4a90c5d7e6531e6361c116e00139662fcff37588309c07c21740d8a3c277ec4b7febbad4d5af752a772eab0df5625430f66b3b47fcbfc92
7
+ data.tar.gz: 4b89bec481b6b2e900325a9f9bc11a69e87b42d61a1358205e53d3a17f90c722377e4fdf7accafc11124ac2e4d70d88b36cdd214cb5f9b7d576e216d9ca6b31b
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @crrood @Aleffio @wboereboom @cyattilakiss
1
+ * @crrood @wboereboom @AlexandrosMor @michaelpaul
@@ -0,0 +1,19 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+
14
+ - name: Release Gem on RubyGems
15
+ if: contains(github.ref, 'refs/tags/v')
16
+ uses: cadwallion/publish-rubygems-action@master
17
+ env:
18
+ GITHUB_TOKEN: ${{secrets.TOKEN_RUBYGEMS_RELEASES_WITH_EXPIRATION}}
19
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
data/README.md CHANGED
@@ -108,7 +108,7 @@ If you have a feature request, or spotted a bug or a technical problem, [create
108
108
  For other questions, [contact our Support Team](https://www.adyen.help/hc/en-us/requests/new?ticket_form_id=360000705420).
109
109
 
110
110
  ## Licence
111
- This repository is available under the [MIT license](https://github.com/Adyen/adyen-ruby-api-library/blob/master/LICENSE).
111
+ This repository is available under the [MIT license](https://github.com/Adyen/adyen-ruby-api-library/blob/main/LICENSE).
112
112
 
113
113
  ## See also
114
114
  * [Example integration](https://github.com/adyen-examples/adyen-rails-online-payments)
data/docs/checkout.html CHANGED
@@ -23,8 +23,8 @@
23
23
 
24
24
  <p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
25
25
  <ul>
26
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
27
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
26
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
27
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
28
28
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
29
29
  </ul>
30
30
  </header>
data/docs/index.html CHANGED
@@ -21,8 +21,8 @@
21
21
  <p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
22
22
 
23
23
  <ul>
24
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
25
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
24
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
25
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
26
26
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
27
27
  </ul>
28
28
  </header>
@@ -25,8 +25,8 @@
25
25
 
26
26
 
27
27
  <ul>
28
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
29
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
28
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
29
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
30
30
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
31
31
  </ul>
32
32
  </header>
data/docs/marketpay.html CHANGED
@@ -23,8 +23,8 @@
23
23
 
24
24
  <p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
25
25
  <ul>
26
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
27
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
26
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
27
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
28
28
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
29
29
  </ul>
30
30
  </header>
data/docs/payment.html CHANGED
@@ -24,8 +24,8 @@
24
24
 
25
25
  <p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
26
26
  <ul>
27
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
28
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
27
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
28
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
29
29
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
30
30
  </ul>
31
31
  </header>
data/docs/payout.html CHANGED
@@ -23,8 +23,8 @@
23
23
 
24
24
  <p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
25
25
  <ul>
26
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
27
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
26
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
27
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
28
28
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
29
29
  </ul>
30
30
  </header>
data/docs/recurring.html CHANGED
@@ -23,8 +23,8 @@
23
23
 
24
24
  <p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
25
25
  <ul>
26
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
27
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
26
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
27
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
28
28
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
29
29
  </ul>
30
30
  </header>
@@ -25,8 +25,8 @@
25
25
 
26
26
 
27
27
  <ul>
28
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
29
- <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
28
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
29
+ <li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
30
30
  <li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
31
31
  </ul>
32
32
  </header>
data/lib/adyen/client.rb CHANGED
@@ -6,9 +6,9 @@ require_relative "./result"
6
6
  module Adyen
7
7
  class Client
8
8
  attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter, :live_url_prefix
9
- attr_reader :env
9
+ attr_reader :env, :connection_options
10
10
 
11
- def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001, live_url_prefix: nil, mock_service_url_base: nil)
11
+ def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001, live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil)
12
12
  @ws_user = ws_user
13
13
  @ws_password = ws_password
14
14
  @api_key = api_key
@@ -16,6 +16,7 @@ module Adyen
16
16
  @adapter = adapter || Faraday.default_adapter
17
17
  @mock_service_url_base = mock_service_url_base || "http://localhost:#{mock_port}"
18
18
  @live_url_prefix = live_url_prefix
19
+ @connection_options = connection_options || Faraday::ConnectionOptions.new
19
20
  end
20
21
 
21
22
  # make sure that env can only be :live, :test, or :mock
@@ -96,7 +97,7 @@ module Adyen
96
97
  end
97
98
 
98
99
  # initialize Faraday connection object
99
- conn = Faraday.new(url: url) do |faraday|
100
+ conn = Faraday.new(url, @connection_options) do |faraday|
100
101
  faraday.adapter @adapter
101
102
  faraday.headers["Content-Type"] = "application/json"
102
103
  faraday.headers["User-Agent"] = Adyen::NAME + "/" + Adyen::VERSION
@@ -104,7 +105,13 @@ module Adyen
104
105
  # set auth type based on service
105
106
  case auth_type
106
107
  when "basic"
107
- faraday.basic_auth(@ws_user, @ws_password)
108
+ if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
109
+ # for faraday 2.0 and higher
110
+ faraday.request :authorization, :basic, @ws_user, @ws_password
111
+ else
112
+ # for faraday 1.x
113
+ faraday.basic_auth(@ws_user, @ws_password)
114
+ end
108
115
  when "api-key"
109
116
  faraday.headers["x-api-key"] = @api_key
110
117
  end
@@ -132,7 +139,7 @@ module Adyen
132
139
  if action.is_a?(::Hash)
133
140
  if action.fetch(:method) == "get"
134
141
  begin
135
- response = conn.get
142
+ response = conn.get
136
143
  rescue Faraday::ConnectionFailed => connection_error
137
144
  raise connection_error, "Connection to #{url} failed"
138
145
  end
data/lib/adyen/errors.rb CHANGED
@@ -3,7 +3,10 @@ module Adyen
3
3
  attr_reader :code, :response, :request, :msg
4
4
 
5
5
  def initialize(request = nil, response = nil, msg = nil, code = nil)
6
- mask_fields(request)
6
+ unless request.nil?
7
+ request = request.is_a?(Hash) ? request : JSON.parse(request, symbolize_names: true)
8
+ mask_fields(request)
9
+ end
7
10
 
8
11
  # components of formatted error message
9
12
  attributes = {
@@ -37,7 +40,7 @@ module Adyen
37
40
  ]
38
41
 
39
42
  # convert to hash if necessary
40
- request = request.is_a?(Hash) ? request : JSON.parse(request)
43
+ request = request.is_a?(Hash) ? request : JSON.parse(request, symbolize_names: true)
41
44
 
42
45
  # iterate through request to find fields to mask
43
46
  request.each do |k, v|
@@ -67,6 +67,14 @@ module Adyen
67
67
  @client.call_adyen_api(@service, action, args[0], args[1], @version)
68
68
  end
69
69
  end
70
+
71
+ def apple_pay
72
+ @apple_pay ||= Adyen::CheckoutApplePay.new(@client, @version)
73
+ end
74
+
75
+ def modifications
76
+ @modifications ||= Adyen::Modifications.new(@client, @version)
77
+ end
70
78
  end
71
79
 
72
80
  class CheckoutDetail < Service
@@ -130,4 +138,55 @@ module Adyen
130
138
  @client.call_adyen_api(@service, action, request, headers, @version)
131
139
  end
132
140
  end
141
+
142
+ class CheckoutApplePay < Service
143
+ def initialize(client, version = DEFAULT_VERSION)
144
+ @service = "Checkout"
145
+ @client = client
146
+ @version = version
147
+ end
148
+
149
+ def sessions(request, headers = {})
150
+ action = "applePay/sessions"
151
+ @client.call_adyen_api(@service, action, request, headers, @version)
152
+ end
153
+ end
154
+
155
+ class Modifications < Service
156
+ def initialize(client, version = DEFAULT_VERSION)
157
+ @service = "Checkout"
158
+ @client = client
159
+ @version = version
160
+ end
161
+
162
+ def capture(linkId, request, headers = {})
163
+ action = "payments/" + linkId + "/captures"
164
+ @client.call_adyen_api(@service, action, request, headers, @version, false)
165
+ end
166
+
167
+ def cancel(linkId, request, headers = {})
168
+ action = "payments/" + linkId + "/cancels"
169
+ @client.call_adyen_api(@service, action, request, headers, @version, false)
170
+ end
171
+
172
+ def genericCancel(request, headers = {})
173
+ action = "cancels"
174
+ @client.call_adyen_api(@service, action, request, headers, @version)
175
+ end
176
+
177
+ def refund(linkId, request, headers = {})
178
+ action = "payments/" + linkId + "/refunds"
179
+ @client.call_adyen_api(@service, action, request, headers, @version, false)
180
+ end
181
+
182
+ def reversal(linkId, request, headers = {})
183
+ action = "payments/" + linkId + "/reversals"
184
+ @client.call_adyen_api(@service, action, request, headers, @version, false)
185
+ end
186
+
187
+ def amountUpdate(linkId, request, headers = {})
188
+ action = "payments/" + linkId + "/amountUpdates"
189
+ @client.call_adyen_api(@service, action, request, headers, @version, false)
190
+ end
191
+ end
133
192
  end
data/lib/adyen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Adyen
2
2
  NAME = "adyen-ruby-api-library"
3
- VERSION = "6.0.0".freeze
3
+ VERSION = "6.2.0".freeze
4
4
  end
@@ -345,6 +345,38 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
345
345
  to eq("cancelled")
346
346
  end
347
347
 
348
+ it "makes an applePay/sessions call" do
349
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/apple_pay_sessions.json"))
350
+
351
+ response_body = json_from_file("mocks/responses/Checkout/apple_pay_sessions.json")
352
+
353
+ url = @shared_values[:client].service_url(@shared_values[:service], "applePay/sessions", @shared_values[:client].checkout.version)
354
+ WebMock.stub_request(:post, url).
355
+ with(
356
+ body: request_body,
357
+ headers: {
358
+ "x-api-key" => @shared_values[:client].api_key
359
+ }
360
+ ).
361
+ to_return(
362
+ body: response_body
363
+ )
364
+
365
+ result = @shared_values[:client].checkout.apple_pay.sessions(request_body)
366
+ response_hash = result.response
367
+
368
+ expect(result.status).
369
+ to eq(200)
370
+ expect(response_hash).
371
+ to eq(JSON.parse(response_body))
372
+ expect(response_hash).
373
+ to be_a Adyen::HashWithAccessors
374
+ expect(response_hash).
375
+ to be_a_kind_of Hash
376
+ expect(response_hash["data"]).
377
+ to eq("LARGE_BLOB_HERE")
378
+ end
379
+
348
380
  it "makes a sessions call" do
349
381
  request_body = JSON.parse(json_from_file("mocks/requests/Checkout/sessions.json"))
350
382
 
@@ -373,6 +405,198 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
373
405
  to be_a_kind_of Hash
374
406
  end
375
407
 
408
+ it "makes a capture call" do
409
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/capture.json"))
410
+
411
+ response_body = json_from_file("mocks/responses/Checkout/capture.json")
412
+
413
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/captures", @shared_values[:client].checkout.version)
414
+ WebMock.stub_request(:post, url).
415
+ with(
416
+ body: request_body,
417
+ headers: {
418
+ "x-api-key" => @shared_values[:client].api_key
419
+ }
420
+ )
421
+ .to_return(body: response_body, status: 201)
422
+
423
+ result = @shared_values[:client].checkout.modifications.capture("12345", request_body)
424
+ response_hash = result.response
425
+
426
+ expect(result.status).
427
+ to eq(201)
428
+ expect(response_hash).
429
+ to eq(JSON.parse(response_body))
430
+ expect(response_hash).
431
+ to be_a Adyen::HashWithAccessors
432
+ expect(response_hash).
433
+ to be_a_kind_of Hash
434
+ expect(response_hash.reference).
435
+ to eq("123456789")
436
+ expect(response_hash.pspReference).
437
+ to eq("12345")
438
+ end
439
+
440
+ it "makes a psp specific cancel call" do
441
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json"))
442
+
443
+ response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json")
444
+
445
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/cancels", @shared_values[:client].checkout.version)
446
+ WebMock.stub_request(:post, url).
447
+ with(
448
+ body: request_body,
449
+ headers: {
450
+ "x-api-key" => @shared_values[:client].api_key
451
+ }
452
+ )
453
+ .to_return(body: response_body, status: 201)
454
+
455
+ result = @shared_values[:client].checkout.modifications.cancel("12345", request_body)
456
+ response_hash = result.response
457
+
458
+ expect(result.status).
459
+ to eq(201)
460
+ expect(response_hash).
461
+ to eq(JSON.parse(response_body))
462
+ expect(response_hash).
463
+ to be_a Adyen::HashWithAccessors
464
+ expect(response_hash).
465
+ to be_a_kind_of Hash
466
+ expect(response_hash.reference).
467
+ to eq("123456789")
468
+ expect(response_hash.pspReference).
469
+ to eq("12345")
470
+ end
471
+
472
+ it "makes a psp specific refunds call" do
473
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/refund.json"))
474
+
475
+ response_body = json_from_file("mocks/responses/Checkout/refund.json")
476
+
477
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/refunds", @shared_values[:client].checkout.version)
478
+ WebMock.stub_request(:post, url).
479
+ with(
480
+ body: request_body,
481
+ headers: {
482
+ "x-api-key" => @shared_values[:client].api_key
483
+ }
484
+ )
485
+ .to_return(body: response_body, status: 201)
486
+
487
+ result = @shared_values[:client].checkout.modifications.refund("12345", request_body)
488
+ response_hash = result.response
489
+
490
+ expect(result.status).
491
+ to eq(201)
492
+ expect(response_hash).
493
+ to eq(JSON.parse(response_body))
494
+ expect(response_hash).
495
+ to be_a Adyen::HashWithAccessors
496
+ expect(response_hash).
497
+ to be_a_kind_of Hash
498
+ expect(response_hash.reference).
499
+ to eq("123456789")
500
+ expect(response_hash.pspReference).
501
+ to eq("12345")
502
+ end
503
+
504
+ it "makes a psp specific reversals call" do
505
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json"))
506
+
507
+ response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json")
508
+
509
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/reversals", @shared_values[:client].checkout.version)
510
+ WebMock.stub_request(:post, url).
511
+ with(
512
+ body: request_body,
513
+ headers: {
514
+ "x-api-key" => @shared_values[:client].api_key
515
+ }
516
+ )
517
+ .to_return(body: response_body, status: 201)
518
+
519
+ result = @shared_values[:client].checkout.modifications.reversal("12345", request_body)
520
+ response_hash = result.response
521
+
522
+ expect(result.status).
523
+ to eq(201)
524
+ expect(response_hash).
525
+ to eq(JSON.parse(response_body))
526
+ expect(response_hash).
527
+ to be_a Adyen::HashWithAccessors
528
+ expect(response_hash).
529
+ to be_a_kind_of Hash
530
+ expect(response_hash.reference).
531
+ to eq("123456789")
532
+ expect(response_hash.pspReference).
533
+ to eq("12345")
534
+ end
535
+
536
+ it "makes a psp specific amountUpdates call" do
537
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/amount_updates.json"))
538
+
539
+ response_body = json_from_file("mocks/responses/Checkout/amount_updates.json")
540
+
541
+ url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/amountUpdates", @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, status: 201)
550
+
551
+ result = @shared_values[:client].checkout.modifications.amountUpdate("12345", request_body)
552
+ response_hash = result.response
553
+
554
+ expect(result.status).
555
+ to eq(201)
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
+ expect(response_hash.reference).
563
+ to eq("123456789")
564
+ expect(response_hash.pspReference).
565
+ to eq("12345")
566
+ end
567
+
568
+ it "makes a generic cancel call" do
569
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/generic_cancel.json"))
570
+
571
+ response_body = json_from_file("mocks/responses/Checkout/generic_cancel.json")
572
+
573
+ url = @shared_values[:client].service_url(@shared_values[:service], "cancels", @shared_values[:client].checkout.version)
574
+ WebMock.stub_request(:post, url).
575
+ with(
576
+ body: request_body,
577
+ headers: {
578
+ "x-api-key" => @shared_values[:client].api_key
579
+ }
580
+ )
581
+ .to_return(body: response_body, status: 201)
582
+
583
+ result = @shared_values[:client].checkout.modifications.genericCancel(request_body)
584
+ response_hash = result.response
585
+
586
+ expect(result.status).
587
+ to eq(201)
588
+ expect(response_hash).
589
+ to eq(JSON.parse(response_body))
590
+ expect(response_hash).
591
+ to be_a Adyen::HashWithAccessors
592
+ expect(response_hash).
593
+ to be_a_kind_of Hash
594
+ expect(response_hash.reference).
595
+ to eq("123456789")
596
+ expect(response_hash.pspReference).
597
+ to eq("12345")
598
+ end
599
+
376
600
  # create client for automated tests
377
601
  client = create_client(:api_key)
378
602
 
data/spec/client_spec.rb CHANGED
@@ -83,4 +83,31 @@ RSpec.describe Adyen do
83
83
  expect(client.service_url_base("Payment")).
84
84
  to eq("https://abcdef1234567890-TestCompany-pal-live.adyenpayments.com/pal/servlet")
85
85
  end
86
+
87
+ it "generates a new set of ConnectionOptions when none are provided" do
88
+ expect(Faraday::ConnectionOptions).to receive(:new).and_call_original
89
+ client = Adyen::Client.new(env: :test)
90
+ end
91
+
92
+ it "uses the ConnectionOptions provided" do
93
+ connection_options = Faraday::ConnectionOptions.new
94
+ expect(Faraday::ConnectionOptions).not_to receive(:new)
95
+ client = Adyen::Client.new(env: :test, connection_options: connection_options)
96
+ end
97
+
98
+ it "initiates a Faraday connection with the provided options" do
99
+ connection_options = Faraday::ConnectionOptions.new
100
+ expect(Faraday::ConnectionOptions).not_to receive(:new)
101
+ client = Adyen::Client.new(api_key: "api_key", env: :mock, connection_options: connection_options)
102
+
103
+ mock_faraday_connection = double(Faraday::Connection)
104
+ url = client.service_url(@shared_values[:service], "payments/details", client.checkout.version)
105
+ request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment-details.json"))
106
+ mock_response = Faraday::Response.new(status: 200)
107
+
108
+ expect(Adyen::AdyenResult).to receive(:new)
109
+ expect(Faraday).to receive(:new).with("http://localhost:3001/v68/payments/details", connection_options).and_return(mock_faraday_connection)
110
+ expect(mock_faraday_connection).to receive(:post).and_return(mock_response)
111
+ client.checkout.payments.details(request_body)
112
+ end
86
113
  end
data/spec/errors_spec.rb CHANGED
@@ -43,5 +43,14 @@ RSpec.describe Adyen::AdyenError do
43
43
  it 'masks CVC when logging request in errors' do
44
44
  expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
45
45
  end
46
+
47
+ context 'when request is string' do
48
+ it 'masks card number when logging request in errors' do
49
+ expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message', 'code').request[:paymentMethod][:number]).to eq('411111******1111')
50
+ end
51
+ it 'masks CVC when logging request in errors' do
52
+ expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
53
+ end
54
+ end
46
55
  end
47
56
  end
@@ -0,0 +1,22 @@
1
+ {
2
+ "amount": {
3
+ "currency": "str",
4
+ "value": 0
5
+ },
6
+ "merchantAccount": "TestMerchant",
7
+ "reason": "delayedCharge",
8
+ "reference": "123456789",
9
+ "splits": [
10
+ {
11
+ "account": "string",
12
+ "amount": {
13
+ "currency": "str",
14
+ "value": 0
15
+ },
16
+ "description": "string",
17
+ "reference": "string",
18
+ "type": "BalanceAccount"
19
+ }
20
+ ]
21
+ }
22
+
@@ -0,0 +1,5 @@
1
+ {
2
+ "displayName": "YOUR_MERCHANT_NAME",
3
+ "domainName": "window.location.hostname",
4
+ "merchantIdentifier": "YOUR_MERCHANT_ID"
5
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "amount": {
3
+ "currency": "str",
4
+ "value": 0
5
+ },
6
+ "lineItems": [
7
+ {
8
+ "amountExcludingTax": 0,
9
+ "amountIncludingTax": 0,
10
+ "description": "string",
11
+ "id": "string",
12
+ "imageUrl": "string",
13
+ "itemCategory": "string",
14
+ "productUrl": "string",
15
+ "quantity": 0,
16
+ "taxAmount": 0,
17
+ "taxPercentage": 0
18
+ }
19
+ ],
20
+ "merchantAccount": "string",
21
+ "reference": "string",
22
+ "splits": [
23
+ {
24
+ "account": "string",
25
+ "amount": {
26
+ "currency": "str",
27
+ "value": 0
28
+ },
29
+ "description": "string",
30
+ "reference": "string",
31
+ "type": "BalanceAccount"
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "merchantAccount": "TestMerchant",
3
+ "paymentReference": "12345",
4
+ "reference": "123456789"
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "merchantAccount": "TestMerchant",
3
+ "reference": "123456789"
4
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "amount": {
3
+ "currency": "str",
4
+ "value": 0
5
+ },
6
+ "lineItems": [
7
+ {
8
+ "amountExcludingTax": 0,
9
+ "amountIncludingTax": 0,
10
+ "description": "string",
11
+ "id": "string",
12
+ "imageUrl": "string",
13
+ "itemCategory": "string",
14
+ "productUrl": "string",
15
+ "quantity": 0,
16
+ "taxAmount": 0,
17
+ "taxPercentage": 0
18
+ }
19
+ ],
20
+ "merchantAccount": "TestMerchant",
21
+ "reference": "123456789",
22
+ "splits": [
23
+ {
24
+ "account": "string",
25
+ "amount": {
26
+ "currency": "str",
27
+ "value": 0
28
+ },
29
+ "description": "string",
30
+ "reference": "string",
31
+ "type": "BalanceAccount"
32
+ }
33
+ ]
34
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "amount": {
3
+ "currency": "str",
4
+ "value": 0
5
+ },
6
+ "merchantAccount": "TestMerchant",
7
+ "paymentPspReference": "123456789",
8
+ "pspReference": "12345",
9
+ "reason": "delayedCharge",
10
+ "reference": "123456789",
11
+ "splits": [
12
+ {
13
+ "account": "string",
14
+ "amount": {
15
+ "currency": "str",
16
+ "value": 0
17
+ },
18
+ "description": "string",
19
+ "reference": "string",
20
+ "type": "BalanceAccount"
21
+ }
22
+ ],
23
+ "status": "received"
24
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "data" : "LARGE_BLOB_HERE"
3
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "amount": {
3
+ "currency": "str",
4
+ "value": 0
5
+ },
6
+ "lineItems": [
7
+ {
8
+ "amountExcludingTax": 0,
9
+ "amountIncludingTax": 0,
10
+ "description": "string",
11
+ "id": "string",
12
+ "imageUrl": "string",
13
+ "itemCategory": "string",
14
+ "productUrl": "string",
15
+ "quantity": 0,
16
+ "taxAmount": 0,
17
+ "taxPercentage": 0
18
+ }
19
+ ],
20
+ "merchantAccount": "string",
21
+ "paymentPspReference": "string",
22
+ "pspReference": "12345",
23
+ "reference": "123456789",
24
+ "splits": [
25
+ {
26
+ "account": "string",
27
+ "amount": {
28
+ "currency": "str",
29
+ "value": 0
30
+ },
31
+ "description": "string",
32
+ "reference": "string",
33
+ "type": "BalanceAccount"
34
+ }
35
+ ],
36
+ "status": "received"
37
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "merchantAccount": "string",
3
+ "paymentReference": "123456789",
4
+ "pspReference": "12345",
5
+ "reference": "123456789",
6
+ "status": "received"
7
+ }
File without changes
@@ -0,0 +1,7 @@
1
+ {
2
+ "merchantAccount": "TestMerchant",
3
+ "paymentPspReference": "string",
4
+ "pspReference": "12345",
5
+ "reference": "123456789",
6
+ "status": "received"
7
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "amount": {
3
+ "currency": "str",
4
+ "value": 0
5
+ },
6
+ "lineItems": [
7
+ {
8
+ "amountExcludingTax": 0,
9
+ "amountIncludingTax": 0,
10
+ "description": "string",
11
+ "id": "string",
12
+ "imageUrl": "string",
13
+ "itemCategory": "string",
14
+ "productUrl": "string",
15
+ "quantity": 0,
16
+ "taxAmount": 0,
17
+ "taxPercentage": 0
18
+ }
19
+ ],
20
+ "merchantAccount": "TestMerchant",
21
+ "paymentPspReference": "123456789",
22
+ "pspReference": "12345",
23
+ "reference": "123456789",
24
+ "splits": [
25
+ {
26
+ "account": "string",
27
+ "amount": {
28
+ "currency": "str",
29
+ "value": 0
30
+ },
31
+ "description": "string",
32
+ "reference": "string",
33
+ "type": "BalanceAccount"
34
+ }
35
+ ],
36
+ "status": "received"
37
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen-ruby-api-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-21 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -82,6 +82,7 @@ files:
82
82
  - ".github/PULL_REQUEST_TEMPLATE.md"
83
83
  - ".github/dependabot.yml"
84
84
  - ".github/workflows/ruby.yml"
85
+ - ".github/workflows/rubygems_release.yml"
85
86
  - ".gitignore"
86
87
  - CODE_OF_CONDUCT.md
87
88
  - CONTRIBUTING.md
@@ -153,6 +154,11 @@ files:
153
154
  - spec/mocks/requests/Account/upload_document.json
154
155
  - spec/mocks/requests/BinLookup/get_3ds_availability.json
155
156
  - spec/mocks/requests/BinLookup/get_cost_estimate.json
157
+ - spec/mocks/requests/Checkout/amount_updates.json
158
+ - spec/mocks/requests/Checkout/apple_pay_sessions.json
159
+ - spec/mocks/requests/Checkout/capture.json
160
+ - spec/mocks/requests/Checkout/generic_cancel.json
161
+ - spec/mocks/requests/Checkout/modifications_request.json
156
162
  - spec/mocks/requests/Checkout/orders.json
157
163
  - spec/mocks/requests/Checkout/orders_cancel.json
158
164
  - spec/mocks/requests/Checkout/origin_keys.json
@@ -163,6 +169,8 @@ files:
163
169
  - spec/mocks/requests/Checkout/payment_methods_balance.json
164
170
  - spec/mocks/requests/Checkout/payment_session.json
165
171
  - spec/mocks/requests/Checkout/payments.json
172
+ - spec/mocks/requests/Checkout/psp_cancel.json
173
+ - spec/mocks/requests/Checkout/refund.json
166
174
  - spec/mocks/requests/Checkout/sessions.json
167
175
  - spec/mocks/requests/Checkout/verify.json
168
176
  - spec/mocks/requests/DataProtectionService/request_subject_erasure.json
@@ -229,7 +237,12 @@ files:
229
237
  - spec/mocks/responses/Account/upload_document.json
230
238
  - spec/mocks/responses/BinLookup/get_3ds_availability.json
231
239
  - spec/mocks/responses/BinLookup/get_cost_estimate.json
240
+ - spec/mocks/responses/Checkout/amount_updates.json
241
+ - spec/mocks/responses/Checkout/apple_pay_sessions.json
242
+ - spec/mocks/responses/Checkout/capture.json
243
+ - spec/mocks/responses/Checkout/generic_cancel.json
232
244
  - spec/mocks/responses/Checkout/get-payment-link.json
245
+ - spec/mocks/responses/Checkout/modifications.json
233
246
  - spec/mocks/responses/Checkout/orders.json
234
247
  - spec/mocks/responses/Checkout/orders_cancel.json
235
248
  - spec/mocks/responses/Checkout/origin_keys.json
@@ -240,6 +253,8 @@ files:
240
253
  - spec/mocks/responses/Checkout/payment_methods_balance.json
241
254
  - spec/mocks/responses/Checkout/payment_session.json
242
255
  - spec/mocks/responses/Checkout/payments.json
256
+ - spec/mocks/responses/Checkout/psp_cancel.json
257
+ - spec/mocks/responses/Checkout/refund.json
243
258
  - spec/mocks/responses/Checkout/sessions-success.json
244
259
  - spec/mocks/responses/Checkout/update-payment-link.json
245
260
  - spec/mocks/responses/Checkout/verify.json
@@ -318,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
333
  - !ruby/object:Gem::Version
319
334
  version: '0'
320
335
  requirements: []
321
- rubygems_version: 3.2.3
336
+ rubygems_version: 3.3.7
322
337
  signing_key:
323
338
  specification_version: 4
324
339
  summary: Official Adyen Ruby API Library