adyen-ruby-api-library 4.1.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -1
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
  5. data/.github/PULL_REQUEST_TEMPLATE.md +7 -0
  6. data/.github/dependabot.yml +8 -0
  7. data/.gitignore +2 -0
  8. data/README.md +72 -119
  9. data/docs/marketpay.html +2 -0
  10. data/lib/adyen-ruby-api-library.rb +3 -12
  11. data/lib/adyen/client.rb +49 -23
  12. data/lib/adyen/services/bin_lookup.rb +18 -0
  13. data/lib/adyen/services/checkout.rb +88 -8
  14. data/lib/adyen/services/{checkout_utility.rb → data_protection.rb} +4 -3
  15. data/lib/adyen/services/dispute.rb +20 -0
  16. data/lib/adyen/services/marketpay.rb +10 -7
  17. data/lib/adyen/services/payments.rb +15 -5
  18. data/lib/adyen/services/payouts.rb +3 -2
  19. data/lib/adyen/services/recurring.rb +3 -2
  20. data/lib/adyen/services/service.rb +2 -2
  21. data/lib/adyen/version.rb +1 -1
  22. data/spec/account_spec.rb +4 -1
  23. data/spec/bin_lookup_spec.rb +15 -0
  24. data/spec/checkout_spec.rb +247 -5
  25. data/spec/data_protection_spec.rb +14 -0
  26. data/spec/dispute_spec.rb +17 -0
  27. data/spec/fund_spec.rb +2 -1
  28. data/spec/mocks/requests/Account/check_account_holder.json +5 -0
  29. data/spec/mocks/requests/Account/delete_payout_methods.json +6 -0
  30. data/spec/mocks/requests/Account/delete_signatories.json +6 -0
  31. data/spec/mocks/requests/BinLookup/get_3ds_availability.json +4 -0
  32. data/spec/mocks/requests/BinLookup/get_cost_estimate.json +8 -0
  33. data/spec/mocks/requests/Checkout/orders.json +6 -0
  34. data/spec/mocks/requests/Checkout/orders_cancel.json +7 -0
  35. data/spec/mocks/requests/Checkout/origin_keys.json +3 -0
  36. data/spec/mocks/requests/Checkout/payment_methods_balance.json +9 -0
  37. data/spec/mocks/requests/DataProtectionService/request_subject_erasure.json +5 -0
  38. data/spec/mocks/requests/DisputeService/defend_dispute.json +5 -0
  39. data/spec/mocks/requests/DisputeService/delete_dispute_defense_document.json +5 -0
  40. data/spec/mocks/requests/DisputeService/retrieve_applicable_defense_reasons.json +4 -0
  41. data/spec/mocks/requests/DisputeService/supply_defense_document.json +11 -0
  42. data/spec/mocks/requests/Fund/refund_funds_transfer.json +7 -0
  43. data/spec/mocks/requests/Payment/donate.json +10 -0
  44. data/spec/mocks/requests/Payment/get_authentication_result.json +4 -0
  45. data/spec/mocks/requests/Payment/retrieve_3ds2_result.json +4 -0
  46. data/spec/mocks/requests/Payment/technical_cancel.json +4 -0
  47. data/spec/mocks/requests/Payment/void_pending_refund.json +4 -0
  48. data/spec/mocks/requests/Payout/payout.json +8 -0
  49. data/spec/mocks/requests/Recurring/schedule_account_updater.json +12 -0
  50. data/spec/mocks/responses/Account/check_account_holder.json +3 -0
  51. data/spec/mocks/responses/Account/delete_payout_methods.json +3 -0
  52. data/spec/mocks/responses/Account/delete_signatories.json +3 -0
  53. data/spec/mocks/responses/BinLookup/get_3ds_availability.json +8 -0
  54. data/spec/mocks/responses/BinLookup/get_cost_estimate.json +8 -0
  55. data/spec/mocks/responses/Checkout/get-payment-link.json +11 -0
  56. data/spec/mocks/responses/Checkout/orders.json +8 -0
  57. data/spec/mocks/responses/Checkout/orders_cancel.json +4 -0
  58. data/spec/mocks/responses/Checkout/origin_keys.json +5 -0
  59. data/spec/mocks/responses/Checkout/payment_methods_balance.json +3 -0
  60. data/spec/mocks/responses/Checkout/update-payment-link.json +11 -0
  61. data/spec/mocks/responses/DataProtectionService/request_subject_erasure.json +3 -0
  62. data/spec/mocks/responses/DisputeService/defend_dispute.json +5 -0
  63. data/spec/mocks/responses/DisputeService/delete_dispute_defense_document.json +5 -0
  64. data/spec/mocks/responses/DisputeService/retrieve_applicable_defense_reasons.json +28 -0
  65. data/spec/mocks/responses/DisputeService/supply_defense_document.json +5 -0
  66. data/spec/mocks/responses/Fund/refund_funds_transfer.json +5 -0
  67. data/spec/mocks/responses/Payment/donate.json +4 -0
  68. data/spec/mocks/responses/Payment/get_authentication_result.json +5 -0
  69. data/spec/mocks/responses/Payment/retrieve_3ds2_result.json +5 -0
  70. data/spec/mocks/responses/Payment/technical_cancel.json +3 -0
  71. data/spec/mocks/responses/Payment/void_pending_refund.json +3 -0
  72. data/spec/mocks/responses/Payout/payout.json +3 -0
  73. data/spec/mocks/responses/Recurring/schedule_account_updater.json +4 -0
  74. data/spec/payments_spec.rb +6 -1
  75. data/spec/payouts_spec.rb +2 -1
  76. data/spec/recurring_spec.rb +2 -1
  77. data/spec/service_spec.rb +2 -0
  78. data/spec/spec_helper.rb +18 -12
  79. metadata +60 -7
  80. data/spec/checkout_utility_spec.rb +0 -29
  81. data/spec/mocks/requests/CheckoutUtility/origin_keys.json +0 -7
  82. 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: 3c88f2064ec4c1e38cfbd6b4d07ea19e0f85e93b40529f17bbdb54674d34adb0
4
- data.tar.gz: 2948eb3c524bc1361688bf800bda8e9f24f3aaa2b7ec199914ccbb5020b8d2f5
3
+ metadata.gz: 606de1d31b6cefd59729a9f8f3e865ab3d6f2b8542c45187193552b6081ca73c
4
+ data.tar.gz: 696ae30282dda22e188e7fc4dbe6bc1fe9c3d9eba1a205bc8e4aa8f5252c860a
5
5
  SHA512:
6
- metadata.gz: daebc0ac72b38814bd7111b47a91933ad5f5c5ae7b83eb50ef70fc1540251febb3a2cb2de4d644e0d49d48a1e4e3fa8de09450fa030627f13b48e7af558bf85c
7
- data.tar.gz: 1e2a7692384f3da060ede6be60f5ac404c84360892a28b71a632a32ca42483900cba0699b865ab5ca82605cab0d19ae3b15e8b1dac37f19c4f8d51fb00a363b2
6
+ metadata.gz: 8d8ca15489a40507aec9d8b1e6484efdc68f1189dca253e12e8d46f030fbc59e324021046a218d133e0fa337873e9978585bdc5e8c7010e3150993e683374818
7
+ data.tar.gz: 73ed56f5737ebfc1834622d97daeae79c7910fafa8fe9f4f4424ed7bd26c4bad29bcc22ab0d2f65be3edca4cc8191c88c86c9b7274dcaec1ff98b1a688b7bd69
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @crrood @hbkwong @KadoBOT @Aleffio @rikterbeek
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.
@@ -0,0 +1,7 @@
1
+ **Description**
2
+ <!-- Please provide a description of the changes proposed in the Pull Request -->
3
+
4
+ **Tested scenarios**
5
+ <!-- Description of tested scenarios -->
6
+
7
+ **Fixed issue**: <!-- #-prefixed issue number -->
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "04:00"
8
+ open-pull-requests-limit: 10
data/.gitignore CHANGED
@@ -11,3 +11,5 @@ design.txt
11
11
 
12
12
  .bundle
13
13
  .ruby-version
14
+
15
+ .DS_Store
data/README.md CHANGED
@@ -1,52 +1,69 @@
1
1
  # Adyen API Library for Ruby
2
2
 
3
- The Adyen API Library for Ruby lets you easily work with Adyen's API.
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
- The Library supports all APIs under the following services:
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
- * postfmapi
17
22
 
18
- ## Requirements
23
+ For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/).
19
24
 
20
- Built for Ruby >= 2.1
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
21
29
 
22
30
  ## Installation
23
31
 
24
- The sole dependency is faraday for http communication - run `bundle install` to install faraday if you don't already have it
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
+ ~~~~
25
37
 
26
- To validate functionality of client, use `bundle install --with development` and `rspec` to run mock API tests.
38
+ To validate functionality of client and run mock API tests use
27
39
 
40
+ ~~~~bash
41
+ bundle install --with development
42
+ ~~~~
43
+ and
44
+ ~~~~bash
45
+ rspec
46
+ ~~~~
28
47
  ## Documentation
29
48
 
30
49
  Follow the rest of our guides from the [documentation](https://adyen.github.io/adyen-ruby-api-library/) on how to use this library.
31
50
 
32
- ## Usage
51
+ ## Using the library
33
52
 
34
- ### Create a client to connect to the Adyen API
35
- ```ruby
36
- require 'adyen-ruby-api-library'
53
+ ### General use with API key
37
54
 
55
+ ~~~~bash
56
+ require 'adyen-ruby-api-library'
57
+ ~~~~
58
+ ~~~~ruby
38
59
  adyen = Adyen::Client.new
39
60
 
40
- # for API-key based implementations
41
61
  adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
42
62
 
43
- # for basic-auth based implementations
44
- adyen.ws_user = 'ws@Company.Adyen'
45
- adyen.ws_password = 'super_secure_password123'
46
- ```
63
+ ~~~~
47
64
 
48
- ### Make a Payment
49
- ```ruby
65
+ - Make a Payment
66
+ ~~~~ruby
50
67
  response = adyen.checkout.payments({
51
68
  :amount => {
52
69
  :currency => "EUR",
@@ -55,109 +72,45 @@ response = adyen.checkout.payments({
55
72
  :reference => "Your order number",
56
73
  :paymentMethod => {
57
74
  :type => "scheme",
58
- :encryptedCardNumber => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
59
- :encryptedExpiryMonth => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
60
- :encryptedExpiryYear => "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
61
- :encryptedSecurityCode => "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
75
+ :encryptedCardNumber => "test_4111111111111111",
76
+ :encryptedExpiryMonth => "test_03",
77
+ :encryptedExpiryYear => "test_2030",
78
+ :encryptedSecurityCode => "test_737"
62
79
  },
63
80
  :returnUrl => "https://your-company.com/checkout/",
64
81
  :merchantAccount => "YourMerchantAccount"
65
82
  })
66
- ```
67
-
68
- ### Change API Version
69
- ```ruby
70
- adyen.checkout.version = 50
71
- ```
72
-
73
- ## List of supported methods
74
-
75
- **checkout:**
76
- - payment_session
77
- - payments.result
78
- - payment_methods
79
- - payments
80
- - payments.details
81
- - payment_links
82
-
83
- **checkout utility:**
84
- - origin_keys
85
-
86
- **payments:**
87
- - authorise
88
- - authorise3d
89
-
90
- **modifications:**
91
- - capture
92
- - cancel
93
- - refund
94
- - cancel_or_refund
95
- - adjust_authorisation
96
-
97
- **payouts:**
98
- - confirm_third_party
99
- - decline_third_party
100
- - store_detail
101
- - submit_third_party
102
- - store_detail_and_submit_third_party
103
-
104
- **recurring:**
105
- - list_recurring_details
106
- - disable
107
- - store_token
108
-
109
- **marketpay.account:**
110
- - create_account_holder
111
- - get_account_holder
112
- - update_account_holder
113
- - update_account_holder_state
114
- - suspend_account_holder
115
- - un_suspend_account_holder
116
- - close_account_holder
117
- - create_account
118
- - update_account
119
- - close_account
120
- - upload_document
121
- - get_uploaded_documents
122
- - delete_bank_accounts
123
- - delete_shareholders
124
-
125
- **marketpay.fund:**
126
- - account_holder_balance
127
- - account_holder_transaction_list
128
- - payout_account_holder
129
- - transfer_funds
130
- - setup_beneficiary
131
- - refund_not_paid_out_transfers
132
-
133
- **marketpay.notification:**
134
- - create_notification_configuration
135
- - get_notification_configuration
136
- - get_notification_configuration_list
137
- - test_notification_configuration
138
- - update_notification_configuration
139
- - delete_notification_configurations
140
-
141
- **marketpay.hop:**
142
- - get_onboarding_url
143
-
144
- **postfmapi:**
145
- - assign_terminals
146
- - find_terminal
147
- - get_terminals_under_account
83
+ ~~~~
148
84
 
149
- ## Support
85
+ - Change API Version
86
+ ~~~~ruby
87
+ adyen.checkout.version = 67
88
+ ~~~~
150
89
 
151
- If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com.
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
+ ~~~~
152
99
 
153
100
  ## Contributing
154
- We strongly encourage you to join us in contributing to this repository so everyone can benefit from:
155
- * New features and functionality
156
- * Resolved bug fixes and issues
157
- * Any general improvements
158
101
 
159
- Read our [**contribution guidelines**](CONTRIBUTING.md) to find out how.
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).
160
109
 
161
110
  ## Licence
111
+ This repository is available under the [MIT license](https://github.com/Adyen/adyen-ruby-api-library/blob/master/LICENSE).
162
112
 
163
- MIT license. For more information, see the LICENSE file.
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/)
data/docs/marketpay.html CHANGED
@@ -61,6 +61,8 @@
61
61
  <li>delete_bank_accounts</li>
62
62
 
63
63
  <li>delete_shareholders</li>
64
+
65
+ <li>delete_signatories</li>
64
66
  </ul>
65
67
 
66
68
  <h4 id="marketpayfund">marketpay.fund:</h4>
@@ -2,23 +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"
10
9
  require_relative "adyen/services/postfmapi"
11
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"
12
14
  require_relative "adyen/hash_with_accessors"
13
15
  require_relative "adyen/utils/hmac_validator"
14
-
15
- # add snake case to camel case converter to String
16
- # to convert rubinic method names to Adyen API methods
17
- #
18
- # i.e. snake_case -> snakeCase
19
- # note that the first letter is not capitalized as normal
20
- class String
21
- def to_camel_case
22
- split("_").collect.with_index{ |x, i| i > 0 ? x.capitalize : x }.join
23
- end
24
- end
data/lib/adyen/client.rb CHANGED
@@ -42,18 +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 "CheckoutUtility"
46
- url = "https://checkout-#{@env}.adyen.com/checkout"
47
- supports_live_url_prefix = true
48
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
54
51
  when "Terminal"
55
52
  url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
56
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
57
57
  else
58
58
  raise ArgumentError, "Invalid service specified"
59
59
  end
@@ -69,7 +69,7 @@ module Adyen
69
69
 
70
70
  # construct full URL from service and endpoint
71
71
  def service_url(service, action, version)
72
- if service == "Checkout" || service == "CheckoutUtility" || service == "Terminal"
72
+ if service == "Checkout" || service == "Terminal"
73
73
  "#{service_url_base(service)}/v#{version}/#{action}"
74
74
  else
75
75
  "#{service_url_base(service)}/#{service}/v#{version}/#{action}"
@@ -77,9 +77,9 @@ module Adyen
77
77
  end
78
78
 
79
79
  # send request to adyen API
80
- 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)
81
81
  # get URL for requested endpoint
82
- url = service_url(service, action, version)
82
+ url = service_url(service, action.is_a?(String) ? action : action.fetch(:url), version)
83
83
 
84
84
  # make sure right authentication has been provided
85
85
  # will use api_key if present, otherwise ws_user and ws_password
@@ -122,20 +122,39 @@ module Adyen
122
122
  end
123
123
 
124
124
  # add application only on checkout service
125
- if service == 'Checkout' || service == 'CheckoutUtility'
125
+ if with_application_info
126
126
  add_application_info(request_data)
127
127
  end
128
128
 
129
129
  # convert to json
130
130
  request_data = request_data.to_json
131
131
 
132
- # post request to Adyen
133
- begin
134
- response = conn.post do |req|
135
- req.body = request_data
136
- end # handle client errors
137
- rescue Faraday::ConnectionFailed => connection_error
138
- raise connection_error, "Connection to #{url} failed"
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
139
158
  end
140
159
 
141
160
  # check for API errors
@@ -154,16 +173,15 @@ module Adyen
154
173
  # add application_info for analytics
155
174
  def add_application_info(request_data)
156
175
  adyenLibrary = {
157
- :name => Adyen::NAME,
158
- :version => Adyen::VERSION.to_s
176
+ :name => Adyen::NAME,
177
+ :version => Adyen::VERSION.to_s,
159
178
  }
160
179
 
161
180
  if request_data[:applicationInfo].nil?
162
- request_data[:applicationInfo] = {};
181
+ request_data[:applicationInfo] = {}
163
182
  end
164
183
 
165
184
  request_data[:applicationInfo][:adyenLibrary] = adyenLibrary
166
- request_data[:applicationInfo][:adyenLibraryTest] = adyenLibrary
167
185
  end
168
186
 
169
187
  # services
@@ -171,10 +189,6 @@ module Adyen
171
189
  @checkout ||= Adyen::Checkout.new(self)
172
190
  end
173
191
 
174
- def checkout_utility
175
- @checkout_utility ||= Adyen::CheckoutUtility.new(self)
176
- end
177
-
178
192
  def payments
179
193
  @payments ||= Adyen::Payments.new(self)
180
194
  end
@@ -194,5 +208,17 @@ module Adyen
194
208
  def postfmapi
195
209
  @postfmapi ||= Adyen::PosTerminalManagement.new(self)
196
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
197
223
  end
198
224
  end