adyen-ruby-api-library 7.0.1 → 7.0.3
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/release.yml +18 -0
- data/.github/workflows/gh_release.yml +16 -0
- data/.github/workflows/release_request.yml +15 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/services.yml +28 -0
- data/.rubocop.yml +8 -0
- data/Gemfile +7 -7
- data/Makefile +16 -10
- data/README.md +13 -10
- data/Rakefile +3 -3
- data/adyen-ruby-api-library.gemspec +6 -3
- data/bin/console +2 -2
- data/lib/adyen/client.rb +91 -75
- data/lib/adyen/errors.rb +23 -18
- data/lib/adyen/hash_with_accessors.rb +12 -7
- data/lib/adyen/services/balanceControlService.rb +7 -14
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +22 -38
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +48 -79
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +6 -13
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +6 -13
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +12 -22
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +16 -29
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +26 -45
- data/lib/adyen/services/balancePlatform/platform_api.rb +12 -22
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +21 -37
- data/lib/adyen/services/balancePlatform.rb +38 -40
- data/lib/adyen/services/binLookup.rb +12 -22
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +11 -21
- data/lib/adyen/services/checkout/modifications_api.rb +31 -53
- data/lib/adyen/services/checkout/orders_api.rb +16 -29
- data/lib/adyen/services/checkout/payment_links_api.rb +16 -29
- data/lib/adyen/services/checkout/payments_api.rb +40 -53
- data/lib/adyen/services/checkout/recurring_api.rb +13 -23
- data/lib/adyen/services/checkout/utility_api.rb +11 -21
- data/lib/adyen/services/checkout.rb +32 -34
- data/lib/adyen/services/dataProtection.rb +7 -14
- data/lib/adyen/services/dispute.rb +6 -5
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +16 -29
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +26 -45
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +25 -29
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +21 -37
- data/lib/adyen/services/legalEntityManagement.rb +32 -34
- data/lib/adyen/services/management/account_company_level_api.rb +18 -31
- data/lib/adyen/services/management/account_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/account_store_level_api.rb +43 -71
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +21 -37
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +21 -37
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +22 -38
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/api_key_company_level_api.rb +6 -13
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +6 -13
- data/lib/adyen/services/management/client_key_company_level_api.rb +6 -13
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +6 -13
- data/lib/adyen/services/management/my_api_credential_api.rb +26 -45
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +32 -54
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +26 -45
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +92 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +24 -40
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +6 -13
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +55 -89
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +55 -89
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +23 -39
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +23 -39
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +45 -73
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +21 -37
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +7 -14
- data/lib/adyen/services/management/users_company_level_api.rb +22 -38
- data/lib/adyen/services/management/users_merchant_level_api.rb +22 -38
- data/lib/adyen/services/management/webhooks_company_level_api.rb +37 -62
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +37 -62
- data/lib/adyen/services/management.rb +99 -96
- data/lib/adyen/services/marketpay.rb +42 -36
- data/lib/adyen/services/payment.rb +67 -110
- data/lib/adyen/services/payout/initialization_api.rb +16 -29
- data/lib/adyen/services/payout/instant_payouts_api.rb +6 -13
- data/lib/adyen/services/payout/reviewing_api.rb +11 -21
- data/lib/adyen/services/payout.rb +19 -21
- data/lib/adyen/services/posTerminalManagement.rb +27 -46
- data/lib/adyen/services/recurring.rb +32 -54
- data/lib/adyen/services/service.rb +5 -4
- data/lib/adyen/services/storedValue.rb +32 -54
- data/lib/adyen/services/transfers/capital_api.rb +38 -0
- data/lib/adyen/services/transfers/transactions_api.rb +12 -22
- data/lib/adyen/services/transfers/transfers_api.rb +6 -13
- data/lib/adyen/services/transfers.rb +20 -17
- data/lib/adyen/utils/hmac_validator.rb +18 -7
- data/lib/adyen/version.rb +3 -3
- data/lib/adyen-ruby-api-library.rb +21 -21
- data/spec/account_spec.rb +20 -20
- data/spec/balance_control_spec.rb +28 -29
- data/spec/balance_platform_spec.rb +108 -102
- data/spec/bin_lookup_spec.rb +50 -50
- data/spec/checkout_spec.rb +573 -524
- data/spec/client_spec.rb +117 -70
- data/spec/data_protection_spec.rb +4 -4
- data/spec/dispute_spec.rb +7 -7
- data/spec/errors_spec.rb +37 -17
- data/spec/fund_spec.rb +10 -10
- data/spec/hash_with_accessors_spec.rb +18 -8
- data/spec/hop_spec.rb +4 -4
- data/spec/lem_spec.rb +44 -49
- data/spec/management_spec.rb +46 -48
- data/spec/notification_spec.rb +9 -9
- data/spec/payments_spec.rb +29 -30
- data/spec/payouts_spec.rb +29 -32
- data/spec/pos_terminal_management_spec.rb +30 -32
- data/spec/recurring_spec.rb +8 -8
- data/spec/service_spec.rb +4 -0
- data/spec/spec_helper.rb +37 -35
- data/spec/stored_value_spec.rb +28 -27
- data/spec/transfers_spec.rb +48 -47
- data/spec/utils/hmac_validator_spec.rb +15 -14
- data/templates/api-single.mustache +13 -15
- data/templates/api-small.mustache +8 -15
- data/templates/api.mustache +7 -14
- metadata +25 -18
- data/.github/dependabot.yml +0 -8
- /data/spec/mocks/responses/Webhooks/{backslash_notification.json → backslash_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{colon_notification.json → colon_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{forwardslash_notification.json → forwardslash_webhook.json} +0 -0
- /data/spec/mocks/responses/Webhooks/{mixed_notification.json → mixed_webhook.json} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3424394aa97925505130c2e86a526725f575d94bb5276bc2212377433430943
|
4
|
+
data.tar.gz: de79dd2ca8be5d5c239e9b3883b9972712cd03227133ab6b66cf8aa88add1f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81fb04e71363771981693afda6387d2e00cd22207444282be51de1f4913d0a7477429acd8b2502bb2f5e440fdc4ece3fa40b95134e358e66eab319336f85489c
|
7
|
+
data.tar.gz: 8c76a644b6ccd599b892cb7df34b80c0d978ae91ff8f0a0b417ea496d775d69b9e07901edb7a7cb5f066c700ebf42f35161ed686e2128219a29a5e949e15c87c
|
data/.github/CODEOWNERS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* @Adyen/
|
1
|
+
* @Adyen/integration-tools-testing
|
data/.github/release.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
changelog:
|
2
|
+
exclude:
|
3
|
+
authors:
|
4
|
+
- renovate[bot]
|
5
|
+
- dependabot[bot]
|
6
|
+
categories:
|
7
|
+
- title: Breaking Changes 🛠
|
8
|
+
labels:
|
9
|
+
- Breaking change
|
10
|
+
- title: New Features 💎
|
11
|
+
labels:
|
12
|
+
- Feature
|
13
|
+
- title: Fixes ⛑️
|
14
|
+
labels:
|
15
|
+
- Fix
|
16
|
+
- title: Other Changes 🖇️
|
17
|
+
labels:
|
18
|
+
- "*"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Github Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- main
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
gh_release:
|
11
|
+
permissions:
|
12
|
+
contents: write
|
13
|
+
uses: Adyen/adyen-node-api-library/.github/workflows/lib-gh-release.yml@develop
|
14
|
+
with:
|
15
|
+
project-name: Ruby
|
16
|
+
secrets: inherit
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: Release request
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- develop
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
release:
|
11
|
+
permissions:
|
12
|
+
contents: write
|
13
|
+
pull-requests: write
|
14
|
+
uses: Adyen/adyen-node-api-library/.github/workflows/lib-release.yml@develop
|
15
|
+
secrets: inherit
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,7 +9,7 @@ jobs:
|
|
9
9
|
matrix:
|
10
10
|
os: [ubuntu-latest]
|
11
11
|
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
12
|
-
ruby: [2.
|
12
|
+
ruby: [2.7, '3.0', 3.1, 3.2, head]
|
13
13
|
runs-on: ${{ matrix.os }}
|
14
14
|
steps:
|
15
15
|
- uses: actions/checkout@v3
|
@@ -0,0 +1,28 @@
|
|
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@v3
|
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: develop
|
25
|
+
branch: automation/services
|
26
|
+
title: ${{ steps.vars.outputs.pr_title }}
|
27
|
+
body: ${{ steps.vars.outputs.pr_body }}
|
28
|
+
add-paths: lib/adyen/services
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
ruby
|
5
|
+
ruby '>= 2.7.0'
|
6
6
|
|
7
|
-
gem
|
7
|
+
gem 'faraday'
|
8
8
|
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
9
|
+
gem 'activesupport', group: :development
|
10
|
+
gem 'bundler', group: :development
|
11
|
+
gem 'rspec', group: :development
|
12
|
+
gem 'webmock', group: :development
|
data/Makefile
CHANGED
@@ -5,8 +5,8 @@ openapi-generator-jar:=build/openapi-generator-cli.jar
|
|
5
5
|
openapi-generator-cli:=java -jar build/openapi-generator-cli.jar
|
6
6
|
output:=build/out
|
7
7
|
|
8
|
-
services:=balancePlatform checkout legalEntityManagement management payout
|
9
|
-
singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue posTerminalManagement
|
8
|
+
services:=balancePlatform checkout legalEntityManagement management payout transfers
|
9
|
+
singleFileServices:=balanceControlService binLookup dataProtection recurring storedValue payment posTerminalManagement
|
10
10
|
|
11
11
|
binLookup: spec=BinLookupService-v54
|
12
12
|
checkout: spec=CheckoutService-v70
|
@@ -19,12 +19,8 @@ payout: spec=PayoutService-v68
|
|
19
19
|
management: spec=ManagementService-v1
|
20
20
|
legalEntityManagement: spec=LegalEntityService-v3
|
21
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
22
|
balanceControlService: spec=BalanceControlService-v1
|
23
|
+
transfers: spec=TransferService-v3
|
28
24
|
|
29
25
|
allServices: $(services) $(singleFileServices)
|
30
26
|
|
@@ -47,7 +43,8 @@ $(services): build/spec $(openapi-generator-jar)
|
|
47
43
|
|
48
44
|
$(singleFileServices): build/spec
|
49
45
|
wget $(openapi-generator-url) -O build/openapi-generator-cli.jar
|
50
|
-
|
46
|
+
jq -e 'del(.paths[][].tags)' build/spec/json/$(spec).json > build/spec/json/$(spec).tmp
|
47
|
+
mv build/spec/json/$(spec).tmp build/spec/json/$(spec).json
|
51
48
|
rm -rf $(output)
|
52
49
|
$(openapi-generator-cli) generate \
|
53
50
|
-i build/spec/json/$(spec).json \
|
@@ -57,7 +54,7 @@ $(singleFileServices): build/spec
|
|
57
54
|
--global-property apis,apiTests=false,apiDocs=false\
|
58
55
|
--additional-properties serviceName=$@\
|
59
56
|
--skip-validate-spec
|
60
|
-
mv $(output)/lib/openapi_client/api
|
57
|
+
mv $(output)/lib/openapi_client/api/*-small.rb lib/adyen/services/$@.rb
|
61
58
|
rm -rf $(output)
|
62
59
|
|
63
60
|
templates: $(openapi-generator-jar)
|
@@ -69,4 +66,13 @@ $(openapi-generator-jar):
|
|
69
66
|
|
70
67
|
build/spec:
|
71
68
|
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
|
69
|
+
perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json
|
70
|
+
|
71
|
+
# Releases
|
72
|
+
|
73
|
+
version:
|
74
|
+
perl -lne 'print "currentVersion=$$1" if /(\d+\.\d+\.\d+)/' < lib/adyen/version.rb >> "$$GITHUB_OUTPUT"
|
75
|
+
|
76
|
+
version_files:=lib/adyen/version.rb
|
77
|
+
bump:
|
78
|
+
perl -i -pe 's/$$ENV{"CURRENT_VERSION"}/$$ENV{"NEXT_VERSION"}/' $(version_files)
|
data/README.md
CHANGED
@@ -9,16 +9,16 @@ This library supports the following:
|
|
9
9
|
|
10
10
|
| API name | API version | Description | API object |
|
11
11
|
|----------|:-----------:|-------------|------------|
|
12
|
-
| [BIN lookup API](https://docs.adyen.com/api-explorer
|
13
|
-
| [Checkout API](https://docs.adyen.com/api-explorer
|
14
|
-
| [Configuration API](https://docs.adyen.com/api-explorer
|
12
|
+
| [BIN lookup API](https://docs.adyen.com/api-explorer/BinLookup/54/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/Checkout/70/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/2/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
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
|
17
|
-
| [Management API](https://docs.adyen.com/api-explorer
|
18
|
-
| [Payments API](https://docs.adyen.com/api-explorer
|
19
|
-
| [Payouts API](https://docs.adyen.com/api-explorer
|
20
|
-
| [POS Terminal Management API](https://docs.adyen.com/api-explorer
|
21
|
-
| [Recurring API](https://docs.adyen.com/api-explorer
|
16
|
+
| [Legal Entity Management API](https://docs.adyen.com/api-explorer/legalentity/3/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/Management/1/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/68/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/68/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/1/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/68/overview) | v68 | Endpoints for managing saved payment details. | [Recurring](lib/adyen/services/recurring.rb) |
|
22
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
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) |
|
24
24
|
|
@@ -27,7 +27,7 @@ For more information, refer to our [documentation](https://docs.adyen.com/) or t
|
|
27
27
|
## Prerequisites
|
28
28
|
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
|
29
29
|
- [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles).
|
30
|
-
- Ruby >= 2.
|
30
|
+
- Ruby >= 2.7
|
31
31
|
|
32
32
|
## Installation
|
33
33
|
|
@@ -99,6 +99,9 @@ To run the tests use :
|
|
99
99
|
bundle install --with development
|
100
100
|
~~~~
|
101
101
|
|
102
|
+
## Feedback
|
103
|
+
We value your input! Help us enhance our API Libraries and improve the integration experience by providing your feedback. Please take a moment to fill out [our feedback form](https://forms.gle/A4EERrR6CWgKWe5r9) to share your thoughts, suggestions or ideas.
|
104
|
+
|
102
105
|
## Contributing
|
103
106
|
|
104
107
|
We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements.
|
data/Rakefile
CHANGED
@@ -3,12 +3,15 @@ require_relative 'lib/adyen/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'adyen-ruby-api-library'
|
5
5
|
spec.version = Adyen::VERSION
|
6
|
-
spec.required_ruby_version = '>= 2.
|
6
|
+
spec.required_ruby_version = '>= 2.7.0'
|
7
7
|
spec.authors = ['Adyen']
|
8
8
|
spec.email = ['support@adyen.com']
|
9
9
|
|
10
10
|
spec.summary = 'Official Adyen Ruby API Library'
|
11
|
-
spec.description = 'Official Adyen API Library for Ruby. Simplifies integrating with the Adyen API
|
11
|
+
spec.description = 'Official Adyen API Library for Ruby. Simplifies integrating with the Adyen API,\
|
12
|
+
including Checkout, Marketpay, payments, recurring, and payouts. For support please reach out to \
|
13
|
+
support@adyen.com. If you would like to contribute please submit \
|
14
|
+
a comment or pull request at https://github.com/Adyen/adyen-ruby-api-library.'
|
12
15
|
spec.homepage = 'https://www.adyen.com'
|
13
16
|
spec.license = 'MIT'
|
14
17
|
|
@@ -22,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
22
25
|
|
23
26
|
spec.add_dependency 'faraday'
|
24
27
|
|
28
|
+
spec.add_development_dependency 'activesupport'
|
25
29
|
spec.add_development_dependency 'bundler'
|
26
30
|
spec.add_development_dependency 'webmock'
|
27
|
-
spec.add_development_dependency 'activesupport'
|
28
31
|
end
|
data/bin/console
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative '../lib/adyen-ruby-api-library'
|
4
4
|
|
5
5
|
# You can add fixtures and/or initialization code here to make experimenting
|
6
6
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -9,5 +9,5 @@ require_relative "../lib/adyen-ruby-api-library.rb"
|
|
9
9
|
# require "pry"
|
10
10
|
# Pry.start
|
11
11
|
|
12
|
-
require
|
12
|
+
require 'irb'
|
13
13
|
IRB.start(__FILE__)
|
data/lib/adyen/client.rb
CHANGED
@@ -1,14 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# rubocop:disable Metrics/ParameterLists
|
2
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
3
|
+
# rubocop:disable Metrics/MethodLength
|
4
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
5
|
+
# rubocop:disable Metrics/AbcSize
|
6
|
+
# rubocop:disable Metrics/ClassLength
|
7
|
+
|
8
|
+
require 'faraday'
|
9
|
+
require 'json'
|
10
|
+
require_relative './errors'
|
11
|
+
require_relative './result'
|
5
12
|
|
6
13
|
module Adyen
|
7
14
|
class Client
|
8
|
-
attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter
|
15
|
+
attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter
|
9
16
|
attr_reader :env, :connection_options
|
10
17
|
|
11
|
-
def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001,
|
18
|
+
def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001,
|
19
|
+
live_url_prefix: nil, mock_service_url_base: nil, connection_options: nil)
|
12
20
|
@ws_user = ws_user
|
13
21
|
@ws_password = ws_password
|
14
22
|
@api_key = api_key
|
@@ -21,15 +29,16 @@ module Adyen
|
|
21
29
|
|
22
30
|
# make sure that env can only be :live, :test, or :mock
|
23
31
|
def env=(value)
|
24
|
-
raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless [
|
32
|
+
raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless %i[
|
33
|
+
live test mock
|
34
|
+
].include? value
|
35
|
+
|
25
36
|
@env = value
|
26
37
|
end
|
27
38
|
|
28
39
|
# remove 'https' from live_url_prefix if necessary
|
29
40
|
def live_url_prefix=(value)
|
30
|
-
|
31
|
-
value["https://"] = ""
|
32
|
-
end
|
41
|
+
value['https://'] = '' unless value['https://'].nil?
|
33
42
|
@live_url_prefix = value
|
34
43
|
end
|
35
44
|
|
@@ -39,45 +48,49 @@ module Adyen
|
|
39
48
|
@mock_service_url_base
|
40
49
|
else
|
41
50
|
case service
|
42
|
-
when
|
51
|
+
when 'Checkout'
|
43
52
|
url = "https://checkout-#{@env}.adyen.com"
|
44
53
|
supports_live_url_prefix = true
|
45
|
-
when
|
54
|
+
when 'Account', 'Fund', 'Notification', 'Hop'
|
46
55
|
url = "https://cal-#{@env}.adyen.com/cal/services/#{service}"
|
47
56
|
supports_live_url_prefix = false
|
48
|
-
when
|
57
|
+
when 'Recurring', 'Payment', 'Payout', 'BinLookup', 'StoredValue', 'BalanceControlService'
|
49
58
|
url = "https://pal-#{@env}.adyen.com/pal/servlet/#{service}"
|
50
59
|
supports_live_url_prefix = true
|
51
|
-
when
|
60
|
+
when 'PosTerminalManagement'
|
52
61
|
url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
|
53
62
|
supports_live_url_prefix = false
|
54
|
-
when
|
63
|
+
when 'DataProtectionService', 'DisputeService'
|
55
64
|
url = "https://ca-#{@env}.adyen.com/ca/services/#{service}"
|
56
65
|
supports_live_url_prefix = false
|
57
|
-
when
|
66
|
+
when 'LegalEntityManagement'
|
58
67
|
url = "https://kyc-#{@env}.adyen.com/lem"
|
59
68
|
supports_live_url_prefix = false
|
60
|
-
when
|
69
|
+
when 'BalancePlatform'
|
61
70
|
url = "https://balanceplatform-api-#{@env}.adyen.com/bcl"
|
62
71
|
supports_live_url_prefix = false
|
63
|
-
when
|
72
|
+
when 'Transfers'
|
64
73
|
url = "https://balanceplatform-api-#{@env}.adyen.com/btl"
|
65
74
|
supports_live_url_prefix = false
|
66
|
-
when
|
75
|
+
when 'Management'
|
67
76
|
url = "https://management-#{@env}.adyen.com"
|
68
77
|
supports_live_url_prefix = false
|
69
78
|
else
|
70
|
-
raise ArgumentError,
|
79
|
+
raise ArgumentError, 'Invalid service specified'
|
80
|
+
end
|
81
|
+
|
82
|
+
if @live_url_prefix.nil? && (@env == :live) && supports_live_url_prefix
|
83
|
+
raise ArgumentError,
|
84
|
+
"Please set Client.live_url_prefix to the portion \
|
85
|
+
of your merchant-specific URL prior to '-[service]-live.adyenpayments.com'"
|
71
86
|
end
|
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
|
87
|
+
|
75
88
|
if @env == :live && supports_live_url_prefix
|
76
89
|
url.insert(8, "#{@live_url_prefix}-")
|
77
|
-
url[
|
90
|
+
url['adyen.com'] = 'adyenpayments.com'
|
78
91
|
end
|
79
92
|
|
80
|
-
|
93
|
+
url
|
81
94
|
end
|
82
95
|
end
|
83
96
|
|
@@ -91,33 +104,38 @@ module Adyen
|
|
91
104
|
end
|
92
105
|
|
93
106
|
# send request to adyen API
|
94
|
-
def call_adyen_api(service, action, request_data, headers, version,
|
107
|
+
def call_adyen_api(service, action, request_data, headers, version, _with_application_info: false)
|
95
108
|
# get URL for requested endpoint
|
96
109
|
url = service_url(service, action.is_a?(String) ? action : action.fetch(:url), version)
|
97
110
|
|
98
111
|
# make sure right authentication has been provided
|
99
112
|
# will use api_key if present, otherwise ws_user and ws_password
|
100
113
|
if @api_key.nil?
|
101
|
-
if service ==
|
102
|
-
raise Adyen::AuthenticationError.new(
|
114
|
+
if service == 'PaymentSetupAndVerification'
|
115
|
+
raise Adyen::AuthenticationError.new('Checkout service requires API-key', request_data),
|
116
|
+
'Checkout service requires API-key'
|
103
117
|
elsif @ws_password.nil? || @ws_user.nil?
|
104
|
-
raise Adyen::AuthenticationError.new(
|
118
|
+
raise Adyen::AuthenticationError.new(
|
119
|
+
'No authentication found - please set api_key or ws_user and ws_password',
|
120
|
+
request_data
|
121
|
+
),
|
122
|
+
'No authentication found - please set api_key or ws_user and ws_password'
|
105
123
|
else
|
106
|
-
auth_type =
|
124
|
+
auth_type = 'basic'
|
107
125
|
end
|
108
126
|
else
|
109
|
-
auth_type =
|
127
|
+
auth_type = 'api-key'
|
110
128
|
end
|
111
129
|
|
112
130
|
# initialize Faraday connection object
|
113
131
|
conn = Faraday.new(url, @connection_options) do |faraday|
|
114
132
|
faraday.adapter @adapter
|
115
|
-
faraday.headers[
|
116
|
-
faraday.headers[
|
133
|
+
faraday.headers['Content-Type'] = 'application/json'
|
134
|
+
faraday.headers['User-Agent'] = "#{Adyen::NAME}/#{Adyen::VERSION}"
|
117
135
|
|
118
136
|
# set auth type based on service
|
119
137
|
case auth_type
|
120
|
-
when
|
138
|
+
when 'basic'
|
121
139
|
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
122
140
|
# for faraday 2.0 and higher
|
123
141
|
faraday.request :authorization, :basic, @ws_user, @ws_password
|
@@ -125,8 +143,8 @@ module Adyen
|
|
125
143
|
# for faraday 1.x
|
126
144
|
faraday.basic_auth(@ws_user, @ws_password)
|
127
145
|
end
|
128
|
-
when
|
129
|
-
faraday.headers[
|
146
|
+
when 'api-key'
|
147
|
+
faraday.headers['x-api-key'] = @api_key
|
130
148
|
end
|
131
149
|
|
132
150
|
# add optional headers if specified in request
|
@@ -136,81 +154,78 @@ module Adyen
|
|
136
154
|
end
|
137
155
|
|
138
156
|
# add library headers
|
139
|
-
faraday.headers[
|
140
|
-
faraday.headers[
|
157
|
+
faraday.headers['adyen-library-name'] = Adyen::NAME
|
158
|
+
faraday.headers['adyen-library-version'] = Adyen::VERSION
|
141
159
|
end
|
142
160
|
# if json string convert to hash
|
143
161
|
# needed to add applicationInfo
|
144
|
-
if request_data.is_a?(String)
|
145
|
-
request_data = JSON.parse(request_data)
|
146
|
-
end
|
147
|
-
|
162
|
+
request_data = JSON.parse(request_data) if request_data.is_a?(String)
|
148
163
|
|
149
164
|
# convert to json
|
150
165
|
request_data = request_data.to_json
|
151
166
|
|
152
167
|
if action.is_a?(::Hash)
|
153
|
-
if action.fetch(:method) ==
|
168
|
+
if action.fetch(:method) == 'get'
|
154
169
|
begin
|
155
170
|
response = conn.get
|
156
|
-
rescue Faraday::ConnectionFailed =>
|
157
|
-
raise
|
171
|
+
rescue Faraday::ConnectionFailed => e
|
172
|
+
raise e, "Connection to #{url} failed"
|
158
173
|
end
|
159
174
|
end
|
160
|
-
if action.fetch(:method) ==
|
175
|
+
if action.fetch(:method) == 'delete'
|
161
176
|
begin
|
162
177
|
response = conn.delete
|
163
|
-
rescue Faraday::ConnectionFailed =>
|
164
|
-
raise
|
178
|
+
rescue Faraday::ConnectionFailed => e
|
179
|
+
raise e, "Connection to #{url} failed"
|
165
180
|
end
|
166
181
|
end
|
167
|
-
if action.fetch(:method) ==
|
182
|
+
if action.fetch(:method) == 'patch'
|
168
183
|
begin
|
169
184
|
response = conn.patch do |req|
|
170
185
|
req.body = request_data
|
171
186
|
end
|
172
|
-
rescue Faraday::ConnectionFailed =>
|
173
|
-
raise
|
187
|
+
rescue Faraday::ConnectionFailed => e
|
188
|
+
raise e, "Connection to #{url} failed"
|
174
189
|
end
|
175
190
|
end
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
191
|
+
if action.fetch(:method) == 'post'
|
192
|
+
# post request to Adyen
|
193
|
+
begin
|
194
|
+
response = conn.post do |req|
|
195
|
+
req.body = request_data
|
196
|
+
end
|
197
|
+
rescue Faraday::ConnectionFailed => e
|
198
|
+
raise e, "Connection to #{url} failed"
|
199
|
+
end
|
184
200
|
end
|
185
|
-
end
|
186
201
|
else
|
187
202
|
begin
|
188
203
|
response = conn.post do |req|
|
189
204
|
req.body = request_data
|
190
|
-
end
|
191
|
-
rescue Faraday::ConnectionFailed =>
|
192
|
-
raise
|
205
|
+
end
|
206
|
+
rescue Faraday::ConnectionFailed => e
|
207
|
+
raise e, "Connection to #{url} failed"
|
193
208
|
end
|
194
209
|
end
|
195
210
|
# check for API errors
|
196
211
|
case response.status
|
197
212
|
when 401
|
198
|
-
raise Adyen::AuthenticationError.new(
|
213
|
+
raise Adyen::AuthenticationError.new(
|
214
|
+
'Invalid API authentication; https://docs.adyen.com/user-management/how-to-get-the-api-key', request_data
|
215
|
+
)
|
199
216
|
when 403
|
200
|
-
raise Adyen::PermissionError.new(
|
217
|
+
raise Adyen::PermissionError.new('Missing user permissions; https://docs.adyen.com/user-management/user-roles',
|
218
|
+
request_data, response.body)
|
201
219
|
end
|
202
|
-
|
220
|
+
|
203
221
|
# delete has no response.body (unless it throws an error)
|
204
|
-
if response.body
|
205
|
-
|
222
|
+
if response.body.nil? || response.body === ''
|
223
|
+
AdyenResult.new('{}', response.headers, response.status)
|
206
224
|
else
|
207
|
-
|
225
|
+
AdyenResult.new(response.body, response.headers, response.status)
|
208
226
|
end
|
209
|
-
|
210
|
-
formatted_response
|
211
227
|
end
|
212
228
|
|
213
|
-
|
214
229
|
# services
|
215
230
|
def checkout
|
216
231
|
@checkout ||= Adyen::Checkout.new(self)
|
@@ -263,13 +278,14 @@ module Adyen
|
|
263
278
|
def management
|
264
279
|
@management ||= Adyen::Management.new(self)
|
265
280
|
end
|
266
|
-
|
281
|
+
|
267
282
|
def stored_value
|
268
|
-
@stored_value ||=Adyen::StoredValue.new(self)
|
283
|
+
@stored_value ||= Adyen::StoredValue.new(self)
|
269
284
|
end
|
270
285
|
|
271
286
|
def balance_control_service
|
272
|
-
@balance_control_service ||=Adyen::BalanceControlService.new(self)
|
287
|
+
@balance_control_service ||= Adyen::BalanceControlService.new(self)
|
273
288
|
end
|
274
289
|
end
|
275
290
|
end
|
291
|
+
# rubocop:enable all
|