checkout_sdk 1.1.8 → 1.2.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: 622d9d100ea4bacc079b7004c68eed945ab997058b6cb5df0e3dcfb844828a3f
4
- data.tar.gz: 89097b31f1189afbb501c68241818fe5e2beeac6daa746bac3e9ca5994a4d57c
3
+ metadata.gz: 14e68356d1de167bcf9ba9c5370aaf6ac81804e1b844474f6c2c573cdc41e96b
4
+ data.tar.gz: 8061066149def7f8b6288c94cbc6d2362ac4528b2741759dca3d1ad254160637
5
5
  SHA512:
6
- metadata.gz: fe4eff9e638233a09803894c6fd31b1a4b58ecd70c4a5fba9c32a6c6fc3e1b495fae0ee453435b9d224ebb92ab659bba6e321cb63620d45ea6d3f9aaeaf8cf8e
7
- data.tar.gz: 1247b228c521fc41105f2da0c3803911dd3f6c0e866b380150615d44d4b12798ca3170b1b7c04950c8e851948aab0d46d0072f95e963fb197dac684c1531e2bf
6
+ metadata.gz: 33cad8c67ad6c941526a6edd897800d975a431da83ca6c0c661181b80943cd63bb417242ee581c523fc1225ae635cc8a0644521c0dfb5f9bc95b3ad78479a9bf
7
+ data.tar.gz: e707e11a320e4db4c3612643120a283b8b58de2ddc13b54999cf6ce7d155fc8441d6f584bb03e23f699801f14e413c292c6bc7af62fb542a0809349f4e673d68
@@ -8,7 +8,9 @@ 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, :logger
11
+ # @!attribute environment_subdomain
12
+ # @return [EnvironmentSubdomain, nil]
13
+ attr_accessor :environment, :http_client, :multipart_http_client, :logger, :environment_subdomain
12
14
 
13
15
  # @param [Environment] environment
14
16
  def with_environment(environment)
@@ -33,6 +35,12 @@ module CheckoutSdk
33
35
  self
34
36
  end
35
37
 
38
+ # @param [String, nil] subdomain
39
+ def with_environment_subdomain(subdomain)
40
+ @environment_subdomain = EnvironmentSubdomain.new(@environment, subdomain)
41
+ self
42
+ end
43
+
36
44
  def build
37
45
  with_environment(Environment.sandbox) if environment.nil?
38
46
  if http_client.nil?
@@ -97,7 +97,12 @@ module CheckoutSdk
97
97
  # @param [CheckoutConfiguration] configuration
98
98
  # @return [ApiClient]
99
99
  def base_api_client(configuration)
100
- ApiClient.new(configuration, configuration.environment.base_uri)
100
+ base_uri = configuration.environment.base_uri
101
+ subdomain = configuration.environment_subdomain
102
+
103
+ base_uri = subdomain.base_uri if subdomain&.base_uri
104
+
105
+ ApiClient.new(configuration, base_uri)
101
106
  end
102
107
 
103
108
  # @param [CheckoutConfiguration] configuration
@@ -7,19 +7,30 @@ module CheckoutSdk
7
7
  # @return [Environment]
8
8
  # @!attribute http_client
9
9
  # @return [Faraday::Connection]
10
+ # @!attribute multipart_http_client
11
+ # @return [Faraday::Connection]
12
+ # @!attribute logger
13
+ # @return [Logger]
14
+ # @!attribute environment_subdomain
15
+ # @return [EnvironmentSubdomain, nil]
10
16
  class CheckoutConfiguration
11
- attr_accessor :credentials, :environment, :http_client, :multipart_http_client, :logger
17
+ attr_accessor :credentials, :environment, :http_client, :multipart_http_client, :logger, :environment_subdomain
12
18
 
19
+ # Initializes the CheckoutConfiguration.
20
+ #
13
21
  # @param [SdkCredentials] credentials
14
22
  # @param [Environment] environment
15
23
  # @param [Faraday::Connection] http_client
16
24
  # @param [Faraday::Connection] multipart_http_client
17
- def initialize(credentials, environment, http_client, multipart_http_client, logger)
25
+ # @param [Logger] logger
26
+ # @param [EnvironmentSubdomain, nil] environment_subdomain (optional, default: nil)
27
+ def initialize(credentials, environment, http_client, multipart_http_client, logger, environment_subdomain = nil)
18
28
  @credentials = credentials
19
29
  @environment = environment
20
30
  @http_client = http_client
21
31
  @multipart_http_client = multipart_http_client
22
32
  @logger = logger
33
+ @environment_subdomain = environment_subdomain
23
34
  end
24
35
  end
25
36
  end
@@ -41,21 +41,23 @@ module CheckoutSdk
41
41
  # @return [CheckoutSdk::CheckoutApi]
42
42
  def build
43
43
  super
44
- CheckoutSdk::CheckoutApi.new(
45
- CheckoutConfiguration.new(
46
- OAuthSdkCredentials.new(client_id,
47
- client_secret,
48
- scopes,
49
- http_client,
50
- environment,
51
- logger,
52
- authorization_uri),
53
- environment,
54
- http_client,
55
- multipart_http_client,
56
- logger
57
- )
44
+ configuration = CheckoutConfiguration.new(
45
+ OAuthSdkCredentials.new(client_id,
46
+ client_secret,
47
+ scopes,
48
+ http_client,
49
+ environment,
50
+ logger,
51
+ authorization_uri),
52
+ environment,
53
+ http_client,
54
+ multipart_http_client,
55
+ logger
58
56
  )
57
+
58
+ configuration.environment_subdomain = environment_subdomain if environment_subdomain
59
+
60
+ CheckoutApi.new(configuration)
59
61
  end
60
62
  end
61
63
  end
@@ -11,15 +11,17 @@ module CheckoutSdk
11
11
  @secret_key_pattern = SECRET_KEY_PATTERN
12
12
  @public_key_pattern = PUBLIC_KEY_PATTERN
13
13
  super
14
- CheckoutApi.new(
15
- CheckoutConfiguration.new(
16
- StaticKeysSdkCredentials.new(secret_key, public_key),
17
- environment,
18
- http_client,
19
- multipart_http_client,
20
- logger
21
- )
14
+ configuration = CheckoutConfiguration.new(
15
+ StaticKeysSdkCredentials.new(secret_key, public_key),
16
+ environment,
17
+ http_client,
18
+ multipart_http_client,
19
+ logger
22
20
  )
21
+
22
+ configuration.environment_subdomain = environment_subdomain if environment_subdomain
23
+
24
+ CheckoutApi.new(configuration)
23
25
  end
24
26
  end
25
27
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ # @!attribute environment
5
+ # @return [Environment]
6
+ # @!attribute subdomain
7
+ # @return [String]
8
+ class EnvironmentSubdomain
9
+ attr_reader :base_uri, :environment, :subdomain
10
+
11
+ # Initializes the EnvironmentSubdomain with the given environment and subdomain.
12
+ #
13
+ # @param environment [Environment] The environment object which should have a base_uri method.
14
+ # @param subdomain [String] The subdomain to add to the environment's API URL.
15
+ def initialize(environment, subdomain)
16
+ @environment = environment
17
+ @subdomain = subdomain
18
+ @base_uri = add_subdomain_to_api_url_environment(environment, subdomain)
19
+ end
20
+
21
+ private
22
+
23
+ # Adds the subdomain to the API URL of the given environment.
24
+ #
25
+ # @param environment [Environment] The environment object which should have a base_uri method.
26
+ # @param subdomain [String] The subdomain to add to the environment's API URL.
27
+ # @return [String] The new environment URL with the subdomain added.
28
+ def add_subdomain_to_api_url_environment(environment, subdomain)
29
+ api_url = environment.base_uri
30
+ new_environment = api_url
31
+
32
+ # Regex to match a subdomain consisting of 8 to 11 lowercase alphanumeric characters
33
+ if subdomain =~ /^[0-9a-z]{8,11}$/
34
+ url_parts = URI.parse(api_url)
35
+ new_host = "#{subdomain}.#{url_parts.host}"
36
+
37
+ port = url_parts.scheme == 'https' && url_parts.port == 443 ? nil : url_parts.port
38
+
39
+ new_url_parts = URI::Generic.build(
40
+ scheme: url_parts.scheme,
41
+ userinfo: url_parts.userinfo,
42
+ host: new_host,
43
+ port: port,
44
+ path: url_parts.path,
45
+ query: url_parts.query,
46
+ fragment: url_parts.fragment
47
+ )
48
+
49
+ new_environment = new_url_parts.to_s
50
+ end
51
+
52
+ new_environment
53
+ end
54
+ end
55
+ end
@@ -41,6 +41,16 @@ module CheckoutSdk
41
41
  void_request,
42
42
  idempotency_key)
43
43
  end
44
+
45
+ # @param [String] payment_id
46
+ # @param [Hash, ReverseRequest] reverse_request
47
+ # @param [String, nil] idempotency_key
48
+ def reverse_payment(payment_id, reverse_request = nil, idempotency_key = nil)
49
+ api_client.invoke_post(build_path(PAYMENTS_PATH, payment_id, 'reversals'),
50
+ sdk_authorization,
51
+ reverse_request,
52
+ idempotency_key)
53
+ end
44
54
  end
45
55
  end
46
56
  end
@@ -161,3 +161,8 @@ require 'checkout_sdk/payments/contexts/payment_contexts_client'
161
161
 
162
162
  # Payment Sessions
163
163
  require 'checkout_sdk/payments/sessions/payment_sessions_client'
164
+ require 'checkout_sdk/payments/sessions/payment_sessions_request'
165
+ require 'checkout_sdk/payments/sessions/payment_methods_type'
166
+ require 'checkout_sdk/payments/sessions/payment_method_configuration'
167
+ require 'checkout_sdk/payments/sessions/card'
168
+ require 'checkout_sdk/payments/sessions/store_payment_details_type'
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Payments
5
+ # @!attribute reference
6
+ # @return [String]
7
+ # @!attribute metadata
8
+ # @return [Hash{String => Object}]
9
+ class ReverseRequest
10
+ attr_accessor :reference,
11
+ :metadata
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Payments
5
+ # @!attribute store_payment_details
6
+ # @return [String] {StorePaymentDetailsType}
7
+ class Card
8
+ attr_accessor :store_payment_details
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Payments
5
+ # @!attribute card
6
+ # @return [Card]
7
+ class PaymentMethodConfiguration
8
+ attr_accessor :card
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Payments
5
+ module PaymentMethodsType
6
+ APPLEPAY = 'applepay'
7
+ BANCONTACT = 'bancontact'
8
+ CARD = 'card'
9
+ EPS = 'eps'
10
+ GIROPAY = 'giropay'
11
+ GOOGLEPAY = 'googlepay'
12
+ IDEAL = 'ideal'
13
+ KNET = 'knet'
14
+ MULTIBANCO = 'multibanco'
15
+ PRZELEWY24 = 'p24'
16
+ PAYPAL = 'paypal'
17
+ SOFORT = 'sofort'
18
+ end
19
+ end
20
+ end
@@ -11,7 +11,7 @@ module CheckoutSdk
11
11
  super api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY
12
12
  end
13
13
 
14
- # @param [Hash] payment_sessions
14
+ # @param [Hash, PaymentSessionsRequest] payment_sessions
15
15
  def create_payment_sessions(payment_sessions)
16
16
  api_client.invoke_post(PAYMENT_SESSIONS, sdk_authorization, payment_sessions)
17
17
  end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Payments
5
+ # @!attribute amount
6
+ # @return [Integer]
7
+ # @!attribute currency
8
+ # @return [String] {CheckoutSdk::Common::Currency}
9
+ # @!attribute payment_type
10
+ # @return [TrueClass, FalseClass]
11
+ # @!attribute billing
12
+ # @return [BillingInformation]
13
+ # @!attribute billing_descriptor
14
+ # @return [BillingDescriptor]
15
+ # @!attribute reference
16
+ # @return [String]
17
+ # @!attribute description
18
+ # @return [String]
19
+ # @!attribute customer
20
+ # @return [CheckoutSdk::Common::CustomerRequest]
21
+ # @!attribute shipping
22
+ # @return [ShippingDetails]
23
+ # @!attribute recipient
24
+ # @return [PaymentRecipient]
25
+ # @!attribute processing
26
+ # @return [ProcessingSettings]
27
+ # @!attribute processing_channel_id
28
+ # @return [String]
29
+ # @!attribute expires_on
30
+ # @return [Time]
31
+ # @!attribute payment_method_configuration
32
+ # @return [PaymentMethodConfiguration]
33
+ # @!attribute enabled_payment_methods
34
+ # @return [Array(PaymentMethodsType)]
35
+ # @!attribute disabled_payment_methods
36
+ # @return [Array(PaymentMethodsType)]
37
+ # @!attribute items
38
+ # @return [Array(Product)]
39
+ # @!attribute amount_allocations
40
+ # @return [Array(CheckoutSdk::Common::AmountAllocations)]
41
+ # @!attribute risk
42
+ # @return [RiskRequest]
43
+ # @!attribute retry
44
+ # @return [PaymentRetryRequest]
45
+ # @!attribute display_name
46
+ # @return [String]
47
+ # @!attribute success_url
48
+ # @return [String]
49
+ # @!attribute failure_url
50
+ # @return [String]
51
+ # @!attribute metadata
52
+ # @return [Hash{String => Object}]
53
+ # @!attribute locale
54
+ # @return [String]
55
+ # @!attribute three_ds
56
+ # @return [ThreeDSRequest]
57
+ # @!attribute sender
58
+ # @return [Sender]
59
+ # @!attribute capture
60
+ # @return [TrueClass, FalseClass]
61
+ # @!attribute ip_address
62
+ # @return [String]
63
+ # @!attribute tax_amount
64
+ # @return [Integer]
65
+ class PaymentSessionsRequest
66
+ attr_accessor :amount,
67
+ :currency,
68
+ :payment_type,
69
+ :billing,
70
+ :billing_descriptor,
71
+ :reference,
72
+ :description,
73
+ :customer,
74
+ :shipping,
75
+ :recipient,
76
+ :processing,
77
+ :processing_channel_id,
78
+ :expires_on,
79
+ :payment_method_configuration,
80
+ :enabled_payment_methods,
81
+ :disabled_payment_methods,
82
+ :items,
83
+ :amount_allocations,
84
+ :risk,
85
+ :retry,
86
+ :display_name,
87
+ :success_url,
88
+ :failure_url,
89
+ :metadata,
90
+ :locale,
91
+ :three_ds,
92
+ :sender,
93
+ :capture,
94
+ :ip_address,
95
+ :tax_amount
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CheckoutSdk
4
+ module Payments
5
+ module StorePaymentDetailsType
6
+ DISABLED = 'disabled'
7
+ ENABLED = 'enabled'
8
+ end
9
+ end
10
+ end
@@ -11,15 +11,17 @@ module CheckoutSdk
11
11
  @secret_key_pattern = SECRET_KEY_PATTERN
12
12
  @public_key_pattern = PUBLIC_KEY_PATTERN
13
13
  super
14
- CheckoutApi.new(
15
- CheckoutConfiguration.new(
16
- PreviousStaticKeysSdkCredentials.new(secret_key, public_key),
17
- environment,
18
- http_client,
19
- multipart_http_client,
20
- logger
21
- )
14
+ configuration = CheckoutConfiguration.new(
15
+ PreviousStaticKeysSdkCredentials.new(secret_key, public_key),
16
+ environment,
17
+ http_client,
18
+ multipart_http_client,
19
+ logger
22
20
  )
21
+
22
+ configuration.environment_subdomain = environment_subdomain if environment_subdomain
23
+
24
+ CheckoutApi.new(configuration)
23
25
  end
24
26
  end
25
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CheckoutSdk
4
- VERSION = '1.1.8'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/checkout_sdk.rb CHANGED
@@ -21,6 +21,7 @@ require 'checkout_sdk/http_metadata'
21
21
  require 'checkout_sdk/checkout_utils'
22
22
  require 'checkout_sdk/platform_type'
23
23
  require 'checkout_sdk/environment'
24
+ require 'checkout_sdk/environment_subdomain'
24
25
  require 'checkout_sdk/sdk_credentials'
25
26
  require 'checkout_sdk/sdk_authorization'
26
27
  require 'checkout_sdk/static_keys_sdk_credentials'
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.1.8
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Checkout
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -220,6 +220,7 @@ files:
220
220
  - lib/checkout_sdk/disputes/disputes_client.rb
221
221
  - lib/checkout_sdk/disputes/disputes_query_filter.rb
222
222
  - lib/checkout_sdk/environment.rb
223
+ - lib/checkout_sdk/environment_subdomain.rb
223
224
  - lib/checkout_sdk/error.rb
224
225
  - lib/checkout_sdk/events/events.rb
225
226
  - lib/checkout_sdk/events/events_client.rb
@@ -352,6 +353,7 @@ files:
352
353
  - lib/checkout_sdk/payments/product.rb
353
354
  - lib/checkout_sdk/payments/product_type.rb
354
355
  - lib/checkout_sdk/payments/refund_request.rb
356
+ - lib/checkout_sdk/payments/reverse_request.rb
355
357
  - lib/checkout_sdk/payments/risk_request.rb
356
358
  - lib/checkout_sdk/payments/sender/corporate_sender.rb
357
359
  - lib/checkout_sdk/payments/sender/government_sender.rb
@@ -362,7 +364,12 @@ files:
362
364
  - lib/checkout_sdk/payments/sender/sender_type.rb
363
365
  - lib/checkout_sdk/payments/sender/source_of_funds.rb
364
366
  - lib/checkout_sdk/payments/sender/ticket.rb
367
+ - lib/checkout_sdk/payments/sessions/card.rb
368
+ - lib/checkout_sdk/payments/sessions/payment_method_configuration.rb
369
+ - lib/checkout_sdk/payments/sessions/payment_methods_type.rb
365
370
  - lib/checkout_sdk/payments/sessions/payment_sessions_client.rb
371
+ - lib/checkout_sdk/payments/sessions/payment_sessions_request.rb
372
+ - lib/checkout_sdk/payments/sessions/store_payment_details_type.rb
366
373
  - lib/checkout_sdk/payments/shipping_details.rb
367
374
  - lib/checkout_sdk/payments/shipping_preference.rb
368
375
  - lib/checkout_sdk/payments/source/apm/after_pay_source.rb