adyen-ruby-api-library 8.0.1 → 9.1.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: 270b6ef403bd4388caeb109a653a812cb08a5ebca358f2524ddec2fb66f78133
4
- data.tar.gz: e6c6eaf7eb56b10d02ba59955b504205f23c6c1793955aae2cb500e715a52aab
3
+ metadata.gz: 5a19405ed4decf65ccbb07223e8b69e56bd0bc5c0b03673159334d7bd7a47cb2
4
+ data.tar.gz: 51db3e77404a7ce0b91dd9c78aa00472e839d378cc2e3bbdcff0325443327c4c
5
5
  SHA512:
6
- metadata.gz: 18302f40daecf83d3fd54a9c56df1906f5682a50b48d75fec756f0fb17a7c79697b9cb4a209d724d4d0a176d2c909b079e8c10f983ac7e2a473bfcbf157a9189
7
- data.tar.gz: 70edb1785ca54271a9a32c1c1fa35bcee5d3e9cef6b36da96a3f611b9411d12422568ea80f2079ea9826f7666e77036a6ebfceeaa43216a8da492d6062b000c9
6
+ metadata.gz: a7b3119d610f63ab83ae68994e6cdcf1c6411f4a511d4f0ed7361a8542bc55b0a29d127d05d8f160eab148e7eaafb556dc5f08a63be235c39bc3bc95944b0f92
7
+ data.tar.gz: 73becdd9922b5a91bd995cdbb3231566a0deb1e0c0aaa15940eee19f9c043a9004900dac865fda4ff2f9da6079e2fc3d557ddd976cfed6c3e5a8142da6c4edb4
@@ -27,15 +27,15 @@ jobs:
27
27
  uses: actions/checkout@v4
28
28
 
29
29
  - name: Initialize CodeQL
30
- uses: github/codeql-action/init@v2
30
+ uses: github/codeql-action/init@v3
31
31
  with:
32
32
  languages: ${{ matrix.language }}
33
33
  queries: +security-and-quality
34
34
 
35
35
  - name: Autobuild
36
- uses: github/codeql-action/autobuild@v2
36
+ uses: github/codeql-action/autobuild@v3
37
37
 
38
38
  - name: Perform CodeQL Analysis
39
- uses: github/codeql-action/analyze@v2
39
+ uses: github/codeql-action/analyze@v3
40
40
  with:
41
41
  category: "/language:${{ matrix.language }}"
@@ -12,7 +12,7 @@ jobs:
12
12
  github:
13
13
  permissions:
14
14
  contents: write
15
- uses: Adyen/release-automation-action/.github/workflows/reusable-github-release.yml@v1.1.1
15
+ uses: Adyen/release-automation-action/.github/workflows/reusable-github-release.yml@v2.0.0
16
16
  with:
17
17
  release-title: Adyen Ruby API Library
18
18
  develop-branch: main
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 8.0.1
1
+ 9.1.0
2
2
 
@@ -34,15 +34,6 @@ module Adyen
34
34
  @client.call_adyen_api(@service, action, {}, headers, @version)
35
35
  end
36
36
 
37
- def get_all_payment_instruments_for_balance_account(id, headers: {}, query_params: {})
38
- endpoint = '/balanceAccounts/{id}/paymentInstruments'.gsub(/{.+?}/, '%s')
39
- endpoint = endpoint.gsub(%r{^/}, '')
40
- endpoint = format(endpoint, id)
41
- endpoint += create_query_string(query_params)
42
- action = { method: 'get', url: endpoint }
43
- @client.call_adyen_api(@service, action, {}, headers, @version)
44
- end
45
-
46
37
  def get_all_sweeps_for_balance_account(balance_account_id, headers: {}, query_params: {})
47
38
  endpoint = '/balanceAccounts/{balanceAccountId}/sweeps'.gsub(/{.+?}/, '%s')
48
39
  endpoint = endpoint.gsub(%r{^/}, '')
@@ -61,6 +52,15 @@ module Adyen
61
52
  @client.call_adyen_api(@service, action, {}, headers, @version)
62
53
  end
63
54
 
55
+ def get_payment_instruments_linked_to_balance_account(id, headers: {}, query_params: {})
56
+ endpoint = '/balanceAccounts/{id}/paymentInstruments'.gsub(/{.+?}/, '%s')
57
+ endpoint = endpoint.gsub(%r{^/}, '')
58
+ endpoint = format(endpoint, id)
59
+ endpoint += create_query_string(query_params)
60
+ action = { method: 'get', url: endpoint }
61
+ @client.call_adyen_api(@service, action, {}, headers, @version)
62
+ end
63
+
64
64
  def get_sweep(balance_account_id, sweep_id, headers: {})
65
65
  endpoint = '/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}'.gsub(/{.+?}/, '%s')
66
66
  endpoint = endpoint.gsub(%r{^/}, '')
@@ -0,0 +1,29 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+ class CardOrdersApi < Service
4
+ attr_accessor :service, :version
5
+
6
+ def initialize(client, version = DEFAULT_VERSION)
7
+ super(client, version, 'BalancePlatform')
8
+ end
9
+
10
+ def get_card_order_items(id, headers: {}, query_params: {})
11
+ endpoint = '/cardorders/{id}/items'.gsub(/{.+?}/, '%s')
12
+ endpoint = endpoint.gsub(%r{^/}, '')
13
+ endpoint = format(endpoint, id)
14
+ endpoint += create_query_string(query_params)
15
+ action = { method: 'get', url: endpoint }
16
+ @client.call_adyen_api(@service, action, {}, headers, @version)
17
+ end
18
+
19
+ def list_card_orders(headers: {}, query_params: {})
20
+ endpoint = '/cardorders'.gsub(/{.+?}/, '%s')
21
+ endpoint = endpoint.gsub(%r{^/}, '')
22
+ endpoint = format(endpoint)
23
+ endpoint += create_query_string(query_params)
24
+ action = { method: 'get', url: endpoint }
25
+ @client.call_adyen_api(@service, action, {}, headers, @version)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,38 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+ class ManageCardPINApi < Service
4
+ attr_accessor :service, :version
5
+
6
+ def initialize(client, version = DEFAULT_VERSION)
7
+ super(client, version, 'BalancePlatform')
8
+ end
9
+
10
+ def change_card_pin(request, headers: {})
11
+ endpoint = '/pins/change'.gsub(/{.+?}/, '%s')
12
+ endpoint = endpoint.gsub(%r{^/}, '')
13
+ endpoint = format(endpoint)
14
+
15
+ action = { method: 'post', url: endpoint }
16
+ @client.call_adyen_api(@service, action, request, headers, @version)
17
+ end
18
+
19
+ def public_key(headers: {}, query_params: {})
20
+ endpoint = '/publicKey'.gsub(/{.+?}/, '%s')
21
+ endpoint = endpoint.gsub(%r{^/}, '')
22
+ endpoint = format(endpoint)
23
+ endpoint += create_query_string(query_params)
24
+ action = { method: 'get', url: endpoint }
25
+ @client.call_adyen_api(@service, action, {}, headers, @version)
26
+ end
27
+
28
+ def reveal_card_pin(request, headers: {})
29
+ endpoint = '/pins/reveal'.gsub(/{.+?}/, '%s')
30
+ endpoint = endpoint.gsub(%r{^/}, '')
31
+ endpoint = format(endpoint)
32
+
33
+ action = { method: 'post', url: endpoint }
34
+ @client.call_adyen_api(@service, action, request, headers, @version)
35
+ end
36
+
37
+ end
38
+ end
@@ -52,6 +52,15 @@ module Adyen
52
52
  @client.call_adyen_api(@service, action, {}, headers, @version)
53
53
  end
54
54
 
55
+ def reveal_data_of_payment_instrument(request, headers: {})
56
+ endpoint = '/paymentInstruments/reveal'.gsub(/{.+?}/, '%s')
57
+ endpoint = endpoint.gsub(%r{^/}, '')
58
+ endpoint = format(endpoint)
59
+
60
+ action = { method: 'post', url: endpoint }
61
+ @client.call_adyen_api(@service, action, request, headers, @version)
62
+ end
63
+
55
64
  def update_payment_instrument(request, id, headers: {})
56
65
  endpoint = '/paymentInstruments/{id}'.gsub(/{.+?}/, '%s')
57
66
  endpoint = endpoint.gsub(%r{^/}, '')
@@ -1,8 +1,10 @@
1
1
  require_relative 'balancePlatform/account_holders_api'
2
2
  require_relative 'balancePlatform/balance_accounts_api'
3
3
  require_relative 'balancePlatform/bank_account_validation_api'
4
+ require_relative 'balancePlatform/card_orders_api'
4
5
  require_relative 'balancePlatform/grant_accounts_api'
5
6
  require_relative 'balancePlatform/grant_offers_api'
7
+ require_relative 'balancePlatform/manage_card_pin_api'
6
8
  require_relative 'balancePlatform/network_tokens_api'
7
9
  require_relative 'balancePlatform/payment_instrument_groups_api'
8
10
  require_relative 'balancePlatform/payment_instruments_api'
@@ -33,6 +35,10 @@ module Adyen
33
35
  @bank_account_validation_api ||= Adyen::BankAccountValidationApi.new(@client, @version)
34
36
  end
35
37
 
38
+ def card_orders_api
39
+ @card_orders_api ||= Adyen::CardOrdersApi.new(@client, @version)
40
+ end
41
+
36
42
  def grant_accounts_api
37
43
  @grant_accounts_api ||= Adyen::GrantAccountsApi.new(@client, @version)
38
44
  end
@@ -41,6 +47,10 @@ module Adyen
41
47
  @grant_offers_api ||= Adyen::GrantOffersApi.new(@client, @version)
42
48
  end
43
49
 
50
+ def manage_card_pin_api
51
+ @manage_card_pin_api ||= Adyen::ManageCardPINApi.new(@client, @version)
52
+ end
53
+
44
54
  def network_tokens_api
45
55
  @network_tokens_api ||= Adyen::NetworkTokensApi.new(@client, @version)
46
56
  end
@@ -0,0 +1,20 @@
1
+ require_relative '../service'
2
+ module Adyen
3
+ class DonationsApi < Service
4
+ attr_accessor :service, :version
5
+
6
+ def initialize(client, version = DEFAULT_VERSION)
7
+ super(client, version, 'Checkout')
8
+ end
9
+
10
+ def donations(request, headers: {})
11
+ endpoint = '/donations'.gsub(/{.+?}/, '%s')
12
+ endpoint = endpoint.gsub(%r{^/}, '')
13
+ endpoint = format(endpoint)
14
+
15
+ action = { method: 'post', url: endpoint }
16
+ @client.call_adyen_api(@service, action, request, headers, @version)
17
+ end
18
+
19
+ end
20
+ end
@@ -16,15 +16,6 @@ module Adyen
16
16
  @client.call_adyen_api(@service, action, request, headers, @version)
17
17
  end
18
18
 
19
- def donations(request, headers: {})
20
- endpoint = '/donations'.gsub(/{.+?}/, '%s')
21
- endpoint = endpoint.gsub(%r{^/}, '')
22
- endpoint = format(endpoint)
23
-
24
- action = { method: 'post', url: endpoint }
25
- @client.call_adyen_api(@service, action, request, headers, @version)
26
- end
27
-
28
19
  def get_result_of_payment_session(session_id, headers: {}, query_params: {})
29
20
  endpoint = '/sessions/{sessionId}'.gsub(/{.+?}/, '%s')
30
21
  endpoint = endpoint.gsub(%r{^/}, '')
@@ -1,4 +1,5 @@
1
1
  require_relative 'checkout/classic_checkout_sdk_api'
2
+ require_relative 'checkout/donations_api'
2
3
  require_relative 'checkout/modifications_api'
3
4
  require_relative 'checkout/orders_api'
4
5
  require_relative 'checkout/payment_links_api'
@@ -21,6 +22,10 @@ module Adyen
21
22
  @classic_checkout_sdk_api ||= Adyen::ClassicCheckoutSDKApi.new(@client, @version)
22
23
  end
23
24
 
25
+ def donations_api
26
+ @donations_api ||= Adyen::DonationsApi.new(@client, @version)
27
+ end
28
+
24
29
  def modifications_api
25
30
  @modifications_api ||= Adyen::ModificationsApi.new(@client, @version)
26
31
  end
@@ -7,10 +7,10 @@ module Adyen
7
7
  super(client, version, 'Transfers')
8
8
  end
9
9
 
10
- def return_transfer(request, id, headers: {})
11
- endpoint = '/transfers/{id}/returns'.gsub(/{.+?}/, '%s')
10
+ def return_transfer(request, transfer_id, headers: {})
11
+ endpoint = '/transfers/{transferId}/returns'.gsub(/{.+?}/, '%s')
12
12
  endpoint = endpoint.gsub(%r{^/}, '')
13
- endpoint = format(endpoint, id)
13
+ endpoint = format(endpoint, transfer_id)
14
14
 
15
15
  action = { method: 'post', url: endpoint }
16
16
  @client.call_adyen_api(@service, action, request, headers, @version)
@@ -15,7 +15,8 @@ module Adyen
15
15
 
16
16
  def valid_webhook_hmac?(webhook_request_item, hmac_key)
17
17
  expected_sign = calculate_webhook_hmac(webhook_request_item, hmac_key)
18
- merchant_sign = fetch(webhook_request_item, 'additionalData.hmacSignature')
18
+ merchant_sign =
19
+ webhook_request_item.dig('additionalData', 'hmacSignature')
19
20
 
20
21
  expected_sign == merchant_sign
21
22
  end
@@ -29,29 +30,20 @@ module Adyen
29
30
  def calculate_webhook_hmac(webhook_request_item, hmac_key)
30
31
  data = data_to_sign(webhook_request_item)
31
32
 
32
- Base64.strict_encode64(OpenSSL::HMAC.digest(HMAC_ALGORITHM, [hmac_key].pack('H*'), data))
33
+ Base64.strict_encode64(
34
+ OpenSSL::HMAC.digest(HMAC_ALGORITHM, [hmac_key].pack('H*'), data)
35
+ )
33
36
  end
34
37
 
38
+ # TODO: Deprecate instead of aliasing
39
+ alias valid_notification_hmac? valid_webhook_hmac?
40
+ alias calculate_notification_hmac calculate_webhook_hmac
35
41
 
36
42
  def data_to_sign(webhook_request_item)
37
- data = WEBHOOK_VALIDATION_KEYS.map { |key| fetch(webhook_request_item, key).to_s }
38
- .join(DATA_SEPARATOR)
39
- end
40
-
41
- private
42
-
43
- def fetch(hash, keys)
44
- value = hash
45
- keys.to_s.split('.').each do |key|
46
- value = if key.to_i.to_s == key
47
- value[key.to_i]
48
- else
49
- value[key].nil? ? value[key.to_sym] : value[key]
50
- end
51
- break if value.nil?
52
- end
53
-
54
- value
43
+ WEBHOOK_VALIDATION_KEYS
44
+ .map { webhook_request_item.dig(*_1.split('.')).to_s }
45
+ .compact
46
+ .join(DATA_SEPARATOR)
55
47
  end
56
48
  end
57
49
  end
data/lib/adyen/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Adyen
2
2
  NAME = 'adyen-ruby-api-library'.freeze
3
- VERSION = '8.0.1'.freeze
3
+ VERSION = '9.1.0'.freeze
4
4
  end
@@ -6,19 +6,19 @@ RSpec.describe Adyen::Utils::HmacValidator do
6
6
  let(:expected_sign) { 'coqCmt/IZ4E3CzPvMY8zTjQVL5hYJUiBRg8UU+iCWo0=' }
7
7
  let(:webhook_request_item) do
8
8
  {
9
- additionalData: {
10
- hmacSignature: expected_sign
9
+ 'additionalData' => {
10
+ 'hmacSignature' => expected_sign
11
11
  },
12
- amount: {
13
- value: 1130,
14
- currency: 'EUR'
12
+ 'amount' => {
13
+ 'value' => 1130,
14
+ 'currency' => 'EUR'
15
15
  },
16
- pspReference: '7914073381342284',
17
- eventCode: 'AUTHORISATION',
18
- merchantAccountCode: 'TestMerchant',
19
- merchantReference: 'TestPayment-1407325143704',
20
- paymentMethod: 'visa',
21
- success: 'true'
16
+ 'pspReference' => '7914073381342284',
17
+ 'eventCode' => 'AUTHORISATION',
18
+ 'merchantAccountCode' => 'TestMerchant',
19
+ 'merchantReference' => 'TestPayment-1407325143704',
20
+ 'paymentMethod' => 'visa',
21
+ 'success' => 'true'
22
22
  }
23
23
  end
24
24
 
@@ -44,22 +44,22 @@ RSpec.describe Adyen::Utils::HmacValidator do
44
44
  end
45
45
 
46
46
  it 'should validate backslashes correctly' do
47
- webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/backslash_webhook.json"))
47
+ webhook = JSON.parse(json_from_file('mocks/responses/Webhooks/backslash_webhook.json'))
48
48
  expect(validator.valid_webhook_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
49
49
  end
50
50
 
51
51
  it 'should validate colons correctly' do
52
- webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/colon_webhook.json"))
52
+ webhook = JSON.parse(json_from_file('mocks/responses/Webhooks/colon_webhook.json'))
53
53
  expect(validator.valid_webhook_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
54
54
  end
55
55
 
56
56
  it 'should validate forward slashes correctly' do
57
- webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/forwardslash_webhook.json"))
57
+ webhook = JSON.parse(json_from_file('mocks/responses/Webhooks/forwardslash_webhook.json'))
58
58
  expect(validator.valid_webhook_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
59
59
  end
60
60
 
61
61
  it 'should validate mix of slashes and colon correctly' do
62
- webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/mixed_webhook.json"))
62
+ webhook = JSON.parse(json_from_file('mocks/responses/Webhooks/mixed_webhook.json'))
63
63
  expect(validator.valid_webhook_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
64
64
  end
65
65
  end
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: 8.0.1
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-19 00:00:00.000000000 Z
11
+ date: 2024-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -87,7 +87,6 @@ files:
87
87
  - ".github/workflows/release.yml"
88
88
  - ".github/workflows/ruby.yml"
89
89
  - ".github/workflows/rubygems_release.yml"
90
- - ".github/workflows/services.yml"
91
90
  - ".gitignore"
92
91
  - ".rubocop.yml"
93
92
  - CODE_OF_CONDUCT.md
@@ -125,8 +124,10 @@ files:
125
124
  - lib/adyen/services/balancePlatform/account_holders_api.rb
126
125
  - lib/adyen/services/balancePlatform/balance_accounts_api.rb
127
126
  - lib/adyen/services/balancePlatform/bank_account_validation_api.rb
127
+ - lib/adyen/services/balancePlatform/card_orders_api.rb
128
128
  - lib/adyen/services/balancePlatform/grant_accounts_api.rb
129
129
  - lib/adyen/services/balancePlatform/grant_offers_api.rb
130
+ - lib/adyen/services/balancePlatform/manage_card_pin_api.rb
130
131
  - lib/adyen/services/balancePlatform/network_tokens_api.rb
131
132
  - lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb
132
133
  - lib/adyen/services/balancePlatform/payment_instruments_api.rb
@@ -136,6 +137,7 @@ files:
136
137
  - lib/adyen/services/binLookup.rb
137
138
  - lib/adyen/services/checkout.rb
138
139
  - lib/adyen/services/checkout/classic_checkout_sdk_api.rb
140
+ - lib/adyen/services/checkout/donations_api.rb
139
141
  - lib/adyen/services/checkout/modifications_api.rb
140
142
  - lib/adyen/services/checkout/orders_api.rb
141
143
  - lib/adyen/services/checkout/payment_links_api.rb
@@ -442,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
442
444
  - !ruby/object:Gem::Version
443
445
  version: '0'
444
446
  requirements: []
445
- rubygems_version: 3.4.10
447
+ rubygems_version: 3.5.3
446
448
  signing_key:
447
449
  specification_version: 4
448
450
  summary: Official Adyen Ruby API Library
@@ -1,28 +0,0 @@
1
- name: Ruby Library Services Generation
2
-
3
- on: [ workflow_dispatch ]
4
-
5
- jobs:
6
- generate:
7
- runs-on: ubuntu-latest
8
- name: Generate Services
9
- steps:
10
- - uses: actions/checkout@v4
11
- - run: make allServices
12
- - name: Set PR variables
13
- id: vars
14
- run: |
15
- echo ::set-output name=pr_title::"Update services"
16
- echo ::set-output name=pr_body::"OpenAPI spec or templates produced new services on $(date +%d-%m-%Y) \
17
- by [commit](https://github.com/Adyen/adyen-openapi/commit/$(git rev-parse HEAD))."
18
- - name: Create Pull Request
19
- uses: peter-evans/create-pull-request@v5
20
- with:
21
- token: ${{ secrets.ADYEN_AUTOMATION_BOT_ACCESS_TOKEN }}
22
- committer: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
23
- author: ${{ secrets.ADYEN_AUTOMATION_BOT_EMAIL }}
24
- base: main
25
- branch: automation/services
26
- title: ${{ steps.vars.outputs.pr_title }}
27
- body: ${{ steps.vars.outputs.pr_body }}
28
- add-paths: lib/adyen/services