checkout_sdk 1.0.0.beta.2 → 1.0.0.beta.3

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -2
  3. data/README.md +34 -0
  4. data/lib/checkout_sdk/abstract_checkout_sdk_builder.rb +6 -1
  5. data/lib/checkout_sdk/api_client.rb +24 -4
  6. data/lib/checkout_sdk/balances/balances.rb +3 -0
  7. data/lib/checkout_sdk/balances/balances_client.rb +22 -0
  8. data/lib/checkout_sdk/checkout_api.rb +25 -1
  9. data/lib/checkout_sdk/checkout_configuration.rb +3 -2
  10. data/lib/checkout_sdk/checkout_oauth_sdk_builder.rb +9 -2
  11. data/lib/checkout_sdk/checkout_static_keys_sdk_builder.rb +2 -1
  12. data/lib/checkout_sdk/checkout_utils.rb +1 -0
  13. data/lib/checkout_sdk/common/common.rb +1 -0
  14. data/lib/checkout_sdk/common/country.rb +1 -0
  15. data/lib/checkout_sdk/common/date_range_query_filter.rb +14 -0
  16. data/lib/checkout_sdk/disputes/disputes_query_filter.rb +1 -7
  17. data/lib/checkout_sdk/events/events.rb +4 -0
  18. data/lib/checkout_sdk/events/events_client.rb +56 -0
  19. data/lib/checkout_sdk/events/events_query_filter.rb +28 -0
  20. data/lib/checkout_sdk/oauth_sdk_credentials.rb +5 -2
  21. data/lib/checkout_sdk/previous/checkout_api.rb +18 -2
  22. data/lib/checkout_sdk/previous/checkout_previous_static_keys_sdk_builder.rb +2 -1
  23. data/lib/checkout_sdk/reconciliation/reconciliation.rb +4 -0
  24. data/lib/checkout_sdk/reconciliation/reconciliation_client.rb +51 -0
  25. data/lib/checkout_sdk/reconciliation/reconciliation_query_payments_filter.rb +16 -0
  26. data/lib/checkout_sdk/reports/reports_client.rb +6 -0
  27. data/lib/checkout_sdk/risk/authentication_result.rb +26 -0
  28. data/lib/checkout_sdk/risk/authorization_result.rb +14 -0
  29. data/lib/checkout_sdk/risk/device.rb +32 -0
  30. data/lib/checkout_sdk/risk/location.rb +14 -0
  31. data/lib/checkout_sdk/risk/pre_authentication_assessment.rb +41 -0
  32. data/lib/checkout_sdk/risk/pre_capture_assessment.rb +44 -0
  33. data/lib/checkout_sdk/risk/risk.rb +17 -0
  34. data/lib/checkout_sdk/risk/risk_client.rb +27 -0
  35. data/lib/checkout_sdk/risk/risk_payment.rb +14 -0
  36. data/lib/checkout_sdk/risk/risk_shipping_details.rb +11 -0
  37. data/lib/checkout_sdk/risk/source/card_source.rb +30 -0
  38. data/lib/checkout_sdk/risk/source/customer_source.rb +15 -0
  39. data/lib/checkout_sdk/risk/source/id_source.rb +18 -0
  40. data/lib/checkout_sdk/risk/source/risk_payment_source.rb +19 -0
  41. data/lib/checkout_sdk/risk/source/token_source.rb +24 -0
  42. data/lib/checkout_sdk/simple_logger.rb +12 -0
  43. data/lib/checkout_sdk/transfers/create_transfer.rb +20 -0
  44. data/lib/checkout_sdk/transfers/transfer_destination.rb +11 -0
  45. data/lib/checkout_sdk/transfers/transfer_source.rb +14 -0
  46. data/lib/checkout_sdk/transfers/transfer_type.rb +11 -0
  47. data/lib/checkout_sdk/transfers/transfers.rb +8 -0
  48. data/lib/checkout_sdk/transfers/transfers_client.rb +27 -0
  49. data/lib/checkout_sdk/version.rb +1 -1
  50. data/lib/checkout_sdk/webhooks/webhook_request.rb +25 -0
  51. data/lib/checkout_sdk/webhooks/webhooks.rb +4 -0
  52. data/lib/checkout_sdk/webhooks/webhooks_client.rb +50 -0
  53. data/lib/checkout_sdk.rb +9 -0
  54. metadata +56 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4986ebc42cf3d03320a66dcaaed808ab1bac043d80cfaa6a67ecc4ba3412fab5
4
- data.tar.gz: 954c730bb43ea3cb5b48479879ef602d87312dbbf182ae0d03e97b14b4ecdccb
3
+ metadata.gz: c24b0f4468ceae122e68a30f9aa9527b8677d9e90ea9b12f6336f1e261c4f8af
4
+ data.tar.gz: 6844387675cf1ce09cbdaaa39a76cd0b8ee1382525378831a139a72e754e7669
5
5
  SHA512:
6
- metadata.gz: 8ab5a0ca6991b63ce2eac3d8084009d4fe9e465908db604c795e6f7c5f53c0b64fbc6b45fb7d29aeaacb604e49a8f5d0c2d8f04522bf1fe3db7e7139b42a80de
7
- data.tar.gz: c19f5b743b9b51c8f375c980d018b30461aeabee0ae4a5d57536374360cb465aad61d355dd70a30d03e39c6f66ec0f1530aa31938991fb1bfd6d632a30cfb744
6
+ metadata.gz: 667029ef711050e5a7bb77b40e0194dcc6bf372a07d4bb52110b097e6c54690823201dad529420515f5fad625d8871cd9fcda8cb855406cdf203fd000abd0949
7
+ data.tar.gz: 6609b101318588b281322a09f9609f55b60747653e49c02a233e09e3f2af1aec16d78a15045d36c985bc7feb0a891d64a23398bdf4d8f1b76b2ba956766c433a
data/.rubocop.yml CHANGED
@@ -20,10 +20,13 @@ Metrics/ParameterLists:
20
20
  Max: 10
21
21
 
22
22
  Metrics/ClassLength:
23
- Max: 110
23
+ Max: 120
24
24
 
25
25
  Metrics/CyclomaticComplexity:
26
- Max: 8
26
+ Max: 10
27
+
28
+ Metrics/PerceivedComplexity:
29
+ Max: 9
27
30
 
28
31
  Style/Documentation:
29
32
  Enabled: false
data/README.md CHANGED
@@ -107,6 +107,20 @@ request = CheckoutSdk::Payments::PaymentRequest.new
107
107
  payment_response = api.payments.request_payment(request)
108
108
  ```
109
109
 
110
+ ## Logging
111
+
112
+ The SDK supports custom Log provider, you need to provide your log configuration via SDK initialization by default uses `Logger` from Ruby.
113
+
114
+ ```ruby
115
+ api = CheckoutSdk.builder
116
+ .static_keys
117
+ .with_secret_key('secret_key')
118
+ .with_public_key('public_key') # optional, only required for operations related with tokens
119
+ .with_environment(CheckoutSdk::Environment.sandbox)
120
+ .with_logger(logger) # your own custom configuration
121
+ .build
122
+ ```
123
+
110
124
  ## Exception handling
111
125
 
112
126
  All the API responses that do not fall in the 2** status codes will cause a `CheckoutSdk::CheckoutApiException`. The
@@ -154,6 +168,7 @@ also need to specify the custom `http client` for `multipart requests`:
154
168
  http_client = Faraday.new do |conn|
155
169
  conn.options.timeout = 10
156
170
  conn.proxy "http://localhost:8080"
171
+ conn.response :raise_error
157
172
  end
158
173
 
159
174
  multipart_client = Faraday.new do |f|
@@ -170,6 +185,25 @@ api = CheckoutSdk.builder
170
185
  .build
171
186
  ```
172
187
 
188
+ If you want to use your own `http_client` and wants to use `Reports` module, the `get_report_file` function follows a redirect URL from Checkout,
189
+ Ruby SDK uses `faraday-follow-redirects` which is an [open source](https://github.com/tisba/faraday-follow-redirects) solution that came after Faraday 2.0 deprecation,
190
+ you must add it otherwise Ruby SDK will not be able to download the contents file, or provide your custom redirect adapter.
191
+
192
+ ```ruby
193
+ http_client = Faraday.new do |f|
194
+ f.response :follow_redirects
195
+ f.response :raise_error
196
+ end
197
+
198
+ api = CheckoutSdk.builder
199
+ .static_keys
200
+ .with_secret_key('secret_key')
201
+ .with_public_key('public_key') # optional, only required for operations related with tokens
202
+ .with_environment(CheckoutSdk::Environment.sandbox)
203
+ .with_http_client(http_client)
204
+ .build
205
+ ```
206
+
173
207
  ## Building from source
174
208
 
175
209
  Once you check out the code from GitHub, the project can be built using gem:
@@ -8,7 +8,7 @@ module CheckoutSdk
8
8
  # @return [Faraday::Connection]
9
9
  # @!attribute multipart_http_client
10
10
  # @return [Faraday::Connection]
11
- attr_accessor :environment, :http_client, :multipart_http_client
11
+ attr_accessor :environment, :http_client, :multipart_http_client, :logger
12
12
 
13
13
  # @param [Environment] environment
14
14
  def with_environment(environment)
@@ -28,6 +28,10 @@ module CheckoutSdk
28
28
  self
29
29
  end
30
30
 
31
+ def with_logger(logger)
32
+ @logger = logger
33
+ end
34
+
31
35
  def build
32
36
  with_environment(Environment.sandbox) if environment.nil?
33
37
  if http_client.nil?
@@ -44,6 +48,7 @@ module CheckoutSdk
44
48
  raise CheckoutArgumentException, 'multipart_http_client must be an instance of Faraday::Connection'
45
49
  end
46
50
  end
51
+ @logger = SimpleLogger.new.logger if @logger.nil?
47
52
  end
48
53
  end
49
54
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  class ApiClient
5
- attr_accessor :client, :multipart_client
5
+ attr_accessor :client, :multipart_client, :log
6
6
 
7
7
  # @param [CheckoutConfiguration] configuration
8
8
  # @param [String] uri
@@ -11,6 +11,7 @@ module CheckoutSdk
11
11
  @client.url_prefix = uri
12
12
  @multipart_client = configuration.multipart_http_client.clone
13
13
  @multipart_client.url_prefix = uri
14
+ @log = configuration.logger
14
15
  end
15
16
 
16
17
  # @param [String] path
@@ -64,6 +65,7 @@ module CheckoutSdk
64
65
  json_body = CheckoutSdk::JsonSerializer.to_custom_hash(body).to_json
65
66
 
66
67
  begin
68
+ @log.info "#{method}: /#{path}"
67
69
  response = @client.run_request(method, path, json_body, headers)
68
70
  rescue Faraday::ClientError => e
69
71
  raise CheckoutApiException, e.response
@@ -81,8 +83,15 @@ module CheckoutSdk
81
83
  end
82
84
 
83
85
  def append_params(path, input_params)
84
- hash = CheckoutSdk::JsonSerializer.to_custom_hash(input_params)
85
- params = URI.encode_www_form(hash)
86
+ raise CheckoutArgumentException, 'Query parameters were not provided' if input_params.nil?
87
+
88
+ if input_params.is_a? String
89
+ params = input_params
90
+ else
91
+ hash = CheckoutSdk::JsonSerializer.to_custom_hash(input_params)
92
+ params = URI.encode_www_form(hash)
93
+ end
94
+
86
95
  "#{path}?#{params}"
87
96
  end
88
97
 
@@ -106,6 +115,7 @@ module CheckoutSdk
106
115
  form = build_multipart_request file_request, file
107
116
 
108
117
  begin
118
+ @log.info "post: /#{path}"
109
119
  response = @multipart_client.run_request(:post, path, form, headers)
110
120
  rescue Faraday::ClientError => e
111
121
  raise CheckoutApiException, e.response
@@ -120,11 +130,21 @@ module CheckoutSdk
120
130
  raise CheckoutApiException, response if response.status < 200 || response.status >= 300
121
131
 
122
132
  metadata = CheckoutUtils.map_to_http_metadata(response)
123
- body = (JSON.parse(response.body, object_class: OpenStruct) if !response.body.nil? && response.body != '')
133
+ body = parse_json_or_contents(response)
124
134
  body = OpenStruct.new if body.nil?
125
135
  body = OpenStruct.new(items: body) if body.is_a? Array
126
136
  body.metadata = metadata if body.is_a? OpenStruct
127
137
  body
128
138
  end
139
+
140
+ def parse_json_or_contents(response)
141
+ return if response.body.nil? || response.body == ''
142
+
143
+ if response.body.start_with?('{', '[')
144
+ JSON.parse(response.body, object_class: OpenStruct)
145
+ else
146
+ OpenStruct.new(contents: response.body)
147
+ end
148
+ end
129
149
  end
130
150
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'checkout_sdk/balances/balances_client'
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Balances
5
+ class BalancesClient < Client
6
+ BALANCES = 'balances'
7
+ private_constant :BALANCES
8
+
9
+ # @param [ApiClient] api_client
10
+ # @param [CheckoutConfiguration] configuration
11
+ def initialize(api_client, configuration)
12
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::OAUTH)
13
+ end
14
+
15
+ # @param [String] entity_id
16
+ # @param [String] balances_query
17
+ def retrieve_entity_balances(entity_id, balances_query)
18
+ api_client.invoke_get(build_path(BALANCES, entity_id), sdk_authorization, balances_query)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -27,6 +27,12 @@ module CheckoutSdk
27
27
  # @return [CheckoutSdk::Accounts::AccountsClient]
28
28
  # @!attribute workflows
29
29
  # @return [CheckoutSdk::Workflows::WorkflowsClient]
30
+ # @!attribute risk
31
+ # @return [CheckoutSdk::Risk::RiskClient]
32
+ # @!attribute balances
33
+ # @return [CheckoutSdk::Balances::BalancesClient]
34
+ # @!attribute transfers
35
+ # @return [CheckoutSdk::Transfers::TransfersClient]
30
36
  class CheckoutApi
31
37
  attr_reader :customers,
32
38
  :disputes,
@@ -40,7 +46,10 @@ module CheckoutSdk
40
46
  :tokens,
41
47
  :ideal,
42
48
  :accounts,
43
- :workflows
49
+ :workflows,
50
+ :risk,
51
+ :balances,
52
+ :transfers
44
53
 
45
54
  # @param [CheckoutConfiguration] configuration
46
55
  def initialize(configuration)
@@ -58,6 +67,9 @@ module CheckoutSdk
58
67
  @ideal = CheckoutSdk::Apm::IdealClient.new api_client, configuration
59
68
  @workflows = CheckoutSdk::Workflows::WorkflowsClient.new api_client, configuration
60
69
  @accounts = CheckoutSdk::Accounts::AccountsClient.new(api_client, files_client(configuration), configuration)
70
+ @risk = CheckoutSdk::Risk::RiskClient.new api_client, configuration
71
+ @balances = CheckoutSdk::Balances::BalancesClient.new(balances_client(configuration), configuration)
72
+ @transfers = CheckoutSdk::Transfers::TransfersClient.new(transfers_client(configuration), configuration)
61
73
  end
62
74
 
63
75
  private
@@ -73,5 +85,17 @@ module CheckoutSdk
73
85
  def files_client(configuration)
74
86
  ApiClient.new(configuration, configuration.environment.files_uri)
75
87
  end
88
+
89
+ # @param [CheckoutConfiguration] configuration
90
+ # @return [ApiClient]
91
+ def balances_client(configuration)
92
+ ApiClient.new(configuration, configuration.environment.balances_uri)
93
+ end
94
+
95
+ # @param [CheckoutConfiguration] configuration
96
+ # @return [ApiClient]
97
+ def transfers_client(configuration)
98
+ ApiClient.new(configuration, configuration.environment.transfers_uri)
99
+ end
76
100
  end
77
101
  end
@@ -8,17 +8,18 @@ module CheckoutSdk
8
8
  # @!attribute http_client
9
9
  # @return [Faraday::Connection]
10
10
  class CheckoutConfiguration
11
- attr_accessor :credentials, :environment, :http_client, :multipart_http_client
11
+ attr_accessor :credentials, :environment, :http_client, :multipart_http_client, :logger
12
12
 
13
13
  # @param [SdkCredentials] credentials
14
14
  # @param [Environment] environment
15
15
  # @param [Faraday::Connection] http_client
16
16
  # @param [Faraday::Connection] multipart_http_client
17
- def initialize(credentials, environment, http_client, multipart_http_client)
17
+ def initialize(credentials, environment, http_client, multipart_http_client, logger)
18
18
  @credentials = credentials
19
19
  @environment = environment
20
20
  @http_client = http_client
21
21
  @multipart_http_client = multipart_http_client
22
+ @logger = logger
22
23
  end
23
24
  end
24
25
  end
@@ -43,10 +43,17 @@ module CheckoutSdk
43
43
  super
44
44
  CheckoutSdk::CheckoutApi.new(
45
45
  CheckoutConfiguration.new(
46
- OAuthSdkCredentials.new(client_id, client_secret, scopes, http_client, environment, authorization_uri),
46
+ OAuthSdkCredentials.new(client_id,
47
+ client_secret,
48
+ scopes,
49
+ http_client,
50
+ environment,
51
+ logger,
52
+ authorization_uri),
47
53
  environment,
48
54
  http_client,
49
- multipart_http_client
55
+ multipart_http_client,
56
+ logger
50
57
  )
51
58
  )
52
59
  end
@@ -16,7 +16,8 @@ module CheckoutSdk
16
16
  StaticKeysSdkCredentials.new(secret_key, public_key),
17
17
  environment,
18
18
  http_client,
19
- multipart_http_client
19
+ multipart_http_client,
20
+ logger
20
21
  )
21
22
  )
22
23
  end
@@ -32,6 +32,7 @@ module CheckoutSdk
32
32
  # @return [Faraday::Connection]
33
33
  def self.build_default_client
34
34
  Faraday.new do |f|
35
+ f.response :follow_redirects
35
36
  f.response :raise_error
36
37
  end
37
38
  end
@@ -22,3 +22,4 @@ require 'checkout_sdk/common/update_customer_request'
22
22
  require 'checkout_sdk/common/marketplace_data'
23
23
  require 'checkout_sdk/common/shipping_info'
24
24
  require 'checkout_sdk/common/product'
25
+ require 'checkout_sdk/common/date_range_query_filter'
@@ -255,6 +255,7 @@ module CheckoutSdk
255
255
  ZM = 'ZM'
256
256
  ZW = 'ZW'
257
257
  PS = 'PS'
258
+ QZ = 'QZ'
258
259
  end
259
260
  end
260
261
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Common
5
+ # @!attribute from
6
+ # @return [DateTime]
7
+ # @!attribute to
8
+ # @return [DateTime]
9
+ class DateRangeQueryFilter
10
+ attr_accessor :from,
11
+ :to
12
+ end
13
+ end
14
+ end
@@ -6,10 +6,6 @@ module CheckoutSdk
6
6
  # @return [Integer]
7
7
  # @!attribute skip
8
8
  # @return [Integer]
9
- # @!attribute from
10
- # @return [DateTime]
11
- # @!attribute to
12
- # @return [DateTime]
13
9
  # @!attribute id
14
10
  # @return [String]
15
11
  # @!attribute statuses
@@ -28,11 +24,9 @@ module CheckoutSdk
28
24
  # @return [String] - Not available on Previous.
29
25
  # @!attribute payment_mcc
30
26
  # @return [String] - Not available on Previous.
31
- class DisputesQueryFilter
27
+ class DisputesQueryFilter < CheckoutSdk::Common::DateRangeQueryFilter
32
28
  attr_accessor :limit,
33
29
  :skip,
34
- :from,
35
- :to,
36
30
  :id,
37
31
  :statuses,
38
32
  :payment_id,
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'checkout_sdk/events/events_query_filter'
4
+ require 'checkout_sdk/events/events_client'
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Events
6
+ class EventsClient < Client
7
+ EVENT_TYPES = 'event-types'
8
+ EVENTS = 'events'
9
+ NOTIFICATIONS = 'notifications'
10
+ WEBHOOKS = 'webhooks'
11
+ EVENT_ID = 'eventId'
12
+ RETRY = 'retry'
13
+ private_constant :EVENT_TYPES, :EVENTS, :NOTIFICATIONS, :WEBHOOKS, :EVENT_ID, :RETRY
14
+
15
+ # @param [ApiClient] api_client
16
+ # @param [CheckoutConfiguration] configuration
17
+ def initialize(api_client, configuration)
18
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY)
19
+ end
20
+
21
+ # @param [String,nil] version
22
+ def retrieve_all_event_types(version = nil)
23
+ query = "version=#{version}" unless version.nil?
24
+ api_client.invoke_get(EVENT_TYPES, sdk_authorization, query)
25
+ end
26
+
27
+ # @param [EventsQueryFilter] query_filter
28
+ def retrieve_events(query_filter)
29
+ api_client.invoke_get(EVENTS, sdk_authorization, query_filter)
30
+ end
31
+
32
+ # @param [String] event_id
33
+ def retrieve_event(event_id)
34
+ api_client.invoke_get(build_path(EVENTS, event_id), sdk_authorization)
35
+ end
36
+
37
+ # @param [String] event_id
38
+ # @param [String] notification_id
39
+ def retrieve_event_notification(event_id, notification_id)
40
+ api_client.invoke_get(build_path(EVENTS, event_id, NOTIFICATIONS, notification_id), sdk_authorization)
41
+ end
42
+
43
+ # @param [String] event_id
44
+ # @param [String] webhook_id
45
+ def retry_webhook(event_id, webhook_id)
46
+ api_client.invoke_post(build_path(EVENTS, event_id, WEBHOOKS, webhook_id), sdk_authorization)
47
+ end
48
+
49
+ # @param [String] event_id
50
+ def retry_all_webhooks(event_id)
51
+ api_client.invoke_post(build_path(EVENTS, event_id, WEBHOOKS, RETRY), sdk_authorization)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Events
6
+ # @!attribute payment_id
7
+ # @return [String]
8
+ # @!attribute charge_id
9
+ # @return [String]
10
+ # @!attribute track_id
11
+ # @return [String]
12
+ # @!attribute reference
13
+ # @return [String]
14
+ # @!attribute skip
15
+ # @return [Integer]
16
+ # @!attribute limit
17
+ # @return [Integer]
18
+ class EventsQueryFilter < CheckoutSdk::Common::DateRangeQueryFilter
19
+ attr_accessor :payment_id,
20
+ :charge_id,
21
+ :track_id,
22
+ :reference,
23
+ :skip,
24
+ :limit
25
+ end
26
+ end
27
+ end
28
+ end
@@ -22,7 +22,8 @@ module CheckoutSdk
22
22
  :scopes,
23
23
  :http_client,
24
24
  :environment,
25
- :authorization_uri
25
+ :authorization_uri,
26
+ :log
26
27
 
27
28
  # @param [String] client_id
28
29
  # @param [String] client_secret
@@ -30,7 +31,7 @@ module CheckoutSdk
30
31
  # @param [Faraday::Connection] http_client
31
32
  # @param [CheckoutSdk::Environment] environment
32
33
  # @param [String, nil] auth_uri
33
- def initialize(client_id, client_secret, scopes, http_client, environment, auth_uri = nil)
34
+ def initialize(client_id, client_secret, scopes, http_client, environment, logger, auth_uri = nil)
34
35
  validate_arguments client_id, client_secret, environment, auth_uri
35
36
  @client_id = client_id
36
37
  @client_secret = client_secret
@@ -38,6 +39,7 @@ module CheckoutSdk
38
39
  @authorization_uri = auth_uri.nil? ? environment.authorization_uri : auth_uri
39
40
  @oauth_http_client = http_client.clone
40
41
  @oauth_http_client.url_prefix = @authorization_uri
42
+ @log = logger
41
43
  build_access_token
42
44
  end
43
45
 
@@ -67,6 +69,7 @@ module CheckoutSdk
67
69
  body = URI.encode_www_form data
68
70
 
69
71
  begin
72
+ @log.info "post: #{authorization_uri}"
70
73
  response = @oauth_http_client.run_request(:post, @authorization_uri, body, headers)
71
74
  rescue Faraday::ClientError => e
72
75
  raise CheckoutAuthorizationException, e.response
@@ -6,7 +6,7 @@ module CheckoutSdk
6
6
  # @return [CheckoutSdk::Customers::CustomerClient]
7
7
  # @!attribute disputes
8
8
  # @return [CheckoutSdk::Disputes::DisputesClient]
9
- # @!attribute payments
9
+ # @!attribute hosted
10
10
  # @return [CheckoutSdk::Payments::HostedPaymentsClient]
11
11
  # @!attribute instruments
12
12
  # @return [CheckoutSdk::Previous::Instruments::InstrumentsClient]
@@ -22,6 +22,14 @@ module CheckoutSdk
22
22
  # @return [CheckoutSdk::Previous::Apm::KlarnaClient]
23
23
  # @!attribute sepa
24
24
  # @return [CheckoutSdk::Previous::Apm::SepaClient]
25
+ # @!attribute risk
26
+ # @return [CheckoutSdk::Risk::RiskClient]
27
+ # @!attribute reconciliation
28
+ # @return [CheckoutSdk::Previous::Reconciliation::ReconciliationClient]
29
+ # @!attribute webhooks
30
+ # @return [CheckoutSdk::Previous::Webhooks::WebhooksClient]
31
+ # @!attribute events
32
+ # @return [CheckoutSdk::Previous::Events::EventsClient]
25
33
  class CheckoutApi
26
34
  attr_reader :customers,
27
35
  :disputes,
@@ -32,7 +40,11 @@ module CheckoutSdk
32
40
  :sources,
33
41
  :tokens,
34
42
  :klarna,
35
- :sepa
43
+ :sepa,
44
+ :risk,
45
+ :reconciliation,
46
+ :webhooks,
47
+ :events
36
48
 
37
49
  # @param [CheckoutConfiguration] configuration
38
50
  def initialize(configuration)
@@ -47,6 +59,10 @@ module CheckoutSdk
47
59
  @tokens = CheckoutSdk::Tokens::TokensClient.new api_client, configuration
48
60
  @klarna = CheckoutSdk::Previous::Apm::KlarnaClient.new api_client, configuration
49
61
  @sepa = CheckoutSdk::Previous::Apm::SepaClient.new api_client, configuration
62
+ @risk = CheckoutSdk::Risk::RiskClient.new api_client, configuration
63
+ @reconciliation = CheckoutSdk::Previous::Reconciliation::ReconciliationClient.new api_client, configuration
64
+ @webhooks = CheckoutSdk::Previous::Webhooks::WebhooksClient.new api_client, configuration
65
+ @events = CheckoutSdk::Previous::Events::EventsClient.new api_client, configuration
50
66
  end
51
67
 
52
68
  private
@@ -16,7 +16,8 @@ module CheckoutSdk
16
16
  PreviousStaticKeysSdkCredentials.new(secret_key, public_key),
17
17
  environment,
18
18
  http_client,
19
- multipart_http_client
19
+ multipart_http_client,
20
+ logger
20
21
  )
21
22
  )
22
23
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'checkout_sdk/reconciliation/reconciliation_client'
4
+ require 'checkout_sdk/reconciliation/reconciliation_query_payments_filter'
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Reconciliation
6
+ class ReconciliationClient < Client
7
+ REPORTING = 'reporting'
8
+ PAYMENTS = 'payments'
9
+ STATEMENTS = 'statements'
10
+ DOWNLOAD = 'download'
11
+ private_constant :REPORTING, :PAYMENTS, :STATEMENTS, :DOWNLOAD
12
+
13
+ # @param [ApiClient] api_client
14
+ # @param [CheckoutConfiguration] configuration
15
+ def initialize(api_client, configuration)
16
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY)
17
+ end
18
+
19
+ # @param [ReconciliationQueryPaymentsFilter] payments_filter
20
+ def query_payments_report(payments_filter)
21
+ api_client.invoke_get(build_path(REPORTING, PAYMENTS), sdk_authorization, payments_filter)
22
+ end
23
+
24
+ # @param [String] payment_id
25
+ def single_payment_report(payment_id)
26
+ api_client.invoke_get(build_path(REPORTING, PAYMENTS, payment_id), sdk_authorization)
27
+ end
28
+
29
+ # @param [CheckoutSdk::Common::DateRangeQueryFilter] data_range
30
+ def query_statements_report(data_range)
31
+ api_client.invoke_get(build_path(REPORTING, STATEMENTS), sdk_authorization, data_range)
32
+ end
33
+
34
+ # @param [CheckoutSdk::Common::DateRangeQueryFilter] data_range
35
+ def retrieve_csv_payment_report(data_range)
36
+ api_client.invoke_get(build_path(REPORTING, PAYMENTS, DOWNLOAD), sdk_authorization, data_range)
37
+ end
38
+
39
+ # @param [String] statement_id
40
+ def retrieve_csv_single_statement_report(statement_id)
41
+ api_client.invoke_get(build_path(REPORTING, STATEMENTS, statement_id, PAYMENTS, DOWNLOAD), sdk_authorization)
42
+ end
43
+
44
+ # @param [CheckoutSdk::Common::DateRangeQueryFilter] data_range
45
+ def retrieve_csv_statements_report(data_range)
46
+ api_client.invoke_get(build_path(REPORTING, STATEMENTS, DOWNLOAD), sdk_authorization, data_range)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Previous
5
+ module Reconciliation
6
+ # @!attribute reference
7
+ # @return [String]
8
+ # @!attribute limit
9
+ # @return [Integer]
10
+ class ReconciliationQueryPaymentsFilter < CheckoutSdk::Common::DateRangeQueryFilter
11
+ attr_accessor :reference,
12
+ :limit
13
+ end
14
+ end
15
+ end
16
+ end
@@ -21,6 +21,12 @@ module CheckoutSdk
21
21
  def get_report_details(report_id)
22
22
  api_client.invoke_get(build_path(REPORTS, report_id), sdk_authorization)
23
23
  end
24
+
25
+ # @param [String] report_id
26
+ # @param [String] file_id
27
+ def get_report_file(report_id, file_id)
28
+ api_client.invoke_get(build_path(REPORTS, report_id, FILES, file_id), sdk_authorization)
29
+ end
24
30
  end
25
31
  end
26
32
  end