adyen-ruby-api-library 8.0.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql.yml +5 -5
- data/.github/workflows/rubygems_release.yml +1 -4
- data/CONTRIBUTING.md +1 -1
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +9 -9
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +32 -32
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +10 -10
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +17 -17
- data/lib/adyen/services/balancePlatform/platform_api.rb +6 -6
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +9 -9
- data/lib/adyen/services/checkout/donations_api.rb +20 -0
- data/lib/adyen/services/checkout/modifications_api.rb +9 -9
- data/lib/adyen/services/checkout/orders_api.rb +6 -6
- data/lib/adyen/services/checkout/payment_links_api.rb +8 -8
- data/lib/adyen/services/checkout/payments_api.rb +6 -15
- data/lib/adyen/services/checkout.rb +5 -0
- data/lib/adyen/services/dataProtection.rb +1 -1
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +9 -9
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +10 -10
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +27 -18
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +8 -8
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +18 -18
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +9 -9
- data/lib/adyen/services/management/account_company_level_api.rb +8 -8
- data/lib/adyen/services/management/account_merchant_level_api.rb +8 -8
- data/lib/adyen/services/management/account_store_level_api.rb +26 -26
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +12 -12
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +12 -12
- data/lib/adyen/services/management/android_files_company_level_api.rb +8 -8
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +13 -13
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +13 -13
- data/lib/adyen/services/management/my_api_credential_api.rb +22 -22
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +15 -15
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +15 -15
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +30 -30
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +8 -8
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +40 -40
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +40 -40
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +16 -16
- data/lib/adyen/services/management/users_company_level_api.rb +13 -13
- data/lib/adyen/services/management/users_merchant_level_api.rb +13 -13
- data/lib/adyen/services/management/webhooks_company_level_api.rb +19 -19
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +19 -19
- data/lib/adyen/services/transfers/transfers_api.rb +6 -6
- data/lib/adyen/utils/hmac_validator.rb +12 -20
- data/lib/adyen/version.rb +1 -1
- data/spec/utils/hmac_validator_spec.rb +15 -15
- metadata +4 -3
@@ -7,12 +7,21 @@ module Adyen
|
|
7
7
|
super(client, version, 'Management')
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def generate_hmac_key(company_id, webhook_id, headers: {})
|
11
|
+
endpoint = '/companies/{companyId}/webhooks/{webhookId}/generateHmac'.gsub(/{.+?}/, '%s')
|
12
|
+
endpoint = endpoint.gsub(%r{^/}, '')
|
13
|
+
endpoint = format(endpoint, company_id, webhook_id)
|
14
|
+
|
15
|
+
action = { method: 'post', url: endpoint }
|
16
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_webhook(company_id, webhook_id, headers: {})
|
11
20
|
endpoint = '/companies/{companyId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
12
21
|
endpoint = endpoint.gsub(%r{^/}, '')
|
13
22
|
endpoint = format(endpoint, company_id, webhook_id)
|
14
23
|
|
15
|
-
action = { method: '
|
24
|
+
action = { method: 'get', url: endpoint }
|
16
25
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
26
|
end
|
18
27
|
|
@@ -25,24 +34,15 @@ module Adyen
|
|
25
34
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
26
35
|
end
|
27
36
|
|
28
|
-
def
|
37
|
+
def remove_webhook(company_id, webhook_id, headers: {})
|
29
38
|
endpoint = '/companies/{companyId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
30
39
|
endpoint = endpoint.gsub(%r{^/}, '')
|
31
40
|
endpoint = format(endpoint, company_id, webhook_id)
|
32
41
|
|
33
|
-
action = { method: '
|
42
|
+
action = { method: 'delete', url: endpoint }
|
34
43
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
35
44
|
end
|
36
45
|
|
37
|
-
def update_webhook(request, company_id, webhook_id, headers: {})
|
38
|
-
endpoint = '/companies/{companyId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
39
|
-
endpoint = endpoint.gsub(%r{^/}, '')
|
40
|
-
endpoint = format(endpoint, company_id, webhook_id)
|
41
|
-
|
42
|
-
action = { method: 'patch', url: endpoint }
|
43
|
-
@client.call_adyen_api(@service, action, request, headers, @version)
|
44
|
-
end
|
45
|
-
|
46
46
|
def set_up_webhook(request, company_id, headers: {})
|
47
47
|
endpoint = '/companies/{companyId}/webhooks'.gsub(/{.+?}/, '%s')
|
48
48
|
endpoint = endpoint.gsub(%r{^/}, '')
|
@@ -52,21 +52,21 @@ module Adyen
|
|
52
52
|
@client.call_adyen_api(@service, action, request, headers, @version)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
endpoint = '/companies/{companyId}/webhooks/{webhookId}/
|
55
|
+
def test_webhook(request, company_id, webhook_id, headers: {})
|
56
|
+
endpoint = '/companies/{companyId}/webhooks/{webhookId}/test'.gsub(/{.+?}/, '%s')
|
57
57
|
endpoint = endpoint.gsub(%r{^/}, '')
|
58
58
|
endpoint = format(endpoint, company_id, webhook_id)
|
59
59
|
|
60
60
|
action = { method: 'post', url: endpoint }
|
61
|
-
@client.call_adyen_api(@service, action,
|
61
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
65
|
-
endpoint = '/companies/{companyId}/webhooks/{webhookId}
|
64
|
+
def update_webhook(request, company_id, webhook_id, headers: {})
|
65
|
+
endpoint = '/companies/{companyId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
66
66
|
endpoint = endpoint.gsub(%r{^/}, '')
|
67
67
|
endpoint = format(endpoint, company_id, webhook_id)
|
68
68
|
|
69
|
-
action = { method: '
|
69
|
+
action = { method: 'patch', url: endpoint }
|
70
70
|
@client.call_adyen_api(@service, action, request, headers, @version)
|
71
71
|
end
|
72
72
|
|
@@ -7,12 +7,21 @@ module Adyen
|
|
7
7
|
super(client, version, 'Management')
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def generate_hmac_key(merchant_id, webhook_id, headers: {})
|
11
|
+
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}/generateHmac'.gsub(/{.+?}/, '%s')
|
12
|
+
endpoint = endpoint.gsub(%r{^/}, '')
|
13
|
+
endpoint = format(endpoint, merchant_id, webhook_id)
|
14
|
+
|
15
|
+
action = { method: 'post', url: endpoint }
|
16
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_webhook(merchant_id, webhook_id, headers: {})
|
11
20
|
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
12
21
|
endpoint = endpoint.gsub(%r{^/}, '')
|
13
22
|
endpoint = format(endpoint, merchant_id, webhook_id)
|
14
23
|
|
15
|
-
action = { method: '
|
24
|
+
action = { method: 'get', url: endpoint }
|
16
25
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
17
26
|
end
|
18
27
|
|
@@ -25,24 +34,15 @@ module Adyen
|
|
25
34
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
26
35
|
end
|
27
36
|
|
28
|
-
def
|
37
|
+
def remove_webhook(merchant_id, webhook_id, headers: {})
|
29
38
|
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
30
39
|
endpoint = endpoint.gsub(%r{^/}, '')
|
31
40
|
endpoint = format(endpoint, merchant_id, webhook_id)
|
32
41
|
|
33
|
-
action = { method: '
|
42
|
+
action = { method: 'delete', url: endpoint }
|
34
43
|
@client.call_adyen_api(@service, action, {}, headers, @version)
|
35
44
|
end
|
36
45
|
|
37
|
-
def update_webhook(request, merchant_id, webhook_id, headers: {})
|
38
|
-
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
39
|
-
endpoint = endpoint.gsub(%r{^/}, '')
|
40
|
-
endpoint = format(endpoint, merchant_id, webhook_id)
|
41
|
-
|
42
|
-
action = { method: 'patch', url: endpoint }
|
43
|
-
@client.call_adyen_api(@service, action, request, headers, @version)
|
44
|
-
end
|
45
|
-
|
46
46
|
def set_up_webhook(request, merchant_id, headers: {})
|
47
47
|
endpoint = '/merchants/{merchantId}/webhooks'.gsub(/{.+?}/, '%s')
|
48
48
|
endpoint = endpoint.gsub(%r{^/}, '')
|
@@ -52,21 +52,21 @@ module Adyen
|
|
52
52
|
@client.call_adyen_api(@service, action, request, headers, @version)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}/
|
55
|
+
def test_webhook(request, merchant_id, webhook_id, headers: {})
|
56
|
+
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}/test'.gsub(/{.+?}/, '%s')
|
57
57
|
endpoint = endpoint.gsub(%r{^/}, '')
|
58
58
|
endpoint = format(endpoint, merchant_id, webhook_id)
|
59
59
|
|
60
60
|
action = { method: 'post', url: endpoint }
|
61
|
-
@client.call_adyen_api(@service, action,
|
61
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
65
|
-
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}
|
64
|
+
def update_webhook(request, merchant_id, webhook_id, headers: {})
|
65
|
+
endpoint = '/merchants/{merchantId}/webhooks/{webhookId}'.gsub(/{.+?}/, '%s')
|
66
66
|
endpoint = endpoint.gsub(%r{^/}, '')
|
67
67
|
endpoint = format(endpoint, merchant_id, webhook_id)
|
68
68
|
|
69
|
-
action = { method: '
|
69
|
+
action = { method: 'patch', url: endpoint }
|
70
70
|
@client.call_adyen_api(@service, action, request, headers, @version)
|
71
71
|
end
|
72
72
|
|
@@ -7,19 +7,19 @@ module Adyen
|
|
7
7
|
super(client, version, 'Transfers')
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
endpoint = '/transfers'.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)
|
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)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
endpoint = '/transfers
|
19
|
+
def transfer_funds(request, headers: {})
|
20
|
+
endpoint = '/transfers'.gsub(/{.+?}/, '%s')
|
21
21
|
endpoint = endpoint.gsub(%r{^/}, '')
|
22
|
-
endpoint = format(endpoint
|
22
|
+
endpoint = format(endpoint)
|
23
23
|
|
24
24
|
action = { method: 'post', url: endpoint }
|
25
25
|
@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 =
|
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(
|
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
|
-
|
38
|
-
|
39
|
-
|
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
@@ -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
|
9
|
+
'additionalData' => {
|
10
|
+
'hmacSignature' => expected_sign
|
11
11
|
},
|
12
|
-
amount
|
13
|
-
value
|
14
|
-
currency
|
12
|
+
'amount' => {
|
13
|
+
'value' => 1130,
|
14
|
+
'currency' => 'EUR'
|
15
15
|
},
|
16
|
-
pspReference
|
17
|
-
eventCode
|
18
|
-
merchantAccountCode
|
19
|
-
merchantReference
|
20
|
-
paymentMethod
|
21
|
-
success
|
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(
|
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(
|
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(
|
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(
|
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:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/adyen/services/binLookup.rb
|
137
137
|
- lib/adyen/services/checkout.rb
|
138
138
|
- lib/adyen/services/checkout/classic_checkout_sdk_api.rb
|
139
|
+
- lib/adyen/services/checkout/donations_api.rb
|
139
140
|
- lib/adyen/services/checkout/modifications_api.rb
|
140
141
|
- lib/adyen/services/checkout/orders_api.rb
|
141
142
|
- lib/adyen/services/checkout/payment_links_api.rb
|
@@ -442,7 +443,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
442
443
|
- !ruby/object:Gem::Version
|
443
444
|
version: '0'
|
444
445
|
requirements: []
|
445
|
-
rubygems_version: 3.
|
446
|
+
rubygems_version: 3.5.3
|
446
447
|
signing_key:
|
447
448
|
specification_version: 4
|
448
449
|
summary: Official Adyen Ruby API Library
|