dodopayments 1.47.0 → 1.51.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +17 -51
  4. data/lib/dodopayments/client.rb +4 -4
  5. data/lib/dodopayments/internal/transport/base_client.rb +1 -4
  6. data/lib/dodopayments/internal/transport/pooled_net_requester.rb +1 -9
  7. data/lib/dodopayments/internal/type/base_model.rb +6 -11
  8. data/lib/dodopayments/internal/util.rb +1 -1
  9. data/lib/dodopayments/models/checkout_session_create_params.rb +14 -0
  10. data/lib/dodopayments/models/checkout_session_request.rb +347 -0
  11. data/lib/dodopayments/models/checkout_session_response.rb +25 -0
  12. data/lib/dodopayments/models/on_demand_subscription.rb +58 -0
  13. data/lib/dodopayments/models/payment_create_params.rb +1 -4
  14. data/lib/dodopayments/models/subscription.rb +9 -1
  15. data/lib/dodopayments/models/subscription_create_params.rb +3 -56
  16. data/lib/dodopayments/models/subscription_update_params.rb +16 -2
  17. data/lib/dodopayments/models/webhook_create_params.rb +6 -9
  18. data/lib/dodopayments/models/{webhook_create_response.rb → webhook_details.rb} +2 -2
  19. data/lib/dodopayments/models/webhook_retrieve_secret_params.rb +14 -0
  20. data/lib/dodopayments/models/webhook_retrieve_secret_response.rb +16 -0
  21. data/lib/dodopayments/models.rb +12 -2
  22. data/lib/dodopayments/resources/checkout_sessions.rb +61 -0
  23. data/lib/dodopayments/resources/subscriptions.rb +5 -3
  24. data/lib/dodopayments/resources/webhooks.rb +29 -10
  25. data/lib/dodopayments/version.rb +1 -1
  26. data/lib/dodopayments.rb +9 -7
  27. data/rbi/dodopayments/client.rbi +3 -3
  28. data/rbi/dodopayments/errors.rbi +2 -2
  29. data/rbi/dodopayments/models/checkout_session_create_params.rbi +32 -0
  30. data/rbi/dodopayments/models/checkout_session_request.rbi +652 -0
  31. data/rbi/dodopayments/models/checkout_session_response.rbi +40 -0
  32. data/rbi/dodopayments/models/dispute.rbi +4 -4
  33. data/rbi/dodopayments/models/get_dispute.rbi +4 -4
  34. data/rbi/dodopayments/models/license_key.rbi +2 -2
  35. data/rbi/dodopayments/models/on_demand_subscription.rbi +86 -0
  36. data/rbi/dodopayments/models/payment.rbi +8 -8
  37. data/rbi/dodopayments/models/refund.rbi +4 -4
  38. data/rbi/dodopayments/models/subscription.rbi +21 -11
  39. data/rbi/dodopayments/models/subscription_create_params.rbi +4 -90
  40. data/rbi/dodopayments/models/subscription_update_params.rbi +8 -0
  41. data/rbi/dodopayments/models/webhook_create_params.rbi +6 -6
  42. data/rbi/dodopayments/models/{webhook_list_response.rbi → webhook_details.rbi} +2 -5
  43. data/rbi/dodopayments/models/webhook_retrieve_secret_params.rbi +32 -0
  44. data/rbi/dodopayments/models/webhook_retrieve_secret_response.rbi +26 -0
  45. data/rbi/dodopayments/models.rbi +14 -2
  46. data/rbi/dodopayments/resources/checkout_sessions.rbi +80 -0
  47. data/rbi/dodopayments/resources/subscriptions.rbi +4 -2
  48. data/rbi/dodopayments/resources/webhooks.rbi +17 -7
  49. data/sig/dodopayments/client.rbs +2 -2
  50. data/sig/dodopayments/models/checkout_session_create_params.rbs +15 -0
  51. data/sig/dodopayments/models/checkout_session_request.rbs +277 -0
  52. data/sig/dodopayments/models/checkout_session_response.rbs +16 -0
  53. data/sig/dodopayments/models/on_demand_subscription.rbs +40 -0
  54. data/sig/dodopayments/models/subscription.rbs +8 -3
  55. data/sig/dodopayments/models/subscription_create_params.rbs +4 -41
  56. data/sig/dodopayments/models/subscription_update_params.rbs +5 -0
  57. data/sig/dodopayments/models/{webhook_list_response.rbs → webhook_details.rbs} +2 -2
  58. data/sig/dodopayments/models/webhook_retrieve_secret_params.rbs +15 -0
  59. data/sig/dodopayments/models/webhook_retrieve_secret_response.rbs +13 -0
  60. data/sig/dodopayments/models.rbs +12 -2
  61. data/sig/dodopayments/resources/checkout_sessions.rbs +24 -0
  62. data/sig/dodopayments/resources/subscriptions.rbs +2 -1
  63. data/sig/dodopayments/resources/webhooks.rbs +9 -4
  64. metadata +26 -20
  65. data/lib/dodopayments/models/webhook_list_response.rb +0 -88
  66. data/lib/dodopayments/models/webhook_retrieve_response.rb +0 -88
  67. data/lib/dodopayments/models/webhook_update_response.rb +0 -88
  68. data/lib/dodopayments/models/your_webhook_url_create_params.rb +0 -32
  69. data/lib/dodopayments/resources/your_webhook_url.rb +0 -56
  70. data/rbi/dodopayments/models/webhook_create_response.rbi +0 -112
  71. data/rbi/dodopayments/models/webhook_retrieve_response.rbi +0 -112
  72. data/rbi/dodopayments/models/webhook_update_response.rbi +0 -112
  73. data/rbi/dodopayments/models/your_webhook_url_create_params.rbi +0 -56
  74. data/rbi/dodopayments/resources/your_webhook_url.rbi +0 -51
  75. data/sig/dodopayments/models/webhook_create_response.rbs +0 -60
  76. data/sig/dodopayments/models/webhook_retrieve_response.rbs +0 -60
  77. data/sig/dodopayments/models/webhook_update_response.rbs +0 -60
  78. data/sig/dodopayments/models/your_webhook_url_create_params.rbs +0 -42
  79. data/sig/dodopayments/resources/your_webhook_url.rbs +0 -18
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dodopayments
4
+ module Models
5
+ # @see Dodopayments::Resources::CheckoutSessions#create
6
+ class CheckoutSessionResponse < Dodopayments::Internal::Type::BaseModel
7
+ # @!attribute checkout_url
8
+ # Checkout url
9
+ #
10
+ # @return [String]
11
+ required :checkout_url, String
12
+
13
+ # @!attribute session_id
14
+ # The ID of the created checkout session
15
+ #
16
+ # @return [String]
17
+ required :session_id, String
18
+
19
+ # @!method initialize(checkout_url:, session_id:)
20
+ # @param checkout_url [String] Checkout url
21
+ #
22
+ # @param session_id [String] The ID of the created checkout session
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dodopayments
4
+ module Models
5
+ class OnDemandSubscription < Dodopayments::Internal::Type::BaseModel
6
+ # @!attribute mandate_only
7
+ # If set as True, does not perform any charge and only authorizes payment method
8
+ # details for future use.
9
+ #
10
+ # @return [Boolean]
11
+ required :mandate_only, Dodopayments::Internal::Type::Boolean
12
+
13
+ # @!attribute adaptive_currency_fees_inclusive
14
+ # Whether adaptive currency fees should be included in the product_price (true) or
15
+ # added on top (false). This field is ignored if adaptive pricing is not enabled
16
+ # for the business.
17
+ #
18
+ # @return [Boolean, nil]
19
+ optional :adaptive_currency_fees_inclusive, Dodopayments::Internal::Type::Boolean, nil?: true
20
+
21
+ # @!attribute product_currency
22
+ # Optional currency of the product price. If not specified, defaults to the
23
+ # currency of the product.
24
+ #
25
+ # @return [Symbol, Dodopayments::Models::Currency, nil]
26
+ optional :product_currency, enum: -> { Dodopayments::Currency }, nil?: true
27
+
28
+ # @!attribute product_description
29
+ # Optional product description override for billing and line items. If not
30
+ # specified, the stored description of the product will be used.
31
+ #
32
+ # @return [String, nil]
33
+ optional :product_description, String, nil?: true
34
+
35
+ # @!attribute product_price
36
+ # Product price for the initial charge to customer If not specified the stored
37
+ # price of the product will be used Represented in the lowest denomination of the
38
+ # currency (e.g., cents for USD). For example, to charge $1.00, pass `100`.
39
+ #
40
+ # @return [Integer, nil]
41
+ optional :product_price, Integer, nil?: true
42
+
43
+ # @!method initialize(mandate_only:, adaptive_currency_fees_inclusive: nil, product_currency: nil, product_description: nil, product_price: nil)
44
+ # Some parameter documentations has been truncated, see
45
+ # {Dodopayments::Models::OnDemandSubscription} for more details.
46
+ #
47
+ # @param mandate_only [Boolean] If set as True, does not perform any charge and only authorizes payment method d
48
+ #
49
+ # @param adaptive_currency_fees_inclusive [Boolean, nil] Whether adaptive currency fees should be included in the product_price (true) or
50
+ #
51
+ # @param product_currency [Symbol, Dodopayments::Models::Currency, nil] Optional currency of the product price. If not specified, defaults to the curren
52
+ #
53
+ # @param product_description [String, nil] Optional product description override for billing and line items.
54
+ #
55
+ # @param product_price [Integer, nil] Product price for the initial charge to customer
56
+ end
57
+ end
58
+ end
@@ -23,10 +23,7 @@ module Dodopayments
23
23
  # List of products in the cart. Must contain at least 1 and at most 100 items.
24
24
  #
25
25
  # @return [Array<Dodopayments::Models::OneTimeProductCartItem>]
26
- required :product_cart,
27
- -> {
28
- Dodopayments::Internal::Type::ArrayOf[Dodopayments::OneTimeProductCartItem]
29
- }
26
+ required :product_cart, -> { Dodopayments::Internal::Type::ArrayOf[Dodopayments::OneTimeProductCartItem] }
30
27
 
31
28
  # @!attribute allowed_payment_method_types
32
29
  # List of payment methods allowed during checkout.
@@ -150,7 +150,13 @@ module Dodopayments
150
150
  # @return [String, nil]
151
151
  optional :discount_id, String, nil?: true
152
152
 
153
- # @!method initialize(addons:, billing:, cancel_at_next_billing_date:, created_at:, currency:, customer:, metadata:, next_billing_date:, on_demand:, payment_frequency_count:, payment_frequency_interval:, previous_billing_date:, product_id:, quantity:, recurring_pre_tax_amount:, status:, subscription_id:, subscription_period_count:, subscription_period_interval:, tax_inclusive:, trial_period_days:, cancelled_at: nil, discount_cycles_remaining: nil, discount_id: nil)
153
+ # @!attribute expires_at
154
+ # Timestamp when the subscription will expire
155
+ #
156
+ # @return [Time, nil]
157
+ optional :expires_at, Time, nil?: true
158
+
159
+ # @!method initialize(addons:, billing:, cancel_at_next_billing_date:, created_at:, currency:, customer:, metadata:, next_billing_date:, on_demand:, payment_frequency_count:, payment_frequency_interval:, previous_billing_date:, product_id:, quantity:, recurring_pre_tax_amount:, status:, subscription_id:, subscription_period_count:, subscription_period_interval:, tax_inclusive:, trial_period_days:, cancelled_at: nil, discount_cycles_remaining: nil, discount_id: nil, expires_at: nil)
154
160
  # Some parameter documentations has been truncated, see
155
161
  # {Dodopayments::Models::Subscription} for more details.
156
162
  #
@@ -203,6 +209,8 @@ module Dodopayments
203
209
  # @param discount_cycles_remaining [Integer, nil] Number of remaining discount cycles if discount is applied
204
210
  #
205
211
  # @param discount_id [String, nil] The discount id if discount is applied
212
+ #
213
+ # @param expires_at [Time, nil] Timestamp when the subscription will expire
206
214
  end
207
215
  end
208
216
  end
@@ -71,8 +71,8 @@ module Dodopayments
71
71
 
72
72
  # @!attribute on_demand
73
73
  #
74
- # @return [Dodopayments::Models::SubscriptionCreateParams::OnDemand, nil]
75
- optional :on_demand, -> { Dodopayments::SubscriptionCreateParams::OnDemand }, nil?: true
74
+ # @return [Dodopayments::Models::OnDemandSubscription, nil]
75
+ optional :on_demand, -> { Dodopayments::OnDemandSubscription }, nil?: true
76
76
 
77
77
  # @!attribute payment_link
78
78
  # If true, generates a payment link. Defaults to false if not specified.
@@ -128,7 +128,7 @@ module Dodopayments
128
128
  #
129
129
  # @param metadata [Hash{Symbol=>String}] Additional metadata for the subscription
130
130
  #
131
- # @param on_demand [Dodopayments::Models::SubscriptionCreateParams::OnDemand, nil]
131
+ # @param on_demand [Dodopayments::Models::OnDemandSubscription, nil]
132
132
  #
133
133
  # @param payment_link [Boolean, nil] If true, generates a payment link.
134
134
  #
@@ -141,59 +141,6 @@ module Dodopayments
141
141
  # @param trial_period_days [Integer, nil] Optional trial period in days
142
142
  #
143
143
  # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}]
144
-
145
- class OnDemand < Dodopayments::Internal::Type::BaseModel
146
- # @!attribute mandate_only
147
- # If set as True, does not perform any charge and only authorizes payment method
148
- # details for future use.
149
- #
150
- # @return [Boolean]
151
- required :mandate_only, Dodopayments::Internal::Type::Boolean
152
-
153
- # @!attribute adaptive_currency_fees_inclusive
154
- # Whether adaptive currency fees should be included in the product_price (true) or
155
- # added on top (false). This field is ignored if adaptive pricing is not enabled
156
- # for the business.
157
- #
158
- # @return [Boolean, nil]
159
- optional :adaptive_currency_fees_inclusive, Dodopayments::Internal::Type::Boolean, nil?: true
160
-
161
- # @!attribute product_currency
162
- # Optional currency of the product price. If not specified, defaults to the
163
- # currency of the product.
164
- #
165
- # @return [Symbol, Dodopayments::Models::Currency, nil]
166
- optional :product_currency, enum: -> { Dodopayments::Currency }, nil?: true
167
-
168
- # @!attribute product_description
169
- # Optional product description override for billing and line items. If not
170
- # specified, the stored description of the product will be used.
171
- #
172
- # @return [String, nil]
173
- optional :product_description, String, nil?: true
174
-
175
- # @!attribute product_price
176
- # Product price for the initial charge to customer If not specified the stored
177
- # price of the product will be used Represented in the lowest denomination of the
178
- # currency (e.g., cents for USD). For example, to charge $1.00, pass `100`.
179
- #
180
- # @return [Integer, nil]
181
- optional :product_price, Integer, nil?: true
182
-
183
- # @!method initialize(mandate_only:, adaptive_currency_fees_inclusive: nil, product_currency: nil, product_description: nil, product_price: nil)
184
- # Some parameter documentations has been truncated, see
185
- # {Dodopayments::Models::SubscriptionCreateParams::OnDemand} for more details.
186
- #
187
- # @param mandate_only [Boolean] If set as True, does not perform any charge and only authorizes payment method d
188
- #
189
- # @param adaptive_currency_fees_inclusive [Boolean, nil] Whether adaptive currency fees should be included in the product_price (true) or
190
- #
191
- # @param product_currency [Symbol, Dodopayments::Models::Currency, nil] Optional currency of the product price. If not specified, defaults to the curren
192
- #
193
- # @param product_description [String, nil] Optional product description override for billing and line items.
194
- #
195
- # @param product_price [Integer, nil] Product price for the initial charge to customer
196
- end
197
144
  end
198
145
  end
199
146
  end
@@ -13,6 +13,7 @@ module Dodopayments
13
13
  optional :billing, -> { Dodopayments::BillingAddress }, nil?: true
14
14
 
15
15
  # @!attribute cancel_at_next_billing_date
16
+ # When set, the subscription will remain active until the end of billing period
16
17
  #
17
18
  # @return [Boolean, nil]
18
19
  optional :cancel_at_next_billing_date, Dodopayments::Internal::Type::Boolean, nil?: true
@@ -27,6 +28,11 @@ module Dodopayments
27
28
  # @return [Hash{Symbol=>String}, nil]
28
29
  optional :metadata, Dodopayments::Internal::Type::HashOf[String], nil?: true
29
30
 
31
+ # @!attribute next_billing_date
32
+ #
33
+ # @return [Time, nil]
34
+ optional :next_billing_date, Time, nil?: true
35
+
30
36
  # @!attribute status
31
37
  #
32
38
  # @return [Symbol, Dodopayments::Models::SubscriptionStatus, nil]
@@ -37,13 +43,21 @@ module Dodopayments
37
43
  # @return [String, nil]
38
44
  optional :tax_id, String, nil?: true
39
45
 
40
- # @!method initialize(billing: nil, cancel_at_next_billing_date: nil, disable_on_demand: nil, metadata: nil, status: nil, tax_id: nil, request_options: {})
46
+ # @!method initialize(billing: nil, cancel_at_next_billing_date: nil, disable_on_demand: nil, metadata: nil, next_billing_date: nil, status: nil, tax_id: nil, request_options: {})
41
47
  # @param billing [Dodopayments::Models::BillingAddress, nil]
42
- # @param cancel_at_next_billing_date [Boolean, nil]
48
+ #
49
+ # @param cancel_at_next_billing_date [Boolean, nil] When set, the subscription will remain active until the end of billing period
50
+ #
43
51
  # @param disable_on_demand [Dodopayments::Models::SubscriptionUpdateParams::DisableOnDemand, nil]
52
+ #
44
53
  # @param metadata [Hash{Symbol=>String}, nil]
54
+ #
55
+ # @param next_billing_date [Time, nil]
56
+ #
45
57
  # @param status [Symbol, Dodopayments::Models::SubscriptionStatus, nil]
58
+ #
46
59
  # @param tax_id [String, nil]
60
+ #
47
61
  # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}]
48
62
 
49
63
  class DisableOnDemand < Dodopayments::Internal::Type::BaseModel
@@ -14,9 +14,6 @@ module Dodopayments
14
14
  required :url, String
15
15
 
16
16
  # @!attribute description
17
- # Filter events to the webhook.
18
- #
19
- # Webhook event will only be sent for events in the list.
20
17
  #
21
18
  # @return [String, nil]
22
19
  optional :description, String, nil?: true
@@ -30,12 +27,12 @@ module Dodopayments
30
27
  optional :disabled, Dodopayments::Internal::Type::Boolean, nil?: true
31
28
 
32
29
  # @!attribute filter_types
30
+ # Filter events to the webhook.
31
+ #
32
+ # Webhook event will only be sent for events in the list.
33
33
  #
34
34
  # @return [Array<Symbol, Dodopayments::Models::WebhookEventType>, nil]
35
- optional :filter_types,
36
- -> {
37
- Dodopayments::Internal::Type::ArrayOf[enum: Dodopayments::WebhookEventType]
38
- }
35
+ optional :filter_types, -> { Dodopayments::Internal::Type::ArrayOf[enum: Dodopayments::WebhookEventType] }
39
36
 
40
37
  # @!attribute headers
41
38
  # Custom headers to be passed
@@ -66,11 +63,11 @@ module Dodopayments
66
63
  #
67
64
  # @param url [String] Url of the webhook
68
65
  #
69
- # @param description [String, nil] Filter events to the webhook.
66
+ # @param description [String, nil]
70
67
  #
71
68
  # @param disabled [Boolean, nil] Create the webhook in a disabled state.
72
69
  #
73
- # @param filter_types [Array<Symbol, Dodopayments::Models::WebhookEventType>]
70
+ # @param filter_types [Array<Symbol, Dodopayments::Models::WebhookEventType>] Filter events to the webhook.
74
71
  #
75
72
  # @param headers [Hash{Symbol=>String}, nil] Custom headers to be passed
76
73
  #
@@ -3,7 +3,7 @@
3
3
  module Dodopayments
4
4
  module Models
5
5
  # @see Dodopayments::Resources::Webhooks#create
6
- class WebhookCreateResponse < Dodopayments::Internal::Type::BaseModel
6
+ class WebhookDetails < Dodopayments::Internal::Type::BaseModel
7
7
  # @!attribute id
8
8
  # The webhook's ID.
9
9
  #
@@ -64,7 +64,7 @@ module Dodopayments
64
64
 
65
65
  # @!method initialize(id:, created_at:, description:, metadata:, updated_at:, url:, disabled: nil, filter_types: nil, rate_limit: nil)
66
66
  # Some parameter documentations has been truncated, see
67
- # {Dodopayments::Models::WebhookCreateResponse} for more details.
67
+ # {Dodopayments::Models::WebhookDetails} for more details.
68
68
  #
69
69
  # @param id [String] The webhook's ID.
70
70
  #
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dodopayments
4
+ module Models
5
+ # @see Dodopayments::Resources::Webhooks#retrieve_secret
6
+ class WebhookRetrieveSecretParams < Dodopayments::Internal::Type::BaseModel
7
+ extend Dodopayments::Internal::Type::RequestParameters::Converter
8
+ include Dodopayments::Internal::Type::RequestParameters
9
+
10
+ # @!method initialize(request_options: {})
11
+ # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}]
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dodopayments
4
+ module Models
5
+ # @see Dodopayments::Resources::Webhooks#retrieve_secret
6
+ class WebhookRetrieveSecretResponse < Dodopayments::Internal::Type::BaseModel
7
+ # @!attribute secret
8
+ #
9
+ # @return [String]
10
+ required :secret, String
11
+
12
+ # @!method initialize(secret:)
13
+ # @param secret [String]
14
+ end
15
+ end
16
+ end
@@ -71,6 +71,12 @@ module Dodopayments
71
71
 
72
72
  BrandUpdateParams = Dodopayments::Models::BrandUpdateParams
73
73
 
74
+ CheckoutSessionCreateParams = Dodopayments::Models::CheckoutSessionCreateParams
75
+
76
+ CheckoutSessionRequest = Dodopayments::Models::CheckoutSessionRequest
77
+
78
+ CheckoutSessionResponse = Dodopayments::Models::CheckoutSessionResponse
79
+
74
80
  CountryCode = Dodopayments::Models::CountryCode
75
81
 
76
82
  CreateNewCustomer = Dodopayments::Models::CreateNewCustomer
@@ -155,6 +161,8 @@ module Dodopayments
155
161
 
156
162
  NewCustomer = Dodopayments::Models::NewCustomer
157
163
 
164
+ OnDemandSubscription = Dodopayments::Models::OnDemandSubscription
165
+
158
166
  OneTimeProductCartItem = Dodopayments::Models::OneTimeProductCartItem
159
167
 
160
168
  Payment = Dodopayments::Models::Payment
@@ -225,6 +233,8 @@ module Dodopayments
225
233
 
226
234
  WebhookDeleteParams = Dodopayments::Models::WebhookDeleteParams
227
235
 
236
+ WebhookDetails = Dodopayments::Models::WebhookDetails
237
+
228
238
  WebhookEventType = Dodopayments::Models::WebhookEventType
229
239
 
230
240
  WebhookListParams = Dodopayments::Models::WebhookListParams
@@ -233,9 +243,9 @@ module Dodopayments
233
243
 
234
244
  WebhookRetrieveParams = Dodopayments::Models::WebhookRetrieveParams
235
245
 
246
+ WebhookRetrieveSecretParams = Dodopayments::Models::WebhookRetrieveSecretParams
247
+
236
248
  Webhooks = Dodopayments::Models::Webhooks
237
249
 
238
250
  WebhookUpdateParams = Dodopayments::Models::WebhookUpdateParams
239
-
240
- YourWebhookURLCreateParams = Dodopayments::Models::YourWebhookURLCreateParams
241
251
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dodopayments
4
+ module Resources
5
+ class CheckoutSessions
6
+ # Some parameter documentations has been truncated, see
7
+ # {Dodopayments::Models::CheckoutSessionCreateParams} for more details.
8
+ #
9
+ # @overload create(product_cart:, allowed_payment_method_types: nil, billing_address: nil, billing_currency: nil, confirm: nil, customer: nil, customization: nil, discount_code: nil, feature_flags: nil, metadata: nil, return_url: nil, show_saved_payment_methods: nil, subscription_data: nil, request_options: {})
10
+ #
11
+ # @param product_cart [Array<Dodopayments::Models::CheckoutSessionRequest::ProductCart>]
12
+ #
13
+ # @param allowed_payment_method_types [Array<Symbol, Dodopayments::Models::PaymentMethodTypes>, nil] Customers will never see payment methods that are not in this list.
14
+ #
15
+ # @param billing_address [Dodopayments::Models::CheckoutSessionRequest::BillingAddress, nil] Billing address information for the session
16
+ #
17
+ # @param billing_currency [Symbol, Dodopayments::Models::Currency, nil] This field is ingored if adaptive pricing is disabled
18
+ #
19
+ # @param confirm [Boolean] If confirm is true, all the details will be finalized. If required data is missi
20
+ #
21
+ # @param customer [Dodopayments::Models::AttachExistingCustomer, Dodopayments::Models::NewCustomer, nil] Customer details for the session
22
+ #
23
+ # @param customization [Dodopayments::Models::CheckoutSessionRequest::Customization] Customization for the checkout session page
24
+ #
25
+ # @param discount_code [String, nil]
26
+ #
27
+ # @param feature_flags [Dodopayments::Models::CheckoutSessionRequest::FeatureFlags]
28
+ #
29
+ # @param metadata [Hash{Symbol=>String}, nil] Additional metadata associated with the payment. Defaults to empty if not provid
30
+ #
31
+ # @param return_url [String, nil] The url to redirect after payment failure or success.
32
+ #
33
+ # @param show_saved_payment_methods [Boolean] Display saved payment methods of a returning customer False by default
34
+ #
35
+ # @param subscription_data [Dodopayments::Models::CheckoutSessionRequest::SubscriptionData, nil]
36
+ #
37
+ # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil]
38
+ #
39
+ # @return [Dodopayments::Models::CheckoutSessionResponse]
40
+ #
41
+ # @see Dodopayments::Models::CheckoutSessionCreateParams
42
+ def create(params)
43
+ parsed, options = Dodopayments::CheckoutSessionCreateParams.dump_request(params)
44
+ @client.request(
45
+ method: :post,
46
+ path: "checkouts",
47
+ body: parsed,
48
+ model: Dodopayments::CheckoutSessionResponse,
49
+ options: options
50
+ )
51
+ end
52
+
53
+ # @api private
54
+ #
55
+ # @param client [Dodopayments::Client]
56
+ def initialize(client:)
57
+ @client = client
58
+ end
59
+ end
60
+ end
61
+ end
@@ -26,7 +26,7 @@ module Dodopayments
26
26
  #
27
27
  # @param metadata [Hash{Symbol=>String}] Additional metadata for the subscription
28
28
  #
29
- # @param on_demand [Dodopayments::Models::SubscriptionCreateParams::OnDemand, nil]
29
+ # @param on_demand [Dodopayments::Models::OnDemandSubscription, nil]
30
30
  #
31
31
  # @param payment_link [Boolean, nil] If true, generates a payment link.
32
32
  #
@@ -72,18 +72,20 @@ module Dodopayments
72
72
  )
73
73
  end
74
74
 
75
- # @overload update(subscription_id, billing: nil, cancel_at_next_billing_date: nil, disable_on_demand: nil, metadata: nil, status: nil, tax_id: nil, request_options: {})
75
+ # @overload update(subscription_id, billing: nil, cancel_at_next_billing_date: nil, disable_on_demand: nil, metadata: nil, next_billing_date: nil, status: nil, tax_id: nil, request_options: {})
76
76
  #
77
77
  # @param subscription_id [String] Subscription Id
78
78
  #
79
79
  # @param billing [Dodopayments::Models::BillingAddress, nil]
80
80
  #
81
- # @param cancel_at_next_billing_date [Boolean, nil]
81
+ # @param cancel_at_next_billing_date [Boolean, nil] When set, the subscription will remain active until the end of billing period
82
82
  #
83
83
  # @param disable_on_demand [Dodopayments::Models::SubscriptionUpdateParams::DisableOnDemand, nil]
84
84
  #
85
85
  # @param metadata [Hash{Symbol=>String}, nil]
86
86
  #
87
+ # @param next_billing_date [Time, nil]
88
+ #
87
89
  # @param status [Symbol, Dodopayments::Models::SubscriptionStatus, nil]
88
90
  #
89
91
  # @param tax_id [String, nil]
@@ -15,11 +15,11 @@ module Dodopayments
15
15
  #
16
16
  # @param url [String] Url of the webhook
17
17
  #
18
- # @param description [String, nil] Filter events to the webhook.
18
+ # @param description [String, nil]
19
19
  #
20
20
  # @param disabled [Boolean, nil] Create the webhook in a disabled state.
21
21
  #
22
- # @param filter_types [Array<Symbol, Dodopayments::Models::WebhookEventType>]
22
+ # @param filter_types [Array<Symbol, Dodopayments::Models::WebhookEventType>] Filter events to the webhook.
23
23
  #
24
24
  # @param headers [Hash{Symbol=>String}, nil] Custom headers to be passed
25
25
  #
@@ -31,7 +31,7 @@ module Dodopayments
31
31
  #
32
32
  # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil]
33
33
  #
34
- # @return [Dodopayments::Models::WebhookCreateResponse]
34
+ # @return [Dodopayments::Models::WebhookDetails]
35
35
  #
36
36
  # @see Dodopayments::Models::WebhookCreateParams
37
37
  def create(params)
@@ -40,7 +40,7 @@ module Dodopayments
40
40
  method: :post,
41
41
  path: "webhooks",
42
42
  body: parsed,
43
- model: Dodopayments::Models::WebhookCreateResponse,
43
+ model: Dodopayments::WebhookDetails,
44
44
  options: options
45
45
  )
46
46
  end
@@ -52,14 +52,14 @@ module Dodopayments
52
52
  # @param webhook_id [String]
53
53
  # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil]
54
54
  #
55
- # @return [Dodopayments::Models::WebhookRetrieveResponse]
55
+ # @return [Dodopayments::Models::WebhookDetails]
56
56
  #
57
57
  # @see Dodopayments::Models::WebhookRetrieveParams
58
58
  def retrieve(webhook_id, params = {})
59
59
  @client.request(
60
60
  method: :get,
61
61
  path: ["webhooks/%1$s", webhook_id],
62
- model: Dodopayments::Models::WebhookRetrieveResponse,
62
+ model: Dodopayments::WebhookDetails,
63
63
  options: params[:request_options]
64
64
  )
65
65
  end
@@ -87,7 +87,7 @@ module Dodopayments
87
87
  #
88
88
  # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil]
89
89
  #
90
- # @return [Dodopayments::Models::WebhookUpdateResponse]
90
+ # @return [Dodopayments::Models::WebhookDetails]
91
91
  #
92
92
  # @see Dodopayments::Models::WebhookUpdateParams
93
93
  def update(webhook_id, params = {})
@@ -96,7 +96,7 @@ module Dodopayments
96
96
  method: :patch,
97
97
  path: ["webhooks/%1$s", webhook_id],
98
98
  body: parsed,
99
- model: Dodopayments::Models::WebhookUpdateResponse,
99
+ model: Dodopayments::WebhookDetails,
100
100
  options: options
101
101
  )
102
102
  end
@@ -111,7 +111,7 @@ module Dodopayments
111
111
  #
112
112
  # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil]
113
113
  #
114
- # @return [Dodopayments::Internal::CursorPagePagination<Dodopayments::Models::WebhookListResponse>]
114
+ # @return [Dodopayments::Internal::CursorPagePagination<Dodopayments::Models::WebhookDetails>]
115
115
  #
116
116
  # @see Dodopayments::Models::WebhookListParams
117
117
  def list(params = {})
@@ -121,7 +121,7 @@ module Dodopayments
121
121
  path: "webhooks",
122
122
  query: parsed,
123
123
  page: Dodopayments::Internal::CursorPagePagination,
124
- model: Dodopayments::Models::WebhookListResponse,
124
+ model: Dodopayments::WebhookDetails,
125
125
  options: options
126
126
  )
127
127
  end
@@ -145,6 +145,25 @@ module Dodopayments
145
145
  )
146
146
  end
147
147
 
148
+ # Get webhook secret by id
149
+ #
150
+ # @overload retrieve_secret(webhook_id, request_options: {})
151
+ #
152
+ # @param webhook_id [String]
153
+ # @param request_options [Dodopayments::RequestOptions, Hash{Symbol=>Object}, nil]
154
+ #
155
+ # @return [Dodopayments::Models::WebhookRetrieveSecretResponse]
156
+ #
157
+ # @see Dodopayments::Models::WebhookRetrieveSecretParams
158
+ def retrieve_secret(webhook_id, params = {})
159
+ @client.request(
160
+ method: :get,
161
+ path: ["webhooks/%1$s/secret", webhook_id],
162
+ model: Dodopayments::Models::WebhookRetrieveSecretResponse,
163
+ options: params[:request_options]
164
+ )
165
+ end
166
+
148
167
  # @api private
149
168
  #
150
169
  # @param client [Dodopayments::Client]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dodopayments
4
- VERSION = "1.47.0"
4
+ VERSION = "1.51.0"
5
5
  end
data/lib/dodopayments.rb CHANGED
@@ -52,12 +52,12 @@ require_relative "dodopayments/internal/transport/pooled_net_requester"
52
52
  require_relative "dodopayments/client"
53
53
  require_relative "dodopayments/internal/cursor_page_pagination"
54
54
  require_relative "dodopayments/internal/default_page_number_pagination"
55
+ require_relative "dodopayments/models/checkout_session_request"
55
56
  require_relative "dodopayments/models/license_key"
56
57
  require_relative "dodopayments/models/get_dispute"
57
58
  require_relative "dodopayments/models/refund"
58
59
  require_relative "dodopayments/models/subscription"
59
60
  require_relative "dodopayments/models/payment"
60
- require_relative "dodopayments/models/webhook_payload"
61
61
  require_relative "dodopayments/models/addon_cart_response_item"
62
62
  require_relative "dodopayments/models/addon_create_params"
63
63
  require_relative "dodopayments/models/addon_list_params"
@@ -77,6 +77,8 @@ require_relative "dodopayments/models/brand_retrieve_params"
77
77
  require_relative "dodopayments/models/brand_update_images_params"
78
78
  require_relative "dodopayments/models/brand_update_images_response"
79
79
  require_relative "dodopayments/models/brand_update_params"
80
+ require_relative "dodopayments/models/checkout_session_create_params"
81
+ require_relative "dodopayments/models/checkout_session_response"
80
82
  require_relative "dodopayments/models/country_code"
81
83
  require_relative "dodopayments/models/create_new_customer"
82
84
  require_relative "dodopayments/models/currency"
@@ -120,6 +122,7 @@ require_relative "dodopayments/models/license_validate_response"
120
122
  require_relative "dodopayments/models/misc_list_supported_countries_params"
121
123
  require_relative "dodopayments/models/misc_list_supported_countries_response"
122
124
  require_relative "dodopayments/models/new_customer"
125
+ require_relative "dodopayments/models/on_demand_subscription"
123
126
  require_relative "dodopayments/models/one_time_product_cart_item"
124
127
  require_relative "dodopayments/models/payment_create_params"
125
128
  require_relative "dodopayments/models/payment_create_response"
@@ -161,22 +164,22 @@ require_relative "dodopayments/models/subscription_update_params"
161
164
  require_relative "dodopayments/models/tax_category"
162
165
  require_relative "dodopayments/models/time_interval"
163
166
  require_relative "dodopayments/models/webhook_create_params"
164
- require_relative "dodopayments/models/webhook_create_response"
165
167
  require_relative "dodopayments/models/webhook_delete_params"
168
+ require_relative "dodopayments/models/webhook_details"
166
169
  require_relative "dodopayments/models/webhook_event_type"
167
170
  require_relative "dodopayments/models/webhook_list_params"
168
- require_relative "dodopayments/models/webhook_list_response"
171
+ require_relative "dodopayments/models/webhook_payload"
169
172
  require_relative "dodopayments/models/webhook_retrieve_params"
170
- require_relative "dodopayments/models/webhook_retrieve_response"
173
+ require_relative "dodopayments/models/webhook_retrieve_secret_params"
174
+ require_relative "dodopayments/models/webhook_retrieve_secret_response"
171
175
  require_relative "dodopayments/models/webhooks/header_retrieve_params"
172
176
  require_relative "dodopayments/models/webhooks/header_retrieve_response"
173
177
  require_relative "dodopayments/models/webhooks/header_update_params"
174
178
  require_relative "dodopayments/models/webhook_update_params"
175
- require_relative "dodopayments/models/webhook_update_response"
176
- require_relative "dodopayments/models/your_webhook_url_create_params"
177
179
  require_relative "dodopayments/models"
178
180
  require_relative "dodopayments/resources/addons"
179
181
  require_relative "dodopayments/resources/brands"
182
+ require_relative "dodopayments/resources/checkout_sessions"
180
183
  require_relative "dodopayments/resources/customers"
181
184
  require_relative "dodopayments/resources/customers/customer_portal"
182
185
  require_relative "dodopayments/resources/discounts"
@@ -196,4 +199,3 @@ require_relative "dodopayments/resources/subscriptions"
196
199
  require_relative "dodopayments/resources/webhook_events"
197
200
  require_relative "dodopayments/resources/webhooks"
198
201
  require_relative "dodopayments/resources/webhooks/headers"
199
- require_relative "dodopayments/resources/your_webhook_url"