checkout_sdk 1.12.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c26660018aea61f28d8d1e742c57948b6ebadadb0440e245ca45eb14d53eede
4
- data.tar.gz: 3192d546b4240013ac01de9de0411f6654a974e465e285529f36d3df666f345c
3
+ metadata.gz: c470151f96c3425b61e6c49458a3612daf2174cf3b69e92861c5932dacfe5879
4
+ data.tar.gz: 2201bb66edace8b6b24edb4e84decf122dde349e6418c268e68dacdb1d8239b6
5
5
  SHA512:
6
- metadata.gz: 1791fa5f04fe3a5628e4804312fc778ff407398f657e47c1b51e85844251e4e28f81d88593a994b0318212fc016eb42f392f6de2612dc856aad55430783e7558
7
- data.tar.gz: cf4e630a4fd64a029bae0238c0e32bbdb0ab1a4576324fe31a7d09e74bfd54842440baf2725837527118d78d0b2a36b100f2051701c5fa50926c31bae4250c88
6
+ metadata.gz: 9d28b90870372311da801cb4c93f3fd16933b8ee79f43954bb837c8d30f82fe2ddef2ed965a41a81611a32263bf11d2778c8f21f49c8031d0b977b9aad2d15ce
7
+ data.tar.gz: d2a7438c35e5815e9be95804597218ae62d7a967e92ef6285f749110a77d82cead49c1933d88994551822547ea59ce5ee41b3466f2b0773569ac11eada4dd663
data/README.md CHANGED
@@ -69,6 +69,10 @@ account [here](https://www.checkout.com/get-test-account).
69
69
 
70
70
  **PLEASE NEVER SHARE OR PUBLISH YOUR CHECKOUT CREDENTIALS.**
71
71
 
72
+ ### Subdomain value
73
+
74
+ Requests must be made through your merchant-specific subdomain (MSSD): the first 8 characters of your client ID (excluding `cli_`). For example, if your client ID is `cli_vkuhvk4vjn2edkps7dfsq6emqm`, your subdomain is `vkuhvk4v`. When `with_environment_subdomain` is set the SDK sends requests to `https://vkuhvk4v.api.checkout.com`. See [Base URLs](https://api-reference.checkout.com/#section/Base-URLs) and [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints) for further details, and for where to find your unique client ID. Private Link merchants use their `pl-` prefixed subdomain (for example `pl-vkuhvk4v`), which the SDK also accepts.
75
+
72
76
  ### Default
73
77
 
74
78
  Default keys client instantiation can be done as follows:
@@ -79,6 +83,7 @@ api = CheckoutSdk.builder
79
83
  .with_secret_key('secret_key')
80
84
  .with_public_key('public_key') # optional, only required for operations related with tokens
81
85
  .with_environment(CheckoutSdk::Environment.sandbox)
86
+ .with_environment_subdomain('subdomain') # required, the first 8 characters of your client ID
82
87
  .build
83
88
  ```
84
89
 
@@ -89,10 +94,10 @@ The SDK supports client credentials OAuth, when initialized as follows:
89
94
  ```ruby
90
95
  api = CheckoutSdk.builder
91
96
  .oauth
92
- .with_authorization_uri('https://access.sandbox.checkout.com/connect/token') # custom authorization URI, optional
93
97
  .with_client_credentials("client_id", "client_secret")
94
98
  .with_scopes([CheckoutSdk::OAuthScopes::VAULT, CheckoutSdk::OAuthScopes::GATEWAY]) # array of scopes
95
99
  .with_environment(CheckoutSdk::Environment.sandbox)
100
+ .with_environment_subdomain('subdomain') # required, the first 8 characters of your client ID
96
101
  .build
97
102
  ```
98
103
 
@@ -107,6 +112,7 @@ api = CheckoutSdk.builder
107
112
  .with_secret_key('secret_key')
108
113
  .with_public_key('public_key') # optional, only required for operations related with tokens
109
114
  .with_environment(CheckoutSdk::Environment.sandbox)
115
+ .with_environment_subdomain('subdomain') # optional for the Previous platform
110
116
  .build
111
117
  ```
112
118
 
@@ -267,6 +273,23 @@ If you absolutely need to skip the pre-commit hooks:
267
273
  OVERCOMMIT_DISABLE=1 git commit -m "your message"
268
274
  ```
269
275
 
276
+ ## Legacy domain (emergency use only)
277
+
278
+ > :warning: **Only use if merchant specific sub domains are causing issues.** Connecting through your merchant-specific subdomain (see [Subdomain value](#subdomain-value)) is the supported way of using the Checkout.com API, and non-subdomain usage will be deprecated.
279
+
280
+ If, in exceptional circumstances, you cannot use your merchant-specific subdomain, you can explicitly opt out by calling `with_legacy_domain` instead of `with_environment_subdomain`:
281
+
282
+ ```ruby
283
+ api = CheckoutSdk.builder
284
+ .static_keys
285
+ .with_secret_key('secret_key')
286
+ .with_environment(CheckoutSdk::Environment.sandbox)
287
+ .with_legacy_domain # deprecated, emergency fallback only
288
+ .build
289
+ ```
290
+
291
+ This routes requests to `api.checkout.com` (or `api.sandbox.checkout.com`) and `access.checkout.com` (or `access.sandbox.checkout.com`). The method prints a deprecation warning. Exactly one of `with_environment_subdomain` or `with_legacy_domain` must be set: the SDK raises a `CheckoutSdk::CheckoutArgumentException` if both, or neither, are. The Previous (ABC) platform predates merchant-specific subdomains and is exempt from this requirement.
292
+
270
293
  ## Code of Conduct
271
294
 
272
295
  Please refer to [Code of Conduct](CODE_OF_CONDUCT.md)
@@ -8,9 +8,13 @@ module CheckoutSdk
8
8
  # @return [Faraday::Connection]
9
9
  # @!attribute multipart_http_client
10
10
  # @return [Faraday::Connection]
11
- # @!attribute environment_subdomain
12
- # @return [EnvironmentSubdomain, nil]
13
- attr_accessor :environment, :http_client, :multipart_http_client, :logger, :environment_subdomain
11
+ # @!attribute subdomain
12
+ # @return [String, nil]
13
+ attr_accessor :environment, :http_client, :multipart_http_client, :logger, :subdomain
14
+
15
+ def initialize
16
+ @use_legacy_domain = false
17
+ end
14
18
 
15
19
  # @param [Environment] environment
16
20
  def with_environment(environment)
@@ -37,11 +41,41 @@ module CheckoutSdk
37
41
 
38
42
  # @param [String, nil] subdomain
39
43
  def with_environment_subdomain(subdomain)
40
- @environment_subdomain = EnvironmentSubdomain.new(@environment, subdomain)
44
+ @subdomain = subdomain
45
+ self
46
+ end
47
+
48
+ # Opts out of the merchant-specific subdomain, sending every request to the shared hosts
49
+ # instead (api.checkout.com and access.checkout.com, or their sandbox equivalents).
50
+ #
51
+ # @deprecated This is an emergency fallback for the rare case where the merchant-specific
52
+ # subdomain cannot be used, and will be removed in a future release. Call
53
+ # {#with_environment_subdomain} instead.
54
+ # See https://api-reference.checkout.com/#section/Base-URLs
55
+ def with_legacy_domain
56
+ warn '[DEPRECATION] with_legacy_domain is deprecated and will be removed in a future ' \
57
+ 'release. It is intended only as an emergency fallback when the merchant-specific ' \
58
+ 'subdomain cannot be used. Call with_environment_subdomain instead. ' \
59
+ 'See https://api-reference.checkout.com/#section/Base-URLs'
60
+ @use_legacy_domain = true
41
61
  self
42
62
  end
43
63
 
64
+ # @return [EnvironmentSubdomain, nil]
65
+ def environment_subdomain
66
+ return nil if subdomain.nil?
67
+
68
+ EnvironmentSubdomain.new(environment, subdomain)
69
+ end
70
+
71
+ # Whether this builder requires the merchant-specific subdomain to be configured. The
72
+ # Previous (ABC) platform predates merchant-specific subdomains, so it overrides this.
73
+ def requires_environment_subdomain?
74
+ true
75
+ end
76
+
44
77
  def build
78
+ validate_environment_settings
45
79
  with_environment(Environment.sandbox) if environment.nil?
46
80
  if http_client.nil?
47
81
  @http_client = CheckoutUtils.build_default_client
@@ -59,5 +93,22 @@ module CheckoutSdk
59
93
  end
60
94
  @logger = SimpleLogger.new.logger if @logger.nil?
61
95
  end
96
+
97
+ private
98
+
99
+ def validate_environment_settings
100
+ if !subdomain.nil? && @use_legacy_domain
101
+ raise CheckoutArgumentException,
102
+ 'with_environment_subdomain and with_legacy_domain cannot both be set - provide ' \
103
+ 'only your merchant-specific subdomain'
104
+ end
105
+ return unless subdomain.nil? && !@use_legacy_domain && requires_environment_subdomain?
106
+
107
+ raise CheckoutArgumentException,
108
+ 'environment subdomain is required - provide your merchant-specific subdomain ' \
109
+ '(typically your client ID excluding the cli_ prefix, see ' \
110
+ 'https://api-reference.checkout.com/#section/Base-URLs), or call with_legacy_domain ' \
111
+ 'to opt out only if merchant specific sub domains are causing issues'
112
+ end
62
113
  end
63
114
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  module Accounts
5
+ # For SaaS sellers (ISV), a daily schedule runs on working days only (Monday to Friday);
6
+ # payouts do not take place on weekends.
5
7
  class ScheduleFrequencyDaily < ScheduleRequest
6
8
  def initialize
7
9
  super(ScheduleFrequencyType::DAILY)
@@ -3,7 +3,9 @@
3
3
  module CheckoutSdk
4
4
  module Accounts
5
5
  # @!attribute by_month_day
6
- # @return [Array(Integer)]
6
+ # @return [Array(Integer)] The day or days of the month the payout should take place.
7
+ # For SaaS sellers (ISV), only the following combinations are supported, in any order:
8
+ # [1], [15], [1, 15] or [1, 16].
7
9
  class ScheduleFrequencyMonthly < ScheduleRequest
8
10
  attr_accessor :by_month_day
9
11
 
@@ -3,7 +3,9 @@
3
3
  module CheckoutSdk
4
4
  module Accounts
5
5
  # @!attribute by_day
6
- # @return [Array(String)]
6
+ # @return [Array(String)] The day or days of the week the payout should take place.
7
+ # For SaaS sellers (ISV), only working days (Monday to Friday) are supported;
8
+ # payouts set to take place on weekends are rejected.
7
9
  class ScheduleFrequencyWeekly < ScheduleRequest
8
10
  attr_accessor :by_day
9
11
 
@@ -6,11 +6,22 @@ module CheckoutSdk
6
6
  # @return [TrueClass, FalseClass]
7
7
  # @!attribute threshold
8
8
  # @return [TrueClass, FalseClass]
9
+ # @!attribute balance_minimum
10
+ # @return [Integer] The amount, in the minor units of the schedule's currency, to retain in the
11
+ # sub-entity's available balance. SaaS sellers (ISV) only. Defaults to 0 if you do not set it.
12
+ # @!attribute carry_forward_enabled
13
+ # @return [TrueClass, FalseClass] Indicates whether to carry forward any balance below the configured
14
+ # minimum to the next payout. SaaS sellers (ISV) only. Defaults to false if you do not set it.
15
+ # @!attribute payment_instrument_id
16
+ # @return [String] The ID of the platforms payment instrument used as the payout destination.
9
17
  # @!attribute recurrence
10
18
  # @return [ScheduleRequest]
11
19
  class UpdateSchedule
12
20
  attr_accessor :enabled,
13
21
  :threshold,
22
+ :balance_minimum,
23
+ :carry_forward_enabled,
24
+ :payment_instrument_id,
14
25
  :recurrence
15
26
  end
16
27
  end
@@ -42,15 +42,8 @@ module CheckoutSdk
42
42
  def build
43
43
  super
44
44
 
45
- # Determine authorization URI following Go logic
46
- auth_uri = authorization_uri
47
- if auth_uri.nil? || auth_uri.empty?
48
- auth_uri = if environment_subdomain
49
- environment_subdomain.authorization_uri
50
- else
51
- environment.authorization_uri
52
- end
53
- end
45
+ env_subdomain = environment_subdomain
46
+ auth_uri = resolve_authorization_uri(env_subdomain)
54
47
 
55
48
  configuration = CheckoutConfiguration.new(
56
49
  OAuthSdkCredentials.new(client_id,
@@ -66,9 +59,29 @@ module CheckoutSdk
66
59
  logger
67
60
  )
68
61
 
69
- configuration.environment_subdomain = environment_subdomain if environment_subdomain
62
+ configuration.environment_subdomain = env_subdomain if env_subdomain
70
63
 
71
64
  CheckoutApi.new(configuration)
72
65
  end
66
+
67
+ private
68
+
69
+ # @param [EnvironmentSubdomain, nil] env_subdomain
70
+ # @return [String]
71
+ def resolve_authorization_uri(env_subdomain)
72
+ auth_uri = authorization_uri
73
+ explicit_uri_set = !(auth_uri.nil? || auth_uri.empty?)
74
+
75
+ if explicit_uri_set && env_subdomain
76
+ raise CheckoutArgumentException,
77
+ 'authorization_uri and environment_subdomain cannot both be set - the token ' \
78
+ 'endpoint is derived from your subdomain; combine authorization_uri with ' \
79
+ 'with_legacy_domain if you need a custom token host'
80
+ end
81
+
82
+ return auth_uri if explicit_uri_set
83
+
84
+ env_subdomain ? env_subdomain.authorization_uri : environment.authorization_uri
85
+ end
73
86
  end
74
87
  end
@@ -19,7 +19,8 @@ module CheckoutSdk
19
19
  logger
20
20
  )
21
21
 
22
- configuration.environment_subdomain = environment_subdomain if environment_subdomain
22
+ env_subdomain = environment_subdomain
23
+ configuration.environment_subdomain = env_subdomain if env_subdomain
23
24
 
24
25
  CheckoutApi.new(configuration)
25
26
  end
@@ -23,36 +23,35 @@ module CheckoutSdk
23
23
 
24
24
  private
25
25
 
26
- # Applies subdomain transformation to any given URI.
27
- # If the subdomain is valid (alphanumeric pattern), prepends it to the host.
28
- # Otherwise, returns the original URI unchanged.
26
+ # Applies subdomain transformation to any given URI, prepending the subdomain to the host.
29
27
  #
30
28
  # @param original_url [String] The original URL to transform.
31
29
  # @param subdomain [String] The subdomain to prepend to the host.
32
- # @return [String] The transformed URL with subdomain, or original URL if subdomain is invalid.
30
+ # @return [String] The transformed URL with subdomain.
31
+ # @raise [CheckoutArgumentException] If the subdomain is not a valid merchant-specific
32
+ # subdomain.
33
33
  def create_url_with_subdomain(original_url, subdomain)
34
- new_environment = original_url
35
-
36
- if subdomain =~ /^(?:pl-)?[a-z0-9]+$/
37
- url_parts = URI.parse(original_url)
38
- new_host = "#{subdomain}.#{url_parts.host}"
39
-
40
- port = url_parts.scheme == 'https' && url_parts.port == 443 ? nil : url_parts.port
34
+ unless subdomain =~ /\A(?:pl-)?[a-z0-9]+\z/
35
+ raise CheckoutArgumentException,
36
+ 'invalid environment subdomain - provide your merchant-specific subdomain, ' \
37
+ 'typically your client ID excluding the cli_ prefix (see ' \
38
+ 'https://api-reference.checkout.com/#section/Base-URLs)'
39
+ end
41
40
 
42
- new_url_parts = URI::Generic.build(
43
- scheme: url_parts.scheme,
44
- userinfo: url_parts.userinfo,
45
- host: new_host,
46
- port: port,
47
- path: url_parts.path,
48
- query: url_parts.query,
49
- fragment: url_parts.fragment
50
- )
41
+ url_parts = URI.parse(original_url)
42
+ new_host = "#{subdomain}.#{url_parts.host}"
51
43
 
52
- new_environment = new_url_parts.to_s
53
- end
44
+ port = url_parts.scheme == 'https' && url_parts.port == 443 ? nil : url_parts.port
54
45
 
55
- new_environment
46
+ URI::Generic.build(
47
+ scheme: url_parts.scheme,
48
+ userinfo: url_parts.userinfo,
49
+ host: new_host,
50
+ port: port,
51
+ path: url_parts.path,
52
+ query: url_parts.query,
53
+ fragment: url_parts.fragment
54
+ ).to_s
56
55
  end
57
56
  end
58
57
  end
@@ -2,12 +2,16 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  module Payments
5
+ # @!attribute amount
6
+ # @return [Integer] the amount to void, min 0, max 9999999999.
7
+ # If not specified, the full payment amount is voided.
5
8
  # @!attribute reference
6
9
  # @return [String]
7
10
  # @!attribute metadata
8
11
  # @return [Hash{String => Object}]
9
12
  class VoidRequest
10
- attr_accessor :reference,
13
+ attr_accessor :amount,
14
+ :reference,
11
15
  :metadata
12
16
  end
13
17
  end
@@ -7,6 +7,12 @@ module CheckoutSdk
7
7
  PUBLIC_KEY_PATTERN = '^pk_(test_)?(\\w{8})-(\\w{4})-(\\w{4})-(\\w{4})-(\\w{12})$'
8
8
  private_constant :SECRET_KEY_PATTERN, :PUBLIC_KEY_PATTERN
9
9
 
10
+ # The Previous (ABC) platform predates merchant-specific subdomains, so it is exempt from
11
+ # the mandatory with_environment_subdomain/with_legacy_domain configuration.
12
+ def requires_environment_subdomain?
13
+ false
14
+ end
15
+
10
16
  def build
11
17
  @secret_key_pattern = SECRET_KEY_PATTERN
12
18
  @public_key_pattern = PUBLIC_KEY_PATTERN
@@ -19,7 +25,8 @@ module CheckoutSdk
19
25
  logger
20
26
  )
21
27
 
22
- configuration.environment_subdomain = environment_subdomain if environment_subdomain
28
+ env_subdomain = environment_subdomain
29
+ configuration.environment_subdomain = env_subdomain if env_subdomain
23
30
 
24
31
  CheckoutApi.new(configuration)
25
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CheckoutSdk
4
- VERSION = '1.12.0'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkout_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Checkout
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-19 00:00:00.000000000 Z
11
+ date: 2026-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake