adyen-ruby-api-library 6.2.0 → 7.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/CODEOWNERS +1 -1
- data/.github/workflows/codeql.yml +41 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/rubygems_release.yml +1 -1
- data/.gitignore +3 -0
- data/Makefile +72 -0
- data/README.md +20 -18
- data/lib/adyen/client.rb +82 -42
- data/lib/adyen/errors.rb +2 -2
- data/lib/adyen/services/balanceControlService.rb +28 -0
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +63 -0
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +123 -0
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +51 -0
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +75 -0
- data/lib/adyen/services/balancePlatform/platform_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +63 -0
- data/lib/adyen/services/balancePlatform.rb +61 -0
- data/lib/adyen/services/binLookup.rb +40 -0
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +39 -0
- data/lib/adyen/services/checkout/modifications_api.rb +87 -0
- data/lib/adyen/services/checkout/orders_api.rb +51 -0
- data/lib/adyen/services/checkout/payment_links_api.rb +51 -0
- data/lib/adyen/services/checkout/payments_api.rb +87 -0
- data/lib/adyen/services/checkout/recurring_api.rb +39 -0
- data/lib/adyen/services/checkout/utility_api.rb +39 -0
- data/lib/adyen/services/checkout.rb +39 -180
- data/lib/adyen/services/dataProtection.rb +28 -0
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +75 -0
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement.rb +51 -0
- data/lib/adyen/services/management/account_company_level_api.rb +51 -0
- data/lib/adyen/services/management/account_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/account_store_level_api.rb +111 -0
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +63 -0
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/my_api_credential_api.rb +75 -0
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +87 -0
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +75 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +111 -0
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +63 -0
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/users_company_level_api.rb +63 -0
- data/lib/adyen/services/management/users_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/webhooks_company_level_api.rb +99 -0
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +99 -0
- data/lib/adyen/services/management.rb +151 -0
- data/lib/adyen/services/payment.rb +172 -0
- data/lib/adyen/services/payout/initialization_api.rb +51 -0
- data/lib/adyen/services/payout/instant_payouts_api.rb +27 -0
- data/lib/adyen/services/payout/reviewing_api.rb +39 -0
- data/lib/adyen/services/payout.rb +31 -0
- data/lib/adyen/services/posTerminalManagement.rb +76 -0
- data/lib/adyen/services/recurring.rb +81 -13
- data/lib/adyen/services/service.rb +6 -1
- data/lib/adyen/services/storedValue.rb +88 -0
- data/lib/adyen/services/transfers/transactions_api.rb +39 -0
- data/lib/adyen/services/transfers/transfers_api.rb +27 -0
- data/lib/adyen/services/transfers.rb +26 -0
- data/lib/adyen/utils/hmac_validator.rb +2 -3
- data/lib/adyen/version.rb +2 -2
- data/lib/adyen-ruby-api-library.rb +11 -5
- data/spec/account_spec.rb +1 -1
- data/spec/balance_control_spec.rb +44 -0
- data/spec/balance_platform_spec.rb +123 -0
- data/spec/bin_lookup_spec.rb +68 -10
- data/spec/checkout_spec.rb +85 -62
- data/spec/client_spec.rb +89 -10
- data/spec/errors_spec.rb +1 -1
- data/spec/fund_spec.rb +1 -1
- data/spec/hop_spec.rb +1 -1
- data/spec/lem_spec.rb +68 -0
- data/spec/management_spec.rb +68 -0
- data/spec/mocks/requests/BalanceControl/balance_transfer.json +10 -0
- data/spec/mocks/requests/BalancePlatform/create_account_holder.json +5 -0
- data/spec/mocks/requests/BalancePlatform/update_account_holder.json +10 -0
- data/spec/mocks/requests/LegalEntityManagement/create_business_line.json +15 -0
- data/spec/mocks/requests/Management/create_store.json +15 -0
- data/spec/mocks/requests/Recurring/create_permit.json +6 -0
- data/spec/mocks/requests/StoredValue/issue_giftcard.json +12 -0
- data/spec/mocks/requests/Transfers/get_transactions.json +82 -0
- data/spec/mocks/requests/Transfers/make_transfer.json +32 -0
- data/spec/mocks/responses/BalanceControl/balance_transfer.json +14 -0
- data/spec/mocks/responses/BalancePlatform/create_account_holder.json +41 -0
- data/spec/mocks/responses/BalancePlatform/get_balance_account.json +15 -0
- data/spec/mocks/responses/BalancePlatform/update_account_holder.json +16 -0
- data/spec/mocks/responses/Checkout/stored_payment_methods.json +1 -0
- data/spec/mocks/responses/LegalEntityManagement/create_business_line.json +17 -0
- data/spec/mocks/responses/Management/create_store.json +23 -0
- data/spec/mocks/responses/Management/get_companies.json +42 -0
- data/spec/mocks/responses/Recurring/create_permit.json +4 -0
- data/spec/mocks/responses/StoredValue/issue_giftcard.json +13 -0
- data/spec/mocks/responses/Transfers/get_transactions.json +82 -0
- data/spec/mocks/responses/Transfers/make_transfer.json +36 -0
- data/spec/mocks/responses/Webhooks/backslash_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/colon_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/forwardslash_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/mixed_notification.json +41 -0
- data/spec/notification_spec.rb +1 -1
- data/spec/payments_spec.rb +41 -23
- data/spec/payouts_spec.rb +43 -16
- data/spec/pos_terminal_management_spec.rb +46 -0
- data/spec/recurring_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/stored_value_spec.rb +43 -0
- data/spec/transfers_spec.rb +63 -0
- data/spec/utils/hmac_validator_spec.rb +20 -6
- data/templates/api-single.mustache +29 -0
- data/templates/api-small.mustache +37 -0
- data/templates/api.mustache +36 -0
- data/templates/config.yaml +10 -0
- metadata +107 -11
- data/lib/adyen/services/bin_lookup.rb +0 -18
- data/lib/adyen/services/data_protection.rb +0 -17
- data/lib/adyen/services/payments.rb +0 -34
- data/lib/adyen/services/payouts.rb +0 -22
- data/lib/adyen/services/postfmapi.rb +0 -19
- data/spec/mocks/requests/Recurring/store_token.json +0 -15
- data/spec/mocks/responses/Recurring/store_token.json +0 -7
- data/spec/postfmapi_spec.rb +0 -16
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative './service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class PosTerminalManagement < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
DEFAULT_VERSION = 1
|
8
|
+
|
9
|
+
def initialize(client, version = DEFAULT_VERSION)
|
10
|
+
@service = "PosTerminalManagement"
|
11
|
+
@client = client
|
12
|
+
@version = version
|
13
|
+
end
|
14
|
+
|
15
|
+
def assign_terminals(request, headers: {} )
|
16
|
+
"""
|
17
|
+
Assign terminals
|
18
|
+
"""
|
19
|
+
endpoint = "/assignTerminals".gsub(/{.+?}/, '%s')
|
20
|
+
endpoint = endpoint.gsub(/^\//, "")
|
21
|
+
endpoint = endpoint % []
|
22
|
+
|
23
|
+
action = { method: "post", url: endpoint}
|
24
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_terminal(request, headers: {} )
|
28
|
+
"""
|
29
|
+
Get the account or store of a terminal
|
30
|
+
"""
|
31
|
+
endpoint = "/findTerminal".gsub(/{.+?}/, '%s')
|
32
|
+
endpoint = endpoint.gsub(/^\//, "")
|
33
|
+
endpoint = endpoint % []
|
34
|
+
|
35
|
+
action = { method: "post", url: endpoint}
|
36
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_stores_under_account(request, headers: {} )
|
40
|
+
"""
|
41
|
+
Get the stores of an account
|
42
|
+
"""
|
43
|
+
endpoint = "/getStoresUnderAccount".gsub(/{.+?}/, '%s')
|
44
|
+
endpoint = endpoint.gsub(/^\//, "")
|
45
|
+
endpoint = endpoint % []
|
46
|
+
|
47
|
+
action = { method: "post", url: endpoint}
|
48
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_terminal_details(request, headers: {} )
|
52
|
+
"""
|
53
|
+
Get the details of a terminal
|
54
|
+
"""
|
55
|
+
endpoint = "/getTerminalDetails".gsub(/{.+?}/, '%s')
|
56
|
+
endpoint = endpoint.gsub(/^\//, "")
|
57
|
+
endpoint = endpoint % []
|
58
|
+
|
59
|
+
action = { method: "post", url: endpoint}
|
60
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_terminals_under_account(request, headers: {} )
|
64
|
+
"""
|
65
|
+
Get the list of terminals
|
66
|
+
"""
|
67
|
+
endpoint = "/getTerminalsUnderAccount".gsub(/{.+?}/, '%s')
|
68
|
+
endpoint = endpoint.gsub(/^\//, "")
|
69
|
+
endpoint = endpoint % []
|
70
|
+
|
71
|
+
action = { method: "post", url: endpoint}
|
72
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -1,20 +1,88 @@
|
|
1
|
-
require_relative 'service'
|
2
|
-
|
1
|
+
require_relative './service'
|
3
2
|
module Adyen
|
3
|
+
|
4
|
+
|
4
5
|
class Recurring < Service
|
5
|
-
attr_accessor :version
|
6
|
-
DEFAULT_VERSION =
|
6
|
+
attr_accessor :service, :version
|
7
|
+
DEFAULT_VERSION = 68
|
7
8
|
|
8
9
|
def initialize(client, version = DEFAULT_VERSION)
|
9
|
-
service =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
@service = "Recurring"
|
11
|
+
@client = client
|
12
|
+
@version = version
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_permit(request, headers: {} )
|
16
|
+
"""
|
17
|
+
Create new permits linked to a recurring contract.
|
18
|
+
"""
|
19
|
+
endpoint = "/createPermit".gsub(/{.+?}/, '%s')
|
20
|
+
endpoint = endpoint.gsub(/^\//, "")
|
21
|
+
endpoint = endpoint % []
|
22
|
+
|
23
|
+
action = { method: "post", url: endpoint}
|
24
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
25
|
+
end
|
26
|
+
|
27
|
+
def disable(request, headers: {} )
|
28
|
+
"""
|
29
|
+
Disable stored payment details
|
30
|
+
"""
|
31
|
+
endpoint = "/disable".gsub(/{.+?}/, '%s')
|
32
|
+
endpoint = endpoint.gsub(/^\//, "")
|
33
|
+
endpoint = endpoint % []
|
34
|
+
|
35
|
+
action = { method: "post", url: endpoint}
|
36
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
37
|
+
end
|
38
|
+
|
39
|
+
def disable_permit(request, headers: {} )
|
40
|
+
"""
|
41
|
+
Disable an existing permit.
|
42
|
+
"""
|
43
|
+
endpoint = "/disablePermit".gsub(/{.+?}/, '%s')
|
44
|
+
endpoint = endpoint.gsub(/^\//, "")
|
45
|
+
endpoint = endpoint % []
|
46
|
+
|
47
|
+
action = { method: "post", url: endpoint}
|
48
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
49
|
+
end
|
50
|
+
|
51
|
+
def list_recurring_details(request, headers: {} )
|
52
|
+
"""
|
53
|
+
Get stored payment details
|
54
|
+
"""
|
55
|
+
endpoint = "/listRecurringDetails".gsub(/{.+?}/, '%s')
|
56
|
+
endpoint = endpoint.gsub(/^\//, "")
|
57
|
+
endpoint = endpoint % []
|
58
|
+
|
59
|
+
action = { method: "post", url: endpoint}
|
60
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def notify_shopper(request, headers: {} )
|
64
|
+
"""
|
65
|
+
Ask issuer to notify the shopper
|
66
|
+
"""
|
67
|
+
endpoint = "/notifyShopper".gsub(/{.+?}/, '%s')
|
68
|
+
endpoint = endpoint.gsub(/^\//, "")
|
69
|
+
endpoint = endpoint % []
|
70
|
+
|
71
|
+
action = { method: "post", url: endpoint}
|
72
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
73
|
+
end
|
74
|
+
|
75
|
+
def schedule_account_updater(request, headers: {} )
|
76
|
+
"""
|
77
|
+
Schedule running the Account Updater
|
78
|
+
"""
|
79
|
+
endpoint = "/scheduleAccountUpdater".gsub(/{.+?}/, '%s')
|
80
|
+
endpoint = endpoint.gsub(/^\//, "")
|
81
|
+
endpoint = endpoint % []
|
82
|
+
|
83
|
+
action = { method: "post", url: endpoint}
|
84
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
18
85
|
end
|
86
|
+
|
19
87
|
end
|
20
88
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Adyen
|
2
2
|
class Service
|
3
|
-
attr_accessor :service, :version
|
3
|
+
attr_accessor :service, :version, :create_query_string
|
4
4
|
|
5
5
|
# add snake case to camel case converter to String
|
6
6
|
# to convert rubinic method names to Adyen API methods
|
@@ -24,5 +24,10 @@ module Adyen
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
+
|
28
|
+
# create query parameter from a hash
|
29
|
+
def create_query_string(arr)
|
30
|
+
"?" + URI.encode_www_form(arr)
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require_relative './service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class StoredValue < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
DEFAULT_VERSION = 46
|
8
|
+
|
9
|
+
def initialize(client, version = DEFAULT_VERSION)
|
10
|
+
@service = "StoredValue"
|
11
|
+
@client = client
|
12
|
+
@version = version
|
13
|
+
end
|
14
|
+
|
15
|
+
def change_status(request, headers: {} )
|
16
|
+
"""
|
17
|
+
Changes the status of the payment method.
|
18
|
+
"""
|
19
|
+
endpoint = "/changeStatus".gsub(/{.+?}/, '%s')
|
20
|
+
endpoint = endpoint.gsub(/^\//, "")
|
21
|
+
endpoint = endpoint % []
|
22
|
+
|
23
|
+
action = { method: "post", url: endpoint}
|
24
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_balance(request, headers: {} )
|
28
|
+
"""
|
29
|
+
Checks the balance.
|
30
|
+
"""
|
31
|
+
endpoint = "/checkBalance".gsub(/{.+?}/, '%s')
|
32
|
+
endpoint = endpoint.gsub(/^\//, "")
|
33
|
+
endpoint = endpoint % []
|
34
|
+
|
35
|
+
action = { method: "post", url: endpoint}
|
36
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
37
|
+
end
|
38
|
+
|
39
|
+
def issue(request, headers: {} )
|
40
|
+
"""
|
41
|
+
Issues a new card.
|
42
|
+
"""
|
43
|
+
endpoint = "/issue".gsub(/{.+?}/, '%s')
|
44
|
+
endpoint = endpoint.gsub(/^\//, "")
|
45
|
+
endpoint = endpoint % []
|
46
|
+
|
47
|
+
action = { method: "post", url: endpoint}
|
48
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
49
|
+
end
|
50
|
+
|
51
|
+
def load(request, headers: {} )
|
52
|
+
"""
|
53
|
+
Loads the payment method.
|
54
|
+
"""
|
55
|
+
endpoint = "/load".gsub(/{.+?}/, '%s')
|
56
|
+
endpoint = endpoint.gsub(/^\//, "")
|
57
|
+
endpoint = endpoint % []
|
58
|
+
|
59
|
+
action = { method: "post", url: endpoint}
|
60
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
61
|
+
end
|
62
|
+
|
63
|
+
def merge_balance(request, headers: {} )
|
64
|
+
"""
|
65
|
+
Merge the balance of two cards.
|
66
|
+
"""
|
67
|
+
endpoint = "/mergeBalance".gsub(/{.+?}/, '%s')
|
68
|
+
endpoint = endpoint.gsub(/^\//, "")
|
69
|
+
endpoint = endpoint % []
|
70
|
+
|
71
|
+
action = { method: "post", url: endpoint}
|
72
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
73
|
+
end
|
74
|
+
|
75
|
+
def void_transaction(request, headers: {} )
|
76
|
+
"""
|
77
|
+
Voids a transaction.
|
78
|
+
"""
|
79
|
+
endpoint = "/voidTransaction".gsub(/{.+?}/, '%s')
|
80
|
+
endpoint = endpoint.gsub(/^\//, "")
|
81
|
+
endpoint = endpoint % []
|
82
|
+
|
83
|
+
action = { method: "post", url: endpoint}
|
84
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class TransactionsApi < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
@service = "Transfers"
|
10
|
+
@client = client
|
11
|
+
@version = version
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_all_transactions(headers: {} , queryParams: {})
|
15
|
+
"""
|
16
|
+
Get all transactions
|
17
|
+
"""
|
18
|
+
endpoint = "/transactions".gsub(/{.+?}/, '%s')
|
19
|
+
endpoint = endpoint.gsub(/^\//, "")
|
20
|
+
endpoint = endpoint % []
|
21
|
+
endpoint = endpoint + create_query_string(queryParams)
|
22
|
+
action = { method: "get", url: endpoint}
|
23
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_transaction(id, headers: {} )
|
27
|
+
"""
|
28
|
+
Get a transaction
|
29
|
+
"""
|
30
|
+
endpoint = "/transactions/{id}".gsub(/{.+?}/, '%s')
|
31
|
+
endpoint = endpoint.gsub(/^\//, "")
|
32
|
+
endpoint = endpoint % [id]
|
33
|
+
|
34
|
+
action = { method: "get", url: endpoint}
|
35
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
|
4
|
+
|
5
|
+
class TransfersApi < Service
|
6
|
+
attr_accessor :service, :version
|
7
|
+
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
9
|
+
@service = "Transfers"
|
10
|
+
@client = client
|
11
|
+
@version = version
|
12
|
+
end
|
13
|
+
|
14
|
+
def transfer_funds(request, headers: {} )
|
15
|
+
"""
|
16
|
+
Transfer funds
|
17
|
+
"""
|
18
|
+
endpoint = "/transfers".gsub(/{.+?}/, '%s')
|
19
|
+
endpoint = endpoint.gsub(/^\//, "")
|
20
|
+
endpoint = endpoint % []
|
21
|
+
|
22
|
+
action = { method: "post", url: endpoint}
|
23
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'transfers/transactions_api'
|
2
|
+
require_relative 'transfers/transfers_api'
|
3
|
+
|
4
|
+
module Adyen
|
5
|
+
|
6
|
+
|
7
|
+
class Transfers
|
8
|
+
attr_accessor :service, :version
|
9
|
+
|
10
|
+
DEFAULT_VERSION = 3
|
11
|
+
def initialize(client, version = DEFAULT_VERSION)
|
12
|
+
@service = "Transfers"
|
13
|
+
@client = client
|
14
|
+
@version = version
|
15
|
+
end
|
16
|
+
|
17
|
+
def transactions_api
|
18
|
+
@transactions_api ||= Adyen::TransactionsApi.new(@client, @version)
|
19
|
+
end
|
20
|
+
|
21
|
+
def transfers_api
|
22
|
+
@transfers_api ||= Adyen::TransfersApi.new(@client, @version)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -22,16 +22,15 @@ module Adyen
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def data_to_sign(notification_request_item)
|
25
|
-
NOTIFICATION_VALIDATION_KEYS.map { |key| fetch(notification_request_item, key).to_s }
|
26
|
-
.map { |value| value.gsub('\\', '\\\\').gsub(':', '\\:') }
|
25
|
+
data = NOTIFICATION_VALIDATION_KEYS.map { |key| fetch(notification_request_item, key).to_s }
|
27
26
|
.join(DATA_SEPARATOR)
|
27
|
+
return data
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def fetch(hash, keys)
|
33
33
|
value = hash
|
34
|
-
|
35
34
|
keys.to_s.split('.').each do |key|
|
36
35
|
value = if key.to_i.to_s == key
|
37
36
|
value[key.to_i]
|
data/lib/adyen/version.rb
CHANGED
@@ -2,14 +2,20 @@ require_relative "adyen/version"
|
|
2
2
|
require_relative "adyen/client"
|
3
3
|
require_relative "adyen/errors"
|
4
4
|
require_relative "adyen/services/checkout"
|
5
|
-
require_relative "adyen/services/
|
6
|
-
require_relative "adyen/services/
|
5
|
+
require_relative "adyen/services/payment"
|
6
|
+
require_relative "adyen/services/payout"
|
7
7
|
require_relative "adyen/services/recurring"
|
8
8
|
require_relative "adyen/services/marketpay"
|
9
|
-
require_relative "adyen/services/
|
9
|
+
require_relative "adyen/services/posTerminalManagement"
|
10
10
|
require_relative "adyen/services/service"
|
11
|
-
require_relative "adyen/services/
|
11
|
+
require_relative "adyen/services/dataProtection"
|
12
12
|
require_relative "adyen/services/dispute"
|
13
|
-
require_relative "adyen/services/
|
13
|
+
require_relative "adyen/services/binLookup"
|
14
14
|
require_relative "adyen/hash_with_accessors"
|
15
15
|
require_relative "adyen/utils/hmac_validator"
|
16
|
+
require_relative "adyen/services/legalEntityManagement"
|
17
|
+
require_relative "adyen/services/balancePlatform"
|
18
|
+
require_relative "adyen/services/transfers"
|
19
|
+
require_relative "adyen/services/management"
|
20
|
+
require_relative "adyen/services/storedValue"
|
21
|
+
require_relative "adyen/services/balanceControlService"
|
data/spec/account_spec.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::BalancePlatform, service: "balancePlatform" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "BalancePlatform",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a balance transfer POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BalanceControl/balance_transfer.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/BalanceControl/balance_transfer.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "balanceTransfer", @shared_values[:client].balance_control_service.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].balance_control_service.balance_transfer(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::BalancePlatform, service: "balancePlatform" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "BalancePlatform",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a account_holder POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BalancePlatform/create_account_holder.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/BalancePlatform/create_account_holder.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "accountHolders", @shared_values[:client].balance_platform.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].balance_platform.account_holders_api.create_account_holder(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
|
45
|
+
it "makes a account_holder PATCH call" do
|
46
|
+
request_body = JSON.parse(json_from_file("mocks/requests/BalancePlatform/update_account_holder.json"))
|
47
|
+
|
48
|
+
response_body = json_from_file("mocks/responses/BalancePlatform/update_account_holder.json")
|
49
|
+
|
50
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "accountHolders/AH3227C223222C5GKR23686TF", @shared_values[:client].balance_platform.version)
|
51
|
+
WebMock.stub_request(:patch, url).
|
52
|
+
with(
|
53
|
+
body: request_body,
|
54
|
+
headers: {
|
55
|
+
"x-api-key" => @shared_values[:client].api_key
|
56
|
+
}
|
57
|
+
).
|
58
|
+
to_return(
|
59
|
+
body: response_body
|
60
|
+
)
|
61
|
+
|
62
|
+
result = @shared_values[:client].balance_platform.account_holders_api.update_account_holder(request_body, id = "AH3227C223222C5GKR23686TF")
|
63
|
+
response_hash = result.response
|
64
|
+
|
65
|
+
expect(result.status).
|
66
|
+
to eq(200)
|
67
|
+
expect(response_hash).
|
68
|
+
to eq(JSON.parse(response_body))
|
69
|
+
expect(response_hash).
|
70
|
+
to be_a Adyen::HashWithAccessors
|
71
|
+
expect(response_hash).
|
72
|
+
to be_a_kind_of Hash
|
73
|
+
end
|
74
|
+
|
75
|
+
it "makes a balance_account GET call" do
|
76
|
+
|
77
|
+
response_body = json_from_file("mocks/responses/BalancePlatform/get_balance_account.json")
|
78
|
+
|
79
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "balanceAccounts/BA3227C223222B5BLP6JQC3FD", @shared_values[:client].balance_platform.version)
|
80
|
+
WebMock.stub_request(:get, url).
|
81
|
+
with(
|
82
|
+
headers: {
|
83
|
+
"x-api-key" => @shared_values[:client].api_key
|
84
|
+
}
|
85
|
+
).
|
86
|
+
to_return(
|
87
|
+
body: response_body
|
88
|
+
)
|
89
|
+
|
90
|
+
result = @shared_values[:client].balance_platform.balance_accounts_api.get_balance_account(id = "BA3227C223222B5BLP6JQC3FD")
|
91
|
+
response_hash = result.response
|
92
|
+
|
93
|
+
expect(result.status).
|
94
|
+
to eq(200)
|
95
|
+
expect(response_hash).
|
96
|
+
to eq(JSON.parse(response_body))
|
97
|
+
expect(response_hash).
|
98
|
+
to be_a Adyen::HashWithAccessors
|
99
|
+
expect(response_hash).
|
100
|
+
to be_a_kind_of Hash
|
101
|
+
end
|
102
|
+
|
103
|
+
it "makes a balance_account/sweeps DELETE call" do
|
104
|
+
|
105
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "balanceAccounts/balanceAccountID/sweeps/sweepID", @shared_values[:client].balance_platform.version)
|
106
|
+
WebMock.stub_request(:delete, url).
|
107
|
+
with(
|
108
|
+
headers: {
|
109
|
+
"x-api-key" => @shared_values[:client].api_key
|
110
|
+
}
|
111
|
+
).
|
112
|
+
to_return(
|
113
|
+
body: "{}"
|
114
|
+
)
|
115
|
+
|
116
|
+
result = @shared_values[:client].balance_platform.balance_accounts_api.delete_sweep("balanceAccountID", "sweepID")
|
117
|
+
response_hash = result.response
|
118
|
+
|
119
|
+
expect(result.status).
|
120
|
+
to eq(200)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|