checkout_sdk 1.12.0 → 2.1.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -1
  3. data/lib/checkout_sdk/abstract_checkout_sdk_builder.rb +55 -4
  4. data/lib/checkout_sdk/accounts/schedule_frequency_daily.rb +2 -0
  5. data/lib/checkout_sdk/accounts/schedule_frequency_monthly.rb +3 -1
  6. data/lib/checkout_sdk/accounts/schedule_frequency_weekly.rb +3 -1
  7. data/lib/checkout_sdk/accounts/update_schedule.rb +11 -0
  8. data/lib/checkout_sdk/apm/apm.rb +5 -0
  9. data/lib/checkout_sdk/apm/bacs/bacs_client.rb +29 -0
  10. data/lib/checkout_sdk/apm/bacs/bacs_notification_request.rb +52 -0
  11. data/lib/checkout_sdk/apm/bacs/bacs_notification_type.rb +10 -0
  12. data/lib/checkout_sdk/checkout_api.rb +4 -0
  13. data/lib/checkout_sdk/checkout_oauth_sdk_builder.rb +23 -10
  14. data/lib/checkout_sdk/checkout_static_keys_sdk_builder.rb +2 -1
  15. data/lib/checkout_sdk/common/account_holder_type.rb +16 -0
  16. data/lib/checkout_sdk/common/customer_request.rb +15 -3
  17. data/lib/checkout_sdk/common/instrument_type.rb +8 -0
  18. data/lib/checkout_sdk/common/payment_source_type.rb +19 -0
  19. data/lib/checkout_sdk/environment_subdomain.rb +22 -23
  20. data/lib/checkout_sdk/instruments/ach_account_type.rb +14 -0
  21. data/lib/checkout_sdk/instruments/bacs_payment_type.rb +15 -0
  22. data/lib/checkout_sdk/instruments/create/create_ach_account_holder.rb +29 -0
  23. data/lib/checkout_sdk/instruments/create/create_ach_instrument_data.rb +30 -0
  24. data/lib/checkout_sdk/instruments/create/create_bacs_account_holder.rb +24 -0
  25. data/lib/checkout_sdk/instruments/create/create_bacs_billing_address.rb +30 -0
  26. data/lib/checkout_sdk/instruments/create/create_bacs_instrument_account.rb +14 -0
  27. data/lib/checkout_sdk/instruments/create/create_bacs_instrument_data.rb +36 -0
  28. data/lib/checkout_sdk/instruments/create/create_sepa_account_holder.rb +28 -0
  29. data/lib/checkout_sdk/instruments/create/create_sepa_billing_address.rb +31 -0
  30. data/lib/checkout_sdk/instruments/create/create_sepa_instrument_data.rb +40 -0
  31. data/lib/checkout_sdk/instruments/create/instrument_ach.rb +25 -0
  32. data/lib/checkout_sdk/instruments/create/instrument_bacs.rb +29 -0
  33. data/lib/checkout_sdk/instruments/create/instrument_sepa.rb +9 -3
  34. data/lib/checkout_sdk/instruments/get/payment_network.rb +8 -4
  35. data/lib/checkout_sdk/instruments/instrument_account_holder_type.rb +14 -0
  36. data/lib/checkout_sdk/instruments/instruments.rb +28 -1
  37. data/lib/checkout_sdk/instruments/sepa_mandate_type.rb +11 -0
  38. data/lib/checkout_sdk/instruments/sepa_payment_type.rb +15 -0
  39. data/lib/checkout_sdk/instruments/update/update_ach_account_holder.rb +28 -0
  40. data/lib/checkout_sdk/instruments/update/update_ach_instrument_data.rb +32 -0
  41. data/lib/checkout_sdk/instruments/update/update_bacs_account_holder.rb +31 -0
  42. data/lib/checkout_sdk/instruments/update/update_bacs_billing_address.rb +30 -0
  43. data/lib/checkout_sdk/instruments/update/update_bacs_instrument_data.rb +36 -0
  44. data/lib/checkout_sdk/instruments/update/update_instrument_ach.rb +21 -0
  45. data/lib/checkout_sdk/instruments/update/update_instrument_bacs.rb +21 -0
  46. data/lib/checkout_sdk/instruments/update/update_instrument_sepa.rb +20 -0
  47. data/lib/checkout_sdk/instruments/update/update_sepa_account_holder.rb +31 -0
  48. data/lib/checkout_sdk/instruments/update/update_sepa_billing_address.rb +31 -0
  49. data/lib/checkout_sdk/instruments/update/update_sepa_instrument_data.rb +43 -0
  50. data/lib/checkout_sdk/payments/payments.rb +19 -0
  51. data/lib/checkout_sdk/payments/source/apm/ach_source.rb +16 -5
  52. data/lib/checkout_sdk/payments/source/apm/ach_source_account_holder.rb +45 -0
  53. data/lib/checkout_sdk/payments/source/apm/ach_source_account_type.rb +22 -0
  54. data/lib/checkout_sdk/payments/source/apm/alipay_cn_source.rb +14 -0
  55. data/lib/checkout_sdk/payments/source/apm/alipay_hk_source.rb +14 -0
  56. data/lib/checkout_sdk/payments/source/apm/alipay_plus_source.rb +9 -0
  57. data/lib/checkout_sdk/payments/source/apm/bacs_source.rb +18 -0
  58. data/lib/checkout_sdk/payments/source/apm/dana_source.rb +14 -0
  59. data/lib/checkout_sdk/payments/source/apm/gcash_source.rb +14 -0
  60. data/lib/checkout_sdk/payments/source/apm/kakaopay_source.rb +14 -0
  61. data/lib/checkout_sdk/payments/source/apm/mobile_pay_source.rb +14 -0
  62. data/lib/checkout_sdk/payments/source/apm/pay_now_source.rb +14 -0
  63. data/lib/checkout_sdk/payments/source/apm/sepa_source.rb +28 -11
  64. data/lib/checkout_sdk/payments/source/apm/sepa_source_account_holder.rb +37 -0
  65. data/lib/checkout_sdk/payments/source/apm/sepa_source_billing_address.rb +31 -0
  66. data/lib/checkout_sdk/payments/source/apm/swish_account_holder.rb +18 -0
  67. data/lib/checkout_sdk/payments/source/apm/swish_billing_descriptor.rb +14 -0
  68. data/lib/checkout_sdk/payments/source/apm/swish_source.rb +29 -0
  69. data/lib/checkout_sdk/payments/source/apm/tng_source.rb +14 -0
  70. data/lib/checkout_sdk/payments/source/apm/truemoney_source.rb +14 -0
  71. data/lib/checkout_sdk/payments/source/apm/twint_source.rb +14 -0
  72. data/lib/checkout_sdk/payments/source/apm/vipps_source.rb +14 -0
  73. data/lib/checkout_sdk/payments/void_request.rb +5 -1
  74. data/lib/checkout_sdk/previous/checkout_previous_static_keys_sdk_builder.rb +8 -1
  75. data/lib/checkout_sdk/version.rb +1 -1
  76. metadata +51 -3
  77. data/lib/checkout_sdk/instruments/create/instrument_data.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c26660018aea61f28d8d1e742c57948b6ebadadb0440e245ca45eb14d53eede
4
- data.tar.gz: 3192d546b4240013ac01de9de0411f6654a974e465e285529f36d3df666f345c
3
+ metadata.gz: d496e04f8a60b750fdd7a6bc7c9f8bde76ee833c436b706523066e18d71d2fc7
4
+ data.tar.gz: 8be2c185284697143ff7caf40146ffb1e068ba507ad1ab9acc8a87f06411731d
5
5
  SHA512:
6
- metadata.gz: 1791fa5f04fe3a5628e4804312fc778ff407398f657e47c1b51e85844251e4e28f81d88593a994b0318212fc016eb42f392f6de2612dc856aad55430783e7558
7
- data.tar.gz: cf4e630a4fd64a029bae0238c0e32bbdb0ab1a4576324fe31a7d09e74bfd54842440baf2725837527118d78d0b2a36b100f2051701c5fa50926c31bae4250c88
6
+ metadata.gz: 6bdd1474da6e0172ab1a935756b9bee04d7f533ae60107332337b9ee1ef98623af15474d3f52f228065515397c280bfebdc5f3eff1bec62c9859eb7e38ccc7ff
7
+ data.tar.gz: e37204701650121c179389ec329d96f6cc42b6e55334a5852ea0806543a9774377fa4efcad67b11d159fb29cf62fa895d2868b64308a22a72b332354096ff35b
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
@@ -9,3 +9,8 @@ require 'checkout_sdk/apm/previous/klarna/order_capture_request'
9
9
  require 'checkout_sdk/apm/previous/klarna/klarna_client'
10
10
  require 'checkout_sdk/apm/previous/sepa/sepa_client'
11
11
  require 'checkout_sdk/apm/ideal/ideal_client'
12
+
13
+ # Bacs
14
+ require 'checkout_sdk/apm/bacs/bacs_notification_type'
15
+ require 'checkout_sdk/apm/bacs/bacs_notification_request'
16
+ require 'checkout_sdk/apm/bacs/bacs_client'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Apm
5
+ # Bacs Direct Debit client.
6
+ class BacsClient < Client
7
+ APMS = 'apms'
8
+ BACS_NOTIFICATIONS = 'bacs/notifications'
9
+ private_constant :APMS, :BACS_NOTIFICATIONS
10
+
11
+ # @param [ApiClient] api_client
12
+ # @param [CheckoutConfiguration] configuration
13
+ def initialize(api_client, configuration)
14
+ super(api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY)
15
+ end
16
+
17
+ # Sends a Bacs Direct Debit pre-notification (advance notice) to a payer ahead
18
+ # of collecting funds from their account.
19
+ #
20
+ # @param [Hash, BacsNotificationRequest] bacs_notification_request
21
+ # @return [Hash] the BacsNotificationResponse, carrying event_id.
22
+ def send_notification(bacs_notification_request)
23
+ api_client.invoke_post(build_path(APMS, BACS_NOTIFICATIONS),
24
+ sdk_authorization,
25
+ bacs_notification_request)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Apm
5
+ # Bacs Direct Debit notification request.
6
+ #
7
+ # @!attribute source_id
8
+ # @return [String] The ID of the Bacs Direct Debit instrument to notify
9
+ # against. [Required] Pattern: ^(src)_(\w{26})$
10
+ # @!attribute notification_type
11
+ # @return [String] {BacsNotificationType} The type of pre-notification being
12
+ # sent to the payer. [Required]
13
+ # @!attribute collection_date
14
+ # @return [String] The date the funds will be collected from the payer's
15
+ # account, in the format yyyy-MM-dd. [Required]
16
+ # Format: date - pass a yyyy-MM-dd String, not a DateTime.
17
+ # @!attribute amount
18
+ # @return [Integer] The amount to be collected, in the currency's minor unit.
19
+ # [Required] min 1
20
+ # @!attribute currency
21
+ # @return [String] {CheckoutSdk::Common::Currency} The three-letter ISO 4217
22
+ # currency code of the collection. [Required] min 3 characters,
23
+ # max 3 characters.
24
+ # @!attribute billing_descriptor
25
+ # @return [String] The billing descriptor that appears on the payer's bank
26
+ # statement. [Required] max 25 characters.
27
+ # @!attribute customer_email
28
+ # @return [String] The email address of the payer that the pre-notification is
29
+ # sent to. [Required] Format: email
30
+ # @!attribute support_email
31
+ # @return [String] The support email address included in the pre-notification.
32
+ # [Required] Format: email
33
+ # @!attribute reference
34
+ # @return [String] A reference you can use to identify the collection.
35
+ # [Optional] max 50 characters.
36
+ # @!attribute support_phone
37
+ # @return [String] The support phone number included in the pre-notification,
38
+ # in E.164 format. [Optional]
39
+ class BacsNotificationRequest
40
+ attr_accessor :source_id,
41
+ :notification_type,
42
+ :collection_date,
43
+ :amount,
44
+ :currency,
45
+ :billing_descriptor,
46
+ :customer_email,
47
+ :support_email,
48
+ :reference,
49
+ :support_phone
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Apm
5
+ # The type of pre-notification being sent to the payer.
6
+ module BacsNotificationType
7
+ ADVANCE_NOTICE = 'advance_notice'
8
+ end
9
+ end
10
+ end
@@ -73,6 +73,8 @@ module CheckoutSdk
73
73
  # @return [CheckoutSdk::Identities::IdentityVerification::IdentityVerificationClient]
74
74
  # @!attribute face_authentication
75
75
  # @return [CheckoutSdk::Identities::FaceAuthentication::FaceAuthenticationClient]
76
+ # @!attribute bacs
77
+ # @return [CheckoutSdk::Apm::BacsClient]
76
78
  # @!attribute apple_pay
77
79
  # @return [CheckoutSdk::Payments::ApplePayClient]
78
80
  # @!attribute google_pay
@@ -91,6 +93,7 @@ module CheckoutSdk
91
93
  :sessions,
92
94
  :tokens,
93
95
  :ideal,
96
+ :bacs,
94
97
  :accounts,
95
98
  :workflows,
96
99
  :risk,
@@ -131,6 +134,7 @@ module CheckoutSdk
131
134
  @sessions = CheckoutSdk::Sessions::SessionsClient.new api_client, configuration
132
135
  @tokens = CheckoutSdk::Tokens::TokensClient.new api_client, configuration
133
136
  @ideal = CheckoutSdk::Apm::IdealClient.new api_client, configuration
137
+ @bacs = CheckoutSdk::Apm::BacsClient.new api_client, configuration
134
138
  @workflows = CheckoutSdk::Workflows::WorkflowsClient.new api_client, configuration
135
139
  @accounts = CheckoutSdk::Accounts::AccountsClient.new(api_client, files_client(configuration), configuration)
136
140
  @risk = CheckoutSdk::Risk::RiskClient.new api_client, configuration
@@ -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
@@ -2,9 +2,25 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  module Common
5
+ # The type of account holder.
6
+ #
7
+ # For stored instruments use {CheckoutSdk::Instruments::InstrumentAccountHolderType},
8
+ # whose schemas declare individual and corporate only.
5
9
  module AccountHolderType
6
10
  INDIVIDUAL = 'individual'
7
11
  CORPORATE = 'corporate'
12
+
13
+ # Declared by the account-holder positions (AccountHolder, AccountHolderAch,
14
+ # PaymentSetupAccountHolder, RefundDestinationAccountHolder and the card-payout
15
+ # destination and sender) but **not** by any sender schema -
16
+ # PaymentRequestSender, PayoutSender, PaymentDetailsResponseSender and
17
+ # PaymentInterfacesSender all omit it. Do not send it as a sender type.
18
+ GOVERNMENT = 'government'
19
+
20
+ # Declared only by the payment and payout *sender* schemas
21
+ # (PaymentRequestSender, PayoutSender, PaymentDetailsResponseSender), never by
22
+ # an account-holder position. Retained rather than removed because removal is
23
+ # breaking; prefer the sender-specific type where one exists.
8
24
  INSTRUMENT = 'instrument'
9
25
  end
10
26
  end
@@ -2,18 +2,30 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  module Common
5
+ # The customer's details.
6
+ #
7
+ # This type serves two positions with different property sets. The payments
8
+ # position (swagger `CustomerRequest`) declares all six properties below. The
9
+ # instrument position (swagger `StoreCustomerInstrumentRequest`, used by
10
+ # {CheckoutSdk::Instruments::InstrumentBacs}, {CheckoutSdk::Instruments::InstrumentSepa}
11
+ # and {CheckoutSdk::Instruments::InstrumentAch}) declares every property except
12
+ # tax_number - do not send tax_number when storing an instrument.
13
+ #
5
14
  # @!attribute id
6
15
  # @return [String]
7
16
  # @!attribute email
8
17
  # @return [String]
9
18
  # @!attribute name
10
- # @return [String]
19
+ # @return [String] Only sets the name for *new* customers.
11
20
  # @!attribute tax_number
12
- # @return [String]
21
+ # @return [String] Payments position only. Not declared by
22
+ # StoreCustomerInstrumentRequest.
13
23
  # @!attribute phone
14
24
  # @return [Phone]
15
25
  # @!attribute default
16
- # @return [TrueClass, FalseClass]
26
+ # @return [TrueClass, FalseClass] If true, this instrument becomes the default
27
+ # for the customer. An instrument is automatically the default when the
28
+ # request creates a new customer.
17
29
  class CustomerRequest
18
30
  attr_accessor :id,
19
31
  :email,
@@ -2,11 +2,19 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  module Common
5
+ # The type of a payment instrument.
5
6
  module InstrumentType
6
7
  BANK_ACCOUNT = 'bank_account'
7
8
  TOKEN = 'token'
8
9
  CARD = 'card'
9
10
  SEPA = 'sepa'
11
+
12
+ # Current API (NAS) only. The previous API (ABC) instrument schemas declare
13
+ # neither of these, so do not use them with a previous-platform client.
14
+ ACH = 'ach'
15
+ BACS = 'bacs'
16
+
17
+ # Previous API (ABC) only. Not declared by any current-API instrument schema.
10
18
  CARD_TOKEN = 'card_token'
11
19
  end
12
20
  end
@@ -2,6 +2,19 @@
2
2
 
3
3
  module CheckoutSdk
4
4
  module Common
5
+ # The type of a payment source or destination.
6
+ #
7
+ # This module is shared by the current API (NAS) and the previous API (ABC),
8
+ # which is still actively maintained. These 22 values are declared by neither
9
+ # `PaymentRequestSourceType` nor `PaymentDetailsResponseSourceType` in the
10
+ # current specification and are **previous API (ABC) only**:
11
+ #
12
+ # afterpay, alipay, applepay, baloto, bank_account, benefit, benefitpay,
13
+ # boleto, cvconnect, dlocal, giropay, googlepay, illicado, oxxo, pagofacil,
14
+ # poli, postfinance, provider_token, rapipago, sofort, tabby, trustly
15
+ #
16
+ # Use them only with a previous-platform client. Every other value below is
17
+ # current-API.
5
18
  module PaymentSourceType
6
19
  CARD = 'card'
7
20
  ID = 'id'
@@ -54,10 +67,16 @@ module CheckoutSdk
54
67
  ILLICADO = 'illicado'
55
68
  SEPA = 'sepa'
56
69
  ACH = 'ach'
70
+ BACS = 'bacs'
57
71
  BIZUM = 'bizum'
58
72
  OCTOPUS = 'octopus'
59
73
  PLAID = 'plaid'
60
74
  SEQURA = 'sequra'
75
+ MOBILEPAY = 'mobilepay'
76
+ PAYNOW = 'paynow'
77
+ SWISH = 'swish'
78
+ TWINT = 'twint'
79
+ VIPPS = 'vipps'
61
80
  TABBY = 'tabby'
62
81
  APPLEPAY = 'applepay'
63
82
  GOOGLEPAY = 'googlepay'
@@ -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
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Instruments
5
+ # The type of Direct Debit account on an ACH instrument.
6
+ #
7
+ # The ACH instrument schemas declare savings and checking only. The ACH payment
8
+ # source additionally declares cash - see {CheckoutSdk::Common::AccountType}.
9
+ module AchAccountType
10
+ SAVINGS = 'savings'
11
+ CHECKING = 'checking'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Instruments
5
+ # The type of payment on a Bacs Direct Debit instrument.
6
+ #
7
+ # Declared capitalized by the Bacs instrument schemas, unlike {SepaPaymentType}
8
+ # which declares the same two concepts lowercase. The casing is not
9
+ # interchangeable and must not be unified.
10
+ module BacsPaymentType
11
+ RECURRING = 'Recurring'
12
+ REGULAR = 'Regular'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Instruments
5
+ # The account holder details of an ACH instrument being stored.
6
+ #
7
+ # The specification lists all four properties in the schema's required array,
8
+ # while the individual field descriptions make them conditional on type
9
+ # ("Required for individual account holder type" / "Required for corporate
10
+ # account holder type"). The two readings contradict each other; send the pair
11
+ # that matches your type value.
12
+ #
13
+ # @!attribute first_name
14
+ # @return [String] First name. Required for individual account holder type.
15
+ # @!attribute last_name
16
+ # @return [String] Last name. Required for individual account holder type.
17
+ # @!attribute company_name
18
+ # @return [String] Company name. Required for corporate account holder type.
19
+ # @!attribute type
20
+ # @return [String] {InstrumentAccountHolderType} Account holder type.
21
+ # [Required]
22
+ class CreateAchAccountHolder
23
+ attr_accessor :first_name,
24
+ :last_name,
25
+ :company_name,
26
+ :type
27
+ end
28
+ end
29
+ end