adyen-ruby-api-library 6.2.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a353164deda5fc44de3ec027f4022732e9c4afdb1a5bfacf91704e9d8c9e90a
|
|
4
|
+
data.tar.gz: 1f1f2d92d0f9528a9c6945da699a3a9d8a05e0594c7fe4d2fb66ad8c85c01c77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8d4190c1cbb857fa27ca0134a34b559c4e30c46d9397bce514b5894820c6fc0a33e4af10076953a27bfe5c36e3ab06558a55264c34a1ae3acfc26c818786979
|
|
7
|
+
data.tar.gz: be1328cdf8c4592cf0c3dc6573c1a248b761efc30f01e4eb997744234295c397c35b3b2755ab07593f6d5f1e776287daedf8f98493f462492e1f2284bcfda346
|
data/.github/CODEOWNERS
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
* @
|
|
1
|
+
* @Adyen/api-libraries-reviewers
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "develop", "main" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "develop" ]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: "40 12 * * 0"
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
analyze:
|
|
13
|
+
name: Analyze
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
actions: read
|
|
17
|
+
contents: read
|
|
18
|
+
security-events: write
|
|
19
|
+
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
language: [ javascript ]
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- name: Checkout
|
|
27
|
+
uses: actions/checkout@v3
|
|
28
|
+
|
|
29
|
+
- name: Initialize CodeQL
|
|
30
|
+
uses: github/codeql-action/init@v2
|
|
31
|
+
with:
|
|
32
|
+
languages: ${{ matrix.language }}
|
|
33
|
+
queries: +security-and-quality
|
|
34
|
+
|
|
35
|
+
- name: Autobuild
|
|
36
|
+
uses: github/codeql-action/autobuild@v2
|
|
37
|
+
|
|
38
|
+
- name: Perform CodeQL Analysis
|
|
39
|
+
uses: github/codeql-action/analyze@v2
|
|
40
|
+
with:
|
|
41
|
+
category: "/language:${{ matrix.language }}"
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
CHANGED
data/Makefile
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
generator:=ruby
|
|
2
|
+
openapi-generator-version:=6.4.0
|
|
3
|
+
openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar
|
|
4
|
+
openapi-generator-jar:=build/openapi-generator-cli.jar
|
|
5
|
+
openapi-generator-cli:=java -jar build/openapi-generator-cli.jar
|
|
6
|
+
output:=build/out
|
|
7
|
+
|
|
8
|
+
services:=balancePlatform checkout legalEntityManagement management payout platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration transfers
|
|
9
|
+
singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue posTerminalManagement payment
|
|
10
|
+
|
|
11
|
+
binLookup: spec=BinLookupService-v54
|
|
12
|
+
checkout: spec=CheckoutService-v70
|
|
13
|
+
dataProtection: spec=DataProtectionService-v1
|
|
14
|
+
storedValue: spec=StoredValueService-v46
|
|
15
|
+
posTerminalManagement: spec=TfmAPIService-v1
|
|
16
|
+
payment: spec=PaymentService-v68
|
|
17
|
+
recurring: spec=RecurringService-v68
|
|
18
|
+
payout: spec=PayoutService-v68
|
|
19
|
+
management: spec=ManagementService-v1
|
|
20
|
+
legalEntityManagement: spec=LegalEntityService-v3
|
|
21
|
+
balancePlatform: spec=BalancePlatformService-v2
|
|
22
|
+
platformsAccount: spec=AccountService-v6
|
|
23
|
+
platformsFund: spec=FundService-v6
|
|
24
|
+
platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
|
|
25
|
+
platformsHostedOnboardingPage: spec=HopService-v6
|
|
26
|
+
transfers: spec=TransferService-v3
|
|
27
|
+
balanceControlService: spec=BalanceControlService-v1
|
|
28
|
+
|
|
29
|
+
allServices: $(services) $(singleFileServices)
|
|
30
|
+
|
|
31
|
+
$(services): build/spec $(openapi-generator-jar)
|
|
32
|
+
wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
|
|
33
|
+
rm -rf $(output)
|
|
34
|
+
$(openapi-generator-cli) generate \
|
|
35
|
+
-i build/spec/json/$(spec).json \
|
|
36
|
+
-g $(generator) \
|
|
37
|
+
-c ./templates/config.yaml \
|
|
38
|
+
-o $(output) \
|
|
39
|
+
--global-property apis,apiTests=false,apiDocs=false,supportingFiles=api-single.rb\
|
|
40
|
+
--additional-properties serviceName=$@\
|
|
41
|
+
--skip-validate-spec
|
|
42
|
+
rm -f $(output)/lib/openapi_client/api/*-small.rb
|
|
43
|
+
mkdir -p lib/adyen/services/$@
|
|
44
|
+
mv $(output)/lib/openapi_client/api/*.rb lib/adyen/services/$@
|
|
45
|
+
mv $(output)/api/api-single.rb lib/adyen/services/$@.rb
|
|
46
|
+
rm -rf $(output)
|
|
47
|
+
|
|
48
|
+
$(singleFileServices): build/spec
|
|
49
|
+
wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
|
|
50
|
+
cat <<< "$$(jq 'del(.paths[][].tags)' build/spec/json/$(spec).json)" > build/spec/json/$(spec).json
|
|
51
|
+
rm -rf $(output)
|
|
52
|
+
$(openapi-generator-cli) generate \
|
|
53
|
+
-i build/spec/json/$(spec).json \
|
|
54
|
+
-g $(generator) \
|
|
55
|
+
-c ./templates/config.yaml \
|
|
56
|
+
-o $(output) \
|
|
57
|
+
--global-property apis,apiTests=false,apiDocs=false\
|
|
58
|
+
--additional-properties serviceName=$@\
|
|
59
|
+
--skip-validate-spec
|
|
60
|
+
mv $(output)/lib/openapi_client/api/default_api-small.rb lib/adyen/services/$@.rb
|
|
61
|
+
rm -rf $(output)
|
|
62
|
+
|
|
63
|
+
templates: $(openapi-generator-jar)
|
|
64
|
+
$(openapi-generator-cli) author template -g $(generator) -o build/templates
|
|
65
|
+
|
|
66
|
+
# Download the generator
|
|
67
|
+
$(openapi-generator-jar):
|
|
68
|
+
wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar)
|
|
69
|
+
|
|
70
|
+
build/spec:
|
|
71
|
+
git clone https://github.com/Adyen/adyen-openapi.git build/spec
|
|
72
|
+
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
|
data/README.md
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
+

|
|
1
2
|
# Adyen API Library for Ruby
|
|
2
3
|
|
|
3
|
-
|
|
4
4
|
This is the officially supported Ruby library for using Adyen's APIs.
|
|
5
5
|
|
|
6
|
-
##
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
## Supported APIs
|
|
7
|
+
|
|
8
|
+
This library supports the following:
|
|
9
|
+
|
|
10
|
+
| API name | API version | Description | API object |
|
|
11
|
+
|----------|:-----------:|-------------|------------|
|
|
12
|
+
| [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview) | v54 | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | [BinLookup](lib/adyen/services/binLookup.rb) |
|
|
13
|
+
| [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview) | v70 | Our latest integration for accepting online payments. | [CheckoutAPI](lib/adyen/services/checkout.rb) |
|
|
14
|
+
| [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview) | v2 | The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | [BalancePlatform](lib/adyen/services/balancePlatform.rb) |
|
|
15
|
+
| [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | v1 | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | [DataProtection](lib/adyen/services/dataProtection.rb) |
|
|
16
|
+
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v3/overview) | v3 | Manage legal entities that contain information required for verification. | [LegalEntityManagement](lib/adyen/services/legalEntityManagement.rb) |
|
|
17
|
+
| [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview) | v1 | Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | [Management](lib/adyen/services/management.rb) |
|
|
18
|
+
| [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview) | v68 | Our classic integration for online payments. | [Classic Integration API](lib/adyen/services/payment.rb) |
|
|
19
|
+
| [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview) | v68 | Endpoints for sending funds to your customers. | [Payout](lib/adyen/services/payout.rb) |
|
|
20
|
+
| [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview) | v1 | Endpoints for managing your point-of-sale payment terminals. | [TerminalManagement](lib/adyen/services/posTerminalManagement.rb) |
|
|
21
|
+
| [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
|
|
22
|
+
| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | v46 | Manage both online and point-of-sale gift cards and other stored-value cards. | [StoredValue](lib/adyen/services/storedValue.rb) |
|
|
23
|
+
| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | v3 | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | [Transfers](lib/adyen/services/transfers.rb) |
|
|
22
24
|
|
|
23
25
|
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
|
24
26
|
|
|
@@ -64,7 +66,7 @@ adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
|
|
|
64
66
|
|
|
65
67
|
- Make a Payment
|
|
66
68
|
~~~~ruby
|
|
67
|
-
response = adyen.checkout.payments({
|
|
69
|
+
response = adyen.checkout.payments_api.payments({
|
|
68
70
|
:amount => {
|
|
69
71
|
:currency => "EUR",
|
|
70
72
|
:value => 1000
|
data/lib/adyen/client.rb
CHANGED
|
@@ -35,30 +35,43 @@ module Adyen
|
|
|
35
35
|
|
|
36
36
|
# base URL for API given service and @env
|
|
37
37
|
def service_url_base(service)
|
|
38
|
-
raise ArgumentError, "Please set Client.live_url_prefix to the portion of your merchant-specific URL prior to '-[service]-live.adyenpayments.com'" if @live_url_prefix.nil? and @env == :live
|
|
39
38
|
if @env == :mock
|
|
40
39
|
@mock_service_url_base
|
|
41
40
|
else
|
|
42
41
|
case service
|
|
43
42
|
when "Checkout"
|
|
44
|
-
url = "https://checkout-#{@env}.adyen.com
|
|
43
|
+
url = "https://checkout-#{@env}.adyen.com"
|
|
45
44
|
supports_live_url_prefix = true
|
|
46
45
|
when "Account", "Fund", "Notification", "Hop"
|
|
47
|
-
url = "https://cal-#{@env}.adyen.com/cal/services"
|
|
46
|
+
url = "https://cal-#{@env}.adyen.com/cal/services/#{service}"
|
|
48
47
|
supports_live_url_prefix = false
|
|
49
|
-
when "Recurring", "Payment", "Payout", "BinLookup"
|
|
50
|
-
url = "https://pal-#{@env}.adyen.com/pal/servlet"
|
|
48
|
+
when "Recurring", "Payment", "Payout", "BinLookup", "StoredValue", "BalanceControlService"
|
|
49
|
+
url = "https://pal-#{@env}.adyen.com/pal/servlet/#{service}"
|
|
51
50
|
supports_live_url_prefix = true
|
|
52
|
-
when "
|
|
51
|
+
when "PosTerminalManagement"
|
|
53
52
|
url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
|
|
54
53
|
supports_live_url_prefix = false
|
|
55
54
|
when "DataProtectionService", "DisputeService"
|
|
56
|
-
url = "https://ca-#{@env}.adyen.com/ca/services"
|
|
55
|
+
url = "https://ca-#{@env}.adyen.com/ca/services/#{service}"
|
|
56
|
+
supports_live_url_prefix = false
|
|
57
|
+
when "LegalEntityManagement"
|
|
58
|
+
url = "https://kyc-#{@env}.adyen.com/lem"
|
|
59
|
+
supports_live_url_prefix = false
|
|
60
|
+
when "BalancePlatform"
|
|
61
|
+
url = "https://balanceplatform-api-#{@env}.adyen.com/bcl"
|
|
62
|
+
supports_live_url_prefix = false
|
|
63
|
+
when "Transfers"
|
|
64
|
+
url = "https://balanceplatform-api-#{@env}.adyen.com/btl"
|
|
65
|
+
supports_live_url_prefix = false
|
|
66
|
+
when "Management"
|
|
67
|
+
url = "https://management-#{@env}.adyen.com"
|
|
57
68
|
supports_live_url_prefix = false
|
|
58
69
|
else
|
|
59
70
|
raise ArgumentError, "Invalid service specified"
|
|
60
71
|
end
|
|
61
|
-
|
|
72
|
+
|
|
73
|
+
raise ArgumentError, "Please set Client.live_url_prefix to the portion of your merchant-specific URL prior to '-[service]-live.adyenpayments.com'" \
|
|
74
|
+
if @live_url_prefix.nil? and @env == :live and supports_live_url_prefix
|
|
62
75
|
if @env == :live && supports_live_url_prefix
|
|
63
76
|
url.insert(8, "#{@live_url_prefix}-")
|
|
64
77
|
url["adyen.com"] = "adyenpayments.com"
|
|
@@ -70,11 +83,7 @@ module Adyen
|
|
|
70
83
|
|
|
71
84
|
# construct full URL from service and endpoint
|
|
72
85
|
def service_url(service, action, version)
|
|
73
|
-
|
|
74
|
-
"#{service_url_base(service)}/v#{version}/#{action}"
|
|
75
|
-
else
|
|
76
|
-
"#{service_url_base(service)}/#{service}/v#{version}/#{action}"
|
|
77
|
-
end
|
|
86
|
+
"#{service_url_base(service)}/v#{version}/#{action}"
|
|
78
87
|
end
|
|
79
88
|
|
|
80
89
|
# send request to adyen API
|
|
@@ -121,6 +130,10 @@ module Adyen
|
|
|
121
130
|
headers.map do |key, value|
|
|
122
131
|
faraday.headers[key] = value
|
|
123
132
|
end
|
|
133
|
+
|
|
134
|
+
# add library headers
|
|
135
|
+
faraday.headers["adyen-library-name"] = Adyen::NAME
|
|
136
|
+
faraday.headers["adyen-library-version"] = Adyen::VERSION
|
|
124
137
|
end
|
|
125
138
|
# if json string convert to hash
|
|
126
139
|
# needed to add applicationInfo
|
|
@@ -128,10 +141,6 @@ module Adyen
|
|
|
128
141
|
request_data = JSON.parse(request_data)
|
|
129
142
|
end
|
|
130
143
|
|
|
131
|
-
# add application only on checkout service
|
|
132
|
-
if with_application_info
|
|
133
|
-
add_application_info(request_data)
|
|
134
|
-
end
|
|
135
144
|
|
|
136
145
|
# convert to json
|
|
137
146
|
request_data = request_data.to_json
|
|
@@ -144,6 +153,13 @@ module Adyen
|
|
|
144
153
|
raise connection_error, "Connection to #{url} failed"
|
|
145
154
|
end
|
|
146
155
|
end
|
|
156
|
+
if action.fetch(:method) == "delete"
|
|
157
|
+
begin
|
|
158
|
+
response = conn.delete
|
|
159
|
+
rescue Faraday::ConnectionFailed => connection_error
|
|
160
|
+
raise connection_error, "Connection to #{url} failed"
|
|
161
|
+
end
|
|
162
|
+
end
|
|
147
163
|
if action.fetch(:method) == "patch"
|
|
148
164
|
begin
|
|
149
165
|
response = conn.patch do |req|
|
|
@@ -153,7 +169,7 @@ module Adyen
|
|
|
153
169
|
raise connection_error, "Connection to #{url} failed"
|
|
154
170
|
end
|
|
155
171
|
end
|
|
156
|
-
|
|
172
|
+
if action.fetch(:method) == 'post'
|
|
157
173
|
# post request to Adyen
|
|
158
174
|
begin
|
|
159
175
|
response = conn.post do |req|
|
|
@@ -162,46 +178,46 @@ module Adyen
|
|
|
162
178
|
rescue Faraday::ConnectionFailed => connection_error
|
|
163
179
|
raise connection_error, "Connection to #{url} failed"
|
|
164
180
|
end
|
|
181
|
+
end
|
|
182
|
+
else
|
|
183
|
+
begin
|
|
184
|
+
response = conn.post do |req|
|
|
185
|
+
req.body = request_data
|
|
186
|
+
end # handle client errors
|
|
187
|
+
rescue Faraday::ConnectionFailed => connection_error
|
|
188
|
+
raise connection_error, "Connection to #{url} failed"
|
|
189
|
+
end
|
|
165
190
|
end
|
|
166
|
-
|
|
167
191
|
# check for API errors
|
|
168
192
|
case response.status
|
|
169
193
|
when 401
|
|
170
194
|
raise Adyen::AuthenticationError.new("Invalid API authentication; https://docs.adyen.com/user-management/how-to-get-the-api-key", request_data)
|
|
171
195
|
when 403
|
|
172
|
-
raise Adyen::PermissionError.new("Missing user permissions; https://docs.adyen.com/user-management/user-roles", request_data)
|
|
196
|
+
raise Adyen::PermissionError.new("Missing user permissions; https://docs.adyen.com/user-management/user-roles", request_data, response.body)
|
|
173
197
|
end
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
198
|
+
|
|
199
|
+
# delete has no response.body (unless it throws an error)
|
|
200
|
+
if response.body == nil
|
|
201
|
+
formatted_response = AdyenResult.new("{}", response.headers, response.status)
|
|
202
|
+
else
|
|
203
|
+
formatted_response = AdyenResult.new(response.body, response.headers, response.status)
|
|
204
|
+
end
|
|
205
|
+
|
|
177
206
|
formatted_response
|
|
178
207
|
end
|
|
179
208
|
|
|
180
|
-
# add application_info for analytics
|
|
181
|
-
def add_application_info(request_data)
|
|
182
|
-
adyenLibrary = {
|
|
183
|
-
:name => Adyen::NAME,
|
|
184
|
-
:version => Adyen::VERSION.to_s,
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if request_data[:applicationInfo].nil?
|
|
188
|
-
request_data[:applicationInfo] = {}
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
request_data[:applicationInfo][:adyenLibrary] = adyenLibrary
|
|
192
|
-
end
|
|
193
209
|
|
|
194
210
|
# services
|
|
195
211
|
def checkout
|
|
196
212
|
@checkout ||= Adyen::Checkout.new(self)
|
|
197
213
|
end
|
|
198
214
|
|
|
199
|
-
def
|
|
200
|
-
@
|
|
215
|
+
def payment
|
|
216
|
+
@payment ||= Adyen::Payment.new(self)
|
|
201
217
|
end
|
|
202
218
|
|
|
203
|
-
def
|
|
204
|
-
@
|
|
219
|
+
def payout
|
|
220
|
+
@payout ||= Adyen::Payout.new(self)
|
|
205
221
|
end
|
|
206
222
|
|
|
207
223
|
def recurring
|
|
@@ -212,8 +228,8 @@ module Adyen
|
|
|
212
228
|
@marketpay ||= Adyen::Marketpay::Marketpay.new(self)
|
|
213
229
|
end
|
|
214
230
|
|
|
215
|
-
def
|
|
216
|
-
@
|
|
231
|
+
def pos_terminal_management
|
|
232
|
+
@pos_terminal_management ||= Adyen::PosTerminalManagement.new(self)
|
|
217
233
|
end
|
|
218
234
|
|
|
219
235
|
def data_protection
|
|
@@ -227,5 +243,29 @@ module Adyen
|
|
|
227
243
|
def bin_lookup
|
|
228
244
|
@bin_lookup ||= Adyen::BinLookup.new(self)
|
|
229
245
|
end
|
|
246
|
+
|
|
247
|
+
def legal_entity_management
|
|
248
|
+
@legal_entity_management ||= Adyen::LegalEntityManagement.new(self)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def balance_platform
|
|
252
|
+
@balance_platform ||= Adyen::BalancePlatform.new(self)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def transfers
|
|
256
|
+
@transfers ||= Adyen::Transfers.new(self)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def management
|
|
260
|
+
@management ||= Adyen::Management.new(self)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def stored_value
|
|
264
|
+
@stored_value ||=Adyen::StoredValue.new(self)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def balance_control_service
|
|
268
|
+
@balance_control_service ||=Adyen::BalanceControlService.new(self)
|
|
269
|
+
end
|
|
230
270
|
end
|
|
231
271
|
end
|
data/lib/adyen/errors.rb
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require_relative './service'
|
|
2
|
+
module Adyen
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BalanceControlService < Service
|
|
6
|
+
attr_accessor :service, :version
|
|
7
|
+
DEFAULT_VERSION = 1
|
|
8
|
+
|
|
9
|
+
def initialize(client, version = DEFAULT_VERSION)
|
|
10
|
+
@service = "BalanceControlService"
|
|
11
|
+
@client = client
|
|
12
|
+
@version = version
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def balance_transfer(request, headers: {} )
|
|
16
|
+
"""
|
|
17
|
+
Start a balance transfer
|
|
18
|
+
"""
|
|
19
|
+
endpoint = "/balanceTransfer".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
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require_relative '../service'
|
|
2
|
+
module Adyen
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AccountHoldersApi < Service
|
|
6
|
+
attr_accessor :service, :version
|
|
7
|
+
|
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
|
9
|
+
@service = "BalancePlatform"
|
|
10
|
+
@client = client
|
|
11
|
+
@version = version
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_account_holder(id, headers: {} )
|
|
15
|
+
"""
|
|
16
|
+
Get an account holder
|
|
17
|
+
"""
|
|
18
|
+
endpoint = "/accountHolders/{id}".gsub(/{.+?}/, '%s')
|
|
19
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
20
|
+
endpoint = endpoint % [id]
|
|
21
|
+
|
|
22
|
+
action = { method: "get", url: endpoint}
|
|
23
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_all_balance_accounts_of_account_holder(id, headers: {} , queryParams: {})
|
|
27
|
+
"""
|
|
28
|
+
Get all balance accounts of an account holder
|
|
29
|
+
"""
|
|
30
|
+
endpoint = "/accountHolders/{id}/balanceAccounts".gsub(/{.+?}/, '%s')
|
|
31
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
32
|
+
endpoint = endpoint % [id]
|
|
33
|
+
endpoint = endpoint + create_query_string(queryParams)
|
|
34
|
+
action = { method: "get", url: endpoint}
|
|
35
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def update_account_holder(request, id, headers: {} )
|
|
39
|
+
"""
|
|
40
|
+
Update an account holder
|
|
41
|
+
"""
|
|
42
|
+
endpoint = "/accountHolders/{id}".gsub(/{.+?}/, '%s')
|
|
43
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
44
|
+
endpoint = endpoint % [id]
|
|
45
|
+
|
|
46
|
+
action = { method: "patch", url: endpoint}
|
|
47
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def create_account_holder(request, headers: {} )
|
|
51
|
+
"""
|
|
52
|
+
Create an account holder
|
|
53
|
+
"""
|
|
54
|
+
endpoint = "/accountHolders".gsub(/{.+?}/, '%s')
|
|
55
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
56
|
+
endpoint = endpoint % []
|
|
57
|
+
|
|
58
|
+
action = { method: "post", url: endpoint}
|
|
59
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
require_relative '../service'
|
|
2
|
+
module Adyen
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BalanceAccountsApi < Service
|
|
6
|
+
attr_accessor :service, :version
|
|
7
|
+
|
|
8
|
+
def initialize(client, version = DEFAULT_VERSION)
|
|
9
|
+
@service = "BalancePlatform"
|
|
10
|
+
@client = client
|
|
11
|
+
@version = version
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def delete_sweep(balanceAccountId, sweepId, headers: {} )
|
|
15
|
+
"""
|
|
16
|
+
Delete a sweep
|
|
17
|
+
"""
|
|
18
|
+
endpoint = "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}".gsub(/{.+?}/, '%s')
|
|
19
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
20
|
+
endpoint = endpoint % [balanceAccountId,sweepId]
|
|
21
|
+
|
|
22
|
+
action = { method: "delete", url: endpoint}
|
|
23
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_all_sweeps_for_balance_account(balanceAccountId, headers: {} , queryParams: {})
|
|
27
|
+
"""
|
|
28
|
+
Get all sweeps for a balance account
|
|
29
|
+
"""
|
|
30
|
+
endpoint = "/balanceAccounts/{balanceAccountId}/sweeps".gsub(/{.+?}/, '%s')
|
|
31
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
32
|
+
endpoint = endpoint % [balanceAccountId]
|
|
33
|
+
endpoint = endpoint + create_query_string(queryParams)
|
|
34
|
+
action = { method: "get", url: endpoint}
|
|
35
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_sweep(balanceAccountId, sweepId, headers: {} )
|
|
39
|
+
"""
|
|
40
|
+
Get a sweep
|
|
41
|
+
"""
|
|
42
|
+
endpoint = "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}".gsub(/{.+?}/, '%s')
|
|
43
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
44
|
+
endpoint = endpoint % [balanceAccountId,sweepId]
|
|
45
|
+
|
|
46
|
+
action = { method: "get", url: endpoint}
|
|
47
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def get_balance_account(id, headers: {} )
|
|
51
|
+
"""
|
|
52
|
+
Get a balance account
|
|
53
|
+
"""
|
|
54
|
+
endpoint = "/balanceAccounts/{id}".gsub(/{.+?}/, '%s')
|
|
55
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
56
|
+
endpoint = endpoint % [id]
|
|
57
|
+
|
|
58
|
+
action = { method: "get", url: endpoint}
|
|
59
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def get_all_payment_instruments_for_balance_account(id, headers: {} , queryParams: {})
|
|
63
|
+
"""
|
|
64
|
+
Get all payment instruments for a balance account
|
|
65
|
+
"""
|
|
66
|
+
endpoint = "/balanceAccounts/{id}/paymentInstruments".gsub(/{.+?}/, '%s')
|
|
67
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
68
|
+
endpoint = endpoint % [id]
|
|
69
|
+
endpoint = endpoint + create_query_string(queryParams)
|
|
70
|
+
action = { method: "get", url: endpoint}
|
|
71
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def update_sweep(request, balanceAccountId, sweepId, headers: {} )
|
|
75
|
+
"""
|
|
76
|
+
Update a sweep
|
|
77
|
+
"""
|
|
78
|
+
endpoint = "/balanceAccounts/{balanceAccountId}/sweeps/{sweepId}".gsub(/{.+?}/, '%s')
|
|
79
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
80
|
+
endpoint = endpoint % [balanceAccountId,sweepId]
|
|
81
|
+
|
|
82
|
+
action = { method: "patch", url: endpoint}
|
|
83
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def update_balance_account(request, id, headers: {} )
|
|
87
|
+
"""
|
|
88
|
+
Update a balance account
|
|
89
|
+
"""
|
|
90
|
+
endpoint = "/balanceAccounts/{id}".gsub(/{.+?}/, '%s')
|
|
91
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
92
|
+
endpoint = endpoint % [id]
|
|
93
|
+
|
|
94
|
+
action = { method: "patch", url: endpoint}
|
|
95
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def create_balance_account(request, headers: {} )
|
|
99
|
+
"""
|
|
100
|
+
Create a balance account
|
|
101
|
+
"""
|
|
102
|
+
endpoint = "/balanceAccounts".gsub(/{.+?}/, '%s')
|
|
103
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
104
|
+
endpoint = endpoint % []
|
|
105
|
+
|
|
106
|
+
action = { method: "post", url: endpoint}
|
|
107
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def create_sweep(request, balanceAccountId, headers: {} )
|
|
111
|
+
"""
|
|
112
|
+
Create a sweep
|
|
113
|
+
"""
|
|
114
|
+
endpoint = "/balanceAccounts/{balanceAccountId}/sweeps".gsub(/{.+?}/, '%s')
|
|
115
|
+
endpoint = endpoint.gsub(/^\//, "")
|
|
116
|
+
endpoint = endpoint % [balanceAccountId]
|
|
117
|
+
|
|
118
|
+
action = { method: "post", url: endpoint}
|
|
119
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
end
|