adyen-ruby-api-library 4.0.2 → 5.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/ISSUE_TEMPLATE/bug_report.md +27 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +7 -0
- data/.github/dependabot.yml +8 -0
- data/.gitignore +2 -0
- data/README.md +72 -110
- data/lib/adyen-ruby-api-library.rb +4 -12
- data/lib/adyen/client.rb +57 -24
- data/lib/adyen/services/bin_lookup.rb +18 -0
- data/lib/adyen/services/checkout.rb +88 -8
- data/lib/adyen/services/{checkout_utility.rb → data_protection.rb} +4 -3
- data/lib/adyen/services/dispute.rb +20 -0
- data/lib/adyen/services/marketpay.rb +26 -6
- data/lib/adyen/services/payments.rb +15 -5
- data/lib/adyen/services/payouts.rb +3 -2
- data/lib/adyen/services/postfmapi.rb +19 -0
- data/lib/adyen/services/recurring.rb +3 -2
- data/lib/adyen/services/service.rb +2 -2
- data/lib/adyen/version.rb +1 -1
- data/spec/account_spec.rb +3 -1
- data/spec/bin_lookup_spec.rb +15 -0
- data/spec/checkout_spec.rb +247 -5
- data/spec/data_protection_spec.rb +14 -0
- data/spec/dispute_spec.rb +17 -0
- data/spec/fund_spec.rb +2 -1
- data/spec/hop_spec.rb +14 -0
- data/spec/mocks/requests/Account/check_account_holder.json +5 -0
- data/spec/mocks/requests/Account/delete_payout_methods.json +6 -0
- data/spec/mocks/requests/BinLookup/get_3ds_availability.json +4 -0
- data/spec/mocks/requests/BinLookup/get_cost_estimate.json +8 -0
- data/spec/mocks/requests/Checkout/orders.json +6 -0
- data/spec/mocks/requests/Checkout/orders_cancel.json +7 -0
- data/spec/mocks/requests/Checkout/origin_keys.json +3 -0
- data/spec/mocks/requests/Checkout/payment_methods_balance.json +9 -0
- data/spec/mocks/requests/DataProtectionService/request_subject_erasure.json +5 -0
- data/spec/mocks/requests/DisputeService/defend_dispute.json +5 -0
- data/spec/mocks/requests/DisputeService/delete_dispute_defense_document.json +5 -0
- data/spec/mocks/requests/DisputeService/retrieve_applicable_defense_reasons.json +4 -0
- data/spec/mocks/requests/DisputeService/supply_defense_document.json +11 -0
- data/spec/mocks/requests/Fund/refund_funds_transfer.json +7 -0
- data/spec/mocks/requests/Hop/get_onboarding_url.json +4 -0
- data/spec/mocks/requests/Payment/donate.json +10 -0
- data/spec/mocks/requests/Payment/get_authentication_result.json +4 -0
- data/spec/mocks/requests/Payment/retrieve_3ds2_result.json +4 -0
- data/spec/mocks/requests/Payment/technical_cancel.json +4 -0
- data/spec/mocks/requests/Payment/void_pending_refund.json +4 -0
- data/spec/mocks/requests/Payout/payout.json +8 -0
- data/spec/mocks/requests/Recurring/schedule_account_updater.json +12 -0
- data/spec/mocks/requests/Terminal/assign_terminals.json +6 -0
- data/spec/mocks/requests/Terminal/find_terminal.json +3 -0
- data/spec/mocks/requests/Terminal/get_terminals_under_account.json +4 -0
- data/spec/mocks/responses/Account/check_account_holder.json +3 -0
- data/spec/mocks/responses/Account/delete_payout_methods.json +3 -0
- data/spec/mocks/responses/BinLookup/get_3ds_availability.json +8 -0
- data/spec/mocks/responses/BinLookup/get_cost_estimate.json +8 -0
- data/spec/mocks/responses/Checkout/get-payment-link.json +11 -0
- data/spec/mocks/responses/Checkout/orders.json +8 -0
- data/spec/mocks/responses/Checkout/orders_cancel.json +4 -0
- data/spec/mocks/responses/Checkout/origin_keys.json +5 -0
- data/spec/mocks/responses/Checkout/payment_methods_balance.json +3 -0
- data/spec/mocks/responses/Checkout/update-payment-link.json +11 -0
- data/spec/mocks/responses/DataProtectionService/request_subject_erasure.json +3 -0
- data/spec/mocks/responses/DisputeService/defend_dispute.json +5 -0
- data/spec/mocks/responses/DisputeService/delete_dispute_defense_document.json +5 -0
- data/spec/mocks/responses/DisputeService/retrieve_applicable_defense_reasons.json +28 -0
- data/spec/mocks/responses/DisputeService/supply_defense_document.json +5 -0
- data/spec/mocks/responses/Fund/refund_funds_transfer.json +5 -0
- data/spec/mocks/responses/Hop/get_onboarding_url.json +7 -0
- data/spec/mocks/responses/Payment/donate.json +4 -0
- data/spec/mocks/responses/Payment/get_authentication_result.json +5 -0
- data/spec/mocks/responses/Payment/retrieve_3ds2_result.json +5 -0
- data/spec/mocks/responses/Payment/technical_cancel.json +3 -0
- data/spec/mocks/responses/Payment/void_pending_refund.json +3 -0
- data/spec/mocks/responses/Payout/payout.json +3 -0
- data/spec/mocks/responses/Recurring/schedule_account_updater.json +4 -0
- data/spec/mocks/responses/Terminal/assign_terminals.json +5 -0
- data/spec/mocks/responses/Terminal/find_terminal.json +6 -0
- data/spec/mocks/responses/Terminal/get_terminals_under_account.json +11 -0
- data/spec/payments_spec.rb +6 -1
- data/spec/payouts_spec.rb +2 -1
- data/spec/postfmapi_spec.rb +16 -0
- data/spec/recurring_spec.rb +2 -1
- data/spec/service_spec.rb +2 -0
- data/spec/spec_helper.rb +18 -12
- metadata +69 -7
- data/spec/checkout_utility_spec.rb +0 -29
- data/spec/mocks/requests/CheckoutUtility/origin_keys.json +0 -7
- data/spec/mocks/responses/CheckoutUtility/origin_keys.json +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02ec361baadfa4a0b114ff3f4b162f737775e22ed23b40d79e76fb0dfda3d7e2
|
4
|
+
data.tar.gz: cbffe8658ad929e8e7a7eb210013a43dbf2c58094b46e3c753c4e07ba41f4b43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa6e2f3474c3d4178fd25076994ccb76b034c8976f47f6da749bdda656b2dbc15c18757f2f7339777a15fd67f18c1d0b0b6f31436a5430a84283d6b39f69387d
|
7
|
+
data.tar.gz: 1b13bf85208f2820b7d4bc033a267b1db8dc727c00b64bd2357cc16e1e34398a70c63bb05b8d7559e3bd7b4b6a03307025a7c5d87c59dc71404a460a758b7cd9
|
data/.github/CODEOWNERS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* @crrood @
|
1
|
+
* @crrood @Aleffio @wboereboom @cyattilakiss
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**How to reproduce**
|
14
|
+
Steps to reproduce the behavior.
|
15
|
+
|
16
|
+
**Expected behavior**
|
17
|
+
A clear and concise description of what you expected to happen.
|
18
|
+
|
19
|
+
**Screenshots**
|
20
|
+
If applicable, add screenshots to help explain your problem.
|
21
|
+
|
22
|
+
**Desktop (please complete the following information):**
|
23
|
+
- ruby Version: [x.y.z]
|
24
|
+
- Library Version: [x.y.z]
|
25
|
+
|
26
|
+
**Additional context**
|
27
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**ruby version**: x.y.z
|
11
|
+
**Library version**: x.y.z
|
12
|
+
|
13
|
+
**Is your feature request related to a problem? Please describe.**
|
14
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
15
|
+
|
16
|
+
**Describe the solution you'd like**
|
17
|
+
A clear and concise description of what you want to happen.
|
18
|
+
|
19
|
+
**Describe alternatives you've considered**
|
20
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
21
|
+
|
22
|
+
**Additional context**
|
23
|
+
Add any other context or screenshots about the feature request here.
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,51 +1,69 @@
|
|
1
1
|
# Adyen API Library for Ruby
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
This is the officially supported Ruby library for using Adyen's APIs.
|
4
5
|
|
5
6
|
## Integration
|
7
|
+
The library supports all APIs under the following services:
|
6
8
|
|
7
|
-
|
9
|
+
* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v67/overview): Our latest integration for accepting online payments. Current supported version: **v67**
|
10
|
+
* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v64/overview): Our classic integration for online payments. Current supported version: **v64**
|
11
|
+
* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v49/overview): Endpoints for managing saved payment details. Current supported version: **v49**
|
12
|
+
* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v64/overview): Endpoints for sending funds to your customers. Current supported version: **v64**
|
13
|
+
* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms.
|
14
|
+
* [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6**
|
15
|
+
* [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6**
|
16
|
+
* [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6**
|
17
|
+
* [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Current supported version: **v1**
|
18
|
+
* [Adyen BinLookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v50/overview): Current supported version: **v50**
|
19
|
+
* [Data Protection API](https://docs.adyen.com/development-resources/data-protection-api): Current supported version: **v1**
|
20
|
+
* [Disputes API](https://docs.adyen.com/risk-management/disputes-api): Current supported version: **v50**
|
8
21
|
|
9
|
-
* checkout
|
10
|
-
* checkout utility
|
11
|
-
* payments
|
12
|
-
* modifications
|
13
|
-
* payouts
|
14
|
-
* recurring
|
15
|
-
* marketpay
|
16
22
|
|
17
|
-
|
23
|
+
For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
|
18
24
|
|
19
|
-
|
25
|
+
## Prerequisites
|
26
|
+
- [Adyen test account](https://docs.adyen.com/get-started-with-adyen)
|
27
|
+
- [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).
|
28
|
+
- Ruby >= 2.1
|
20
29
|
|
21
30
|
## Installation
|
22
31
|
|
23
|
-
The sole dependency is faraday for
|
32
|
+
The sole dependency is faraday for HTTP communication. Run the following command to install faraday if you don't already have it:
|
33
|
+
|
34
|
+
~~~~bash
|
35
|
+
bundle install
|
36
|
+
~~~~
|
24
37
|
|
25
|
-
To validate functionality of client
|
38
|
+
To validate functionality of client and run mock API tests use
|
26
39
|
|
40
|
+
~~~~bash
|
41
|
+
bundle install --with development
|
42
|
+
~~~~
|
43
|
+
and
|
44
|
+
~~~~bash
|
45
|
+
rspec
|
46
|
+
~~~~
|
27
47
|
## Documentation
|
28
48
|
|
29
49
|
Follow the rest of our guides from the [documentation](https://adyen.github.io/adyen-ruby-api-library/) on how to use this library.
|
30
50
|
|
31
|
-
##
|
51
|
+
## Using the library
|
32
52
|
|
33
|
-
###
|
34
|
-
```ruby
|
35
|
-
require 'adyen-ruby-api-library'
|
53
|
+
### General use with API key
|
36
54
|
|
55
|
+
~~~~bash
|
56
|
+
require 'adyen-ruby-api-library'
|
57
|
+
~~~~
|
58
|
+
~~~~ruby
|
37
59
|
adyen = Adyen::Client.new
|
38
60
|
|
39
|
-
# for API-key based implementations
|
40
61
|
adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
|
41
62
|
|
42
|
-
|
43
|
-
adyen.ws_user = 'ws@Company.Adyen'
|
44
|
-
adyen.ws_password = 'super_secure_password123'
|
45
|
-
```
|
63
|
+
~~~~
|
46
64
|
|
47
|
-
|
48
|
-
|
65
|
+
- Make a Payment
|
66
|
+
~~~~ruby
|
49
67
|
response = adyen.checkout.payments({
|
50
68
|
:amount => {
|
51
69
|
:currency => "EUR",
|
@@ -54,101 +72,45 @@ response = adyen.checkout.payments({
|
|
54
72
|
:reference => "Your order number",
|
55
73
|
:paymentMethod => {
|
56
74
|
:type => "scheme",
|
57
|
-
:encryptedCardNumber => "
|
58
|
-
:encryptedExpiryMonth => "
|
59
|
-
:encryptedExpiryYear => "
|
60
|
-
:encryptedSecurityCode => "
|
75
|
+
:encryptedCardNumber => "test_4111111111111111",
|
76
|
+
:encryptedExpiryMonth => "test_03",
|
77
|
+
:encryptedExpiryYear => "test_2030",
|
78
|
+
:encryptedSecurityCode => "test_737"
|
61
79
|
},
|
62
80
|
:returnUrl => "https://your-company.com/checkout/",
|
63
81
|
:merchantAccount => "YourMerchantAccount"
|
64
82
|
})
|
65
|
-
|
66
|
-
|
67
|
-
### Change API Version
|
68
|
-
```ruby
|
69
|
-
adyen.checkout.version = 50
|
70
|
-
```
|
71
|
-
|
72
|
-
## List of supported methods
|
73
|
-
|
74
|
-
**checkout:**
|
75
|
-
- payment_session
|
76
|
-
- payments.result
|
77
|
-
- payment_methods
|
78
|
-
- payments
|
79
|
-
- payments.details
|
80
|
-
- payment_links
|
81
|
-
|
82
|
-
**checkout utility:**
|
83
|
-
- origin_keys
|
84
|
-
|
85
|
-
**payments:**
|
86
|
-
- authorise
|
87
|
-
- authorise3d
|
88
|
-
|
89
|
-
**modifications:**
|
90
|
-
- capture
|
91
|
-
- cancel
|
92
|
-
- refund
|
93
|
-
- cancel_or_refund
|
94
|
-
- adjust_authorisation
|
95
|
-
|
96
|
-
**payouts:**
|
97
|
-
- confirm_third_party
|
98
|
-
- decline_third_party
|
99
|
-
- store_detail
|
100
|
-
- submit_third_party
|
101
|
-
- store_detail_and_submit_third_party
|
102
|
-
|
103
|
-
**recurring:**
|
104
|
-
- list_recurring_details
|
105
|
-
- disable
|
106
|
-
- store_token
|
107
|
-
|
108
|
-
**marketpay.account:**
|
109
|
-
- create_account_holder
|
110
|
-
- get_account_holder
|
111
|
-
- update_account_holder
|
112
|
-
- update_account_holder_state
|
113
|
-
- suspend_account_holder
|
114
|
-
- un_suspend_account_holder
|
115
|
-
- close_account_holder
|
116
|
-
- create_account
|
117
|
-
- update_account
|
118
|
-
- close_account
|
119
|
-
- upload_document
|
120
|
-
- get_uploaded_documents
|
121
|
-
- delete_bank_accounts
|
122
|
-
- delete_shareholders
|
123
|
-
|
124
|
-
**marketpay.fund:**
|
125
|
-
- account_holder_balance
|
126
|
-
- account_holder_transaction_list
|
127
|
-
- payout_account_holder
|
128
|
-
- transfer_funds
|
129
|
-
- setup_beneficiary
|
130
|
-
- refund_not_paid_out_transfers
|
131
|
-
|
132
|
-
**marketpay.notification:**
|
133
|
-
- create_notification_configuration
|
134
|
-
- get_notification_configuration
|
135
|
-
- get_notification_configuration_list
|
136
|
-
- test_notification_configuration
|
137
|
-
- update_notification_configuration
|
138
|
-
- delete_notification_configurations
|
83
|
+
~~~~
|
139
84
|
|
140
|
-
|
85
|
+
- Change API Version
|
86
|
+
~~~~ruby
|
87
|
+
adyen.checkout.version = 67
|
88
|
+
~~~~
|
141
89
|
|
142
|
-
|
90
|
+
### Example integration
|
91
|
+
|
92
|
+
For a closer look at how our Ruby library works, clone our [example integration](https://github.com/adyen-examples/adyen-rails-online-payments). This includes commented code, highlighting key features and concepts, and examples of API calls that can be made using the library.
|
93
|
+
|
94
|
+
### Running the tests
|
95
|
+
To run the tests use :
|
96
|
+
~~~~bash
|
97
|
+
bundle install --with development
|
98
|
+
~~~~
|
143
99
|
|
144
100
|
## Contributing
|
145
|
-
We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
|
146
|
-
* New features and functionality
|
147
|
-
* Resolved bug fixes and issues
|
148
|
-
* Any general improvements
|
149
101
|
|
150
|
-
|
102
|
+
We encourage you to contribute to this repository, so everyone can benefit from new features, bug fixes, and any other improvements.
|
103
|
+
Have a look at our [contributing guidelines](https://github.com/Adyen/adyen-ruby-api-library/blob/develop/CONTRIBUTING.md) to find out how to raise a pull request.
|
104
|
+
|
105
|
+
## Support
|
106
|
+
If you have a feature request, or spotted a bug or a technical problem, [create an issue here](https://github.com/Adyen/adyen-ruby-api-library/issues/new/choose).
|
107
|
+
|
108
|
+
For other questions, [contact our Support Team](https://www.adyen.help/hc/en-us/requests/new?ticket_form_id=360000705420).
|
151
109
|
|
152
110
|
## Licence
|
111
|
+
This repository is available under the [MIT license](https://github.com/Adyen/adyen-ruby-api-library/blob/master/LICENSE).
|
153
112
|
|
154
|
-
|
113
|
+
## See also
|
114
|
+
* [Example integration](https://github.com/adyen-examples/adyen-rails-online-payments)
|
115
|
+
* [Adyen docs](https://docs.adyen.com/)
|
116
|
+
* [API Explorer](https://docs.adyen.com/api-explorer/)
|
@@ -2,22 +2,14 @@ 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/checkout_utility"
|
6
5
|
require_relative "adyen/services/payments"
|
7
6
|
require_relative "adyen/services/payouts"
|
8
7
|
require_relative "adyen/services/recurring"
|
9
8
|
require_relative "adyen/services/marketpay"
|
9
|
+
require_relative "adyen/services/postfmapi"
|
10
10
|
require_relative "adyen/services/service"
|
11
|
+
require_relative "adyen/services/data_protection"
|
12
|
+
require_relative "adyen/services/dispute"
|
13
|
+
require_relative "adyen/services/bin_lookup"
|
11
14
|
require_relative "adyen/hash_with_accessors"
|
12
15
|
require_relative "adyen/utils/hmac_validator"
|
13
|
-
|
14
|
-
# add snake case to camel case converter to String
|
15
|
-
# to convert rubinic method names to Adyen API methods
|
16
|
-
#
|
17
|
-
# i.e. snake_case -> snakeCase
|
18
|
-
# note that the first letter is not capitalized as normal
|
19
|
-
class String
|
20
|
-
def to_camel_case
|
21
|
-
split("_").collect.with_index{ |x, i| i > 0 ? x.capitalize : x }.join
|
22
|
-
end
|
23
|
-
end
|
data/lib/adyen/client.rb
CHANGED
@@ -42,15 +42,18 @@ module Adyen
|
|
42
42
|
when "Checkout"
|
43
43
|
url = "https://checkout-#{@env}.adyen.com/checkout"
|
44
44
|
supports_live_url_prefix = true
|
45
|
-
when "
|
46
|
-
url = "https://checkout-#{@env}.adyen.com/checkout"
|
47
|
-
supports_live_url_prefix = true
|
48
|
-
when "Account", "Fund", "Notification"
|
45
|
+
when "Account", "Fund", "Notification", "Hop"
|
49
46
|
url = "https://cal-#{@env}.adyen.com/cal/services"
|
50
47
|
supports_live_url_prefix = false
|
51
|
-
when "Recurring", "Payment", "Payout"
|
48
|
+
when "Recurring", "Payment", "Payout", "BinLookup"
|
52
49
|
url = "https://pal-#{@env}.adyen.com/pal/servlet"
|
53
50
|
supports_live_url_prefix = true
|
51
|
+
when "Terminal"
|
52
|
+
url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
|
53
|
+
supports_live_url_prefix = false
|
54
|
+
when "DataProtectionService", "DisputeService"
|
55
|
+
url = "https://ca-#{@env}.adyen.com/ca/services"
|
56
|
+
supports_live_url_prefix = false
|
54
57
|
else
|
55
58
|
raise ArgumentError, "Invalid service specified"
|
56
59
|
end
|
@@ -66,7 +69,7 @@ module Adyen
|
|
66
69
|
|
67
70
|
# construct full URL from service and endpoint
|
68
71
|
def service_url(service, action, version)
|
69
|
-
if service == "Checkout" || service == "
|
72
|
+
if service == "Checkout" || service == "Terminal"
|
70
73
|
"#{service_url_base(service)}/v#{version}/#{action}"
|
71
74
|
else
|
72
75
|
"#{service_url_base(service)}/#{service}/v#{version}/#{action}"
|
@@ -74,9 +77,9 @@ module Adyen
|
|
74
77
|
end
|
75
78
|
|
76
79
|
# send request to adyen API
|
77
|
-
def call_adyen_api(service, action, request_data, headers, version)
|
80
|
+
def call_adyen_api(service, action, request_data, headers, version, with_application_info = false)
|
78
81
|
# get URL for requested endpoint
|
79
|
-
url = service_url(service, action, version)
|
82
|
+
url = service_url(service, action.is_a?(String) ? action : action.fetch(:url), version)
|
80
83
|
|
81
84
|
# make sure right authentication has been provided
|
82
85
|
# will use api_key if present, otherwise ws_user and ws_password
|
@@ -119,20 +122,39 @@ module Adyen
|
|
119
122
|
end
|
120
123
|
|
121
124
|
# add application only on checkout service
|
122
|
-
if
|
125
|
+
if with_application_info
|
123
126
|
add_application_info(request_data)
|
124
127
|
end
|
125
128
|
|
126
129
|
# convert to json
|
127
130
|
request_data = request_data.to_json
|
128
131
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
132
|
+
if action.is_a?(::Hash)
|
133
|
+
if action.fetch(:method) == "get"
|
134
|
+
begin
|
135
|
+
response = conn.get
|
136
|
+
rescue Faraday::ConnectionFailed => connection_error
|
137
|
+
raise connection_error, "Connection to #{url} failed"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
if action.fetch(:method) == "patch"
|
141
|
+
begin
|
142
|
+
response = conn.patch do |req|
|
143
|
+
req.body = request_data
|
144
|
+
end
|
145
|
+
rescue Faraday::ConnectionFailed => connection_error
|
146
|
+
raise connection_error, "Connection to #{url} failed"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
else
|
150
|
+
# post request to Adyen
|
151
|
+
begin
|
152
|
+
response = conn.post do |req|
|
153
|
+
req.body = request_data
|
154
|
+
end # handle client errors
|
155
|
+
rescue Faraday::ConnectionFailed => connection_error
|
156
|
+
raise connection_error, "Connection to #{url} failed"
|
157
|
+
end
|
136
158
|
end
|
137
159
|
|
138
160
|
# check for API errors
|
@@ -151,16 +173,15 @@ module Adyen
|
|
151
173
|
# add application_info for analytics
|
152
174
|
def add_application_info(request_data)
|
153
175
|
adyenLibrary = {
|
154
|
-
|
155
|
-
|
176
|
+
:name => Adyen::NAME,
|
177
|
+
:version => Adyen::VERSION.to_s,
|
156
178
|
}
|
157
179
|
|
158
180
|
if request_data[:applicationInfo].nil?
|
159
|
-
request_data[:applicationInfo] = {}
|
181
|
+
request_data[:applicationInfo] = {}
|
160
182
|
end
|
161
183
|
|
162
184
|
request_data[:applicationInfo][:adyenLibrary] = adyenLibrary
|
163
|
-
request_data[:applicationInfo][:adyenLibraryTest] = adyenLibrary
|
164
185
|
end
|
165
186
|
|
166
187
|
# services
|
@@ -168,10 +189,6 @@ module Adyen
|
|
168
189
|
@checkout ||= Adyen::Checkout.new(self)
|
169
190
|
end
|
170
191
|
|
171
|
-
def checkout_utility
|
172
|
-
@checkout_utility ||= Adyen::CheckoutUtility.new(self)
|
173
|
-
end
|
174
|
-
|
175
192
|
def payments
|
176
193
|
@payments ||= Adyen::Payments.new(self)
|
177
194
|
end
|
@@ -187,5 +204,21 @@ module Adyen
|
|
187
204
|
def marketpay
|
188
205
|
@marketpay ||= Adyen::Marketpay::Marketpay.new(self)
|
189
206
|
end
|
207
|
+
|
208
|
+
def postfmapi
|
209
|
+
@postfmapi ||= Adyen::PosTerminalManagement.new(self)
|
210
|
+
end
|
211
|
+
|
212
|
+
def data_protection
|
213
|
+
@data_protection ||= Adyen::DataProtection.new(self)
|
214
|
+
end
|
215
|
+
|
216
|
+
def dispute
|
217
|
+
@dispute ||= Adyen::Dispute.new(self)
|
218
|
+
end
|
219
|
+
|
220
|
+
def bin_lookup
|
221
|
+
@bin_lookup ||= Adyen::BinLookup.new(self)
|
222
|
+
end
|
190
223
|
end
|
191
224
|
end
|