dodopayments 1.49.0__py3-none-any.whl → 1.51.1__py3-none-any.whl

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 (35) hide show
  1. dodopayments/_client.py +15 -11
  2. dodopayments/_models.py +1 -1
  3. dodopayments/_types.py +35 -1
  4. dodopayments/_utils/__init__.py +1 -0
  5. dodopayments/_utils/_typing.py +5 -0
  6. dodopayments/_version.py +1 -1
  7. dodopayments/resources/__init__.py +13 -13
  8. dodopayments/resources/checkout_sessions.py +272 -0
  9. dodopayments/resources/subscriptions.py +7 -2
  10. dodopayments/resources/webhooks/webhooks.py +19 -22
  11. dodopayments/types/__init__.py +4 -13
  12. dodopayments/types/checkout_session_create_params.py +174 -0
  13. dodopayments/types/checkout_session_response.py +13 -0
  14. dodopayments/types/on_demand_subscription_param.py +44 -0
  15. dodopayments/types/subscription.py +3 -0
  16. dodopayments/types/subscription_create_params.py +3 -36
  17. dodopayments/types/subscription_update_params.py +1 -0
  18. dodopayments/types/{webhook_list_response.py → webhook_details.py} +2 -2
  19. {dodopayments-1.49.0.dist-info → dodopayments-1.51.1.dist-info}/METADATA +17 -90
  20. {dodopayments-1.49.0.dist-info → dodopayments-1.51.1.dist-info}/RECORD +22 -31
  21. dodopayments/resources/your_webhook_url.py +0 -224
  22. dodopayments/types/addon_cart_response_item_param.py +0 -13
  23. dodopayments/types/customer_limited_details_param.py +0 -18
  24. dodopayments/types/dispute_param.py +0 -45
  25. dodopayments/types/get_dispute_param.py +0 -52
  26. dodopayments/types/license_key_param.py +0 -53
  27. dodopayments/types/payment_param.py +0 -131
  28. dodopayments/types/refund_param.py +0 -42
  29. dodopayments/types/subscription_param.py +0 -97
  30. dodopayments/types/webhook_create_response.py +0 -42
  31. dodopayments/types/webhook_retrieve_response.py +0 -42
  32. dodopayments/types/webhook_update_response.py +0 -42
  33. dodopayments/types/your_webhook_url_create_params.py +0 -66
  34. {dodopayments-1.49.0.dist-info → dodopayments-1.51.1.dist-info}/WHEEL +0 -0
  35. {dodopayments-1.49.0.dist-info → dodopayments-1.51.1.dist-info}/licenses/LICENSE +0 -0
dodopayments/_client.py CHANGED
@@ -33,7 +33,7 @@ from .resources import (
33
33
  discounts,
34
34
  license_keys,
35
35
  subscriptions,
36
- your_webhook_url,
36
+ checkout_sessions,
37
37
  license_key_instances,
38
38
  )
39
39
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
@@ -67,6 +67,7 @@ ENVIRONMENTS: Dict[str, str] = {
67
67
 
68
68
 
69
69
  class DodoPayments(SyncAPIClient):
70
+ checkout_sessions: checkout_sessions.CheckoutSessionsResource
70
71
  payments: payments.PaymentsResource
71
72
  subscriptions: subscriptions.SubscriptionsResource
72
73
  invoices: invoices.InvoicesResource
@@ -83,7 +84,6 @@ class DodoPayments(SyncAPIClient):
83
84
  addons: addons.AddonsResource
84
85
  brands: brands.BrandsResource
85
86
  webhooks: webhooks.WebhooksResource
86
- your_webhook_url: your_webhook_url.YourWebhookURLResource
87
87
  with_raw_response: DodoPaymentsWithRawResponse
88
88
  with_streaming_response: DodoPaymentsWithStreamedResponse
89
89
 
@@ -165,6 +165,7 @@ class DodoPayments(SyncAPIClient):
165
165
  _strict_response_validation=_strict_response_validation,
166
166
  )
167
167
 
168
+ self.checkout_sessions = checkout_sessions.CheckoutSessionsResource(self)
168
169
  self.payments = payments.PaymentsResource(self)
169
170
  self.subscriptions = subscriptions.SubscriptionsResource(self)
170
171
  self.invoices = invoices.InvoicesResource(self)
@@ -181,7 +182,6 @@ class DodoPayments(SyncAPIClient):
181
182
  self.addons = addons.AddonsResource(self)
182
183
  self.brands = brands.BrandsResource(self)
183
184
  self.webhooks = webhooks.WebhooksResource(self)
184
- self.your_webhook_url = your_webhook_url.YourWebhookURLResource(self)
185
185
  self.with_raw_response = DodoPaymentsWithRawResponse(self)
186
186
  self.with_streaming_response = DodoPaymentsWithStreamedResponse(self)
187
187
 
@@ -293,6 +293,7 @@ class DodoPayments(SyncAPIClient):
293
293
 
294
294
 
295
295
  class AsyncDodoPayments(AsyncAPIClient):
296
+ checkout_sessions: checkout_sessions.AsyncCheckoutSessionsResource
296
297
  payments: payments.AsyncPaymentsResource
297
298
  subscriptions: subscriptions.AsyncSubscriptionsResource
298
299
  invoices: invoices.AsyncInvoicesResource
@@ -309,7 +310,6 @@ class AsyncDodoPayments(AsyncAPIClient):
309
310
  addons: addons.AsyncAddonsResource
310
311
  brands: brands.AsyncBrandsResource
311
312
  webhooks: webhooks.AsyncWebhooksResource
312
- your_webhook_url: your_webhook_url.AsyncYourWebhookURLResource
313
313
  with_raw_response: AsyncDodoPaymentsWithRawResponse
314
314
  with_streaming_response: AsyncDodoPaymentsWithStreamedResponse
315
315
 
@@ -391,6 +391,7 @@ class AsyncDodoPayments(AsyncAPIClient):
391
391
  _strict_response_validation=_strict_response_validation,
392
392
  )
393
393
 
394
+ self.checkout_sessions = checkout_sessions.AsyncCheckoutSessionsResource(self)
394
395
  self.payments = payments.AsyncPaymentsResource(self)
395
396
  self.subscriptions = subscriptions.AsyncSubscriptionsResource(self)
396
397
  self.invoices = invoices.AsyncInvoicesResource(self)
@@ -407,7 +408,6 @@ class AsyncDodoPayments(AsyncAPIClient):
407
408
  self.addons = addons.AsyncAddonsResource(self)
408
409
  self.brands = brands.AsyncBrandsResource(self)
409
410
  self.webhooks = webhooks.AsyncWebhooksResource(self)
410
- self.your_webhook_url = your_webhook_url.AsyncYourWebhookURLResource(self)
411
411
  self.with_raw_response = AsyncDodoPaymentsWithRawResponse(self)
412
412
  self.with_streaming_response = AsyncDodoPaymentsWithStreamedResponse(self)
413
413
 
@@ -520,6 +520,7 @@ class AsyncDodoPayments(AsyncAPIClient):
520
520
 
521
521
  class DodoPaymentsWithRawResponse:
522
522
  def __init__(self, client: DodoPayments) -> None:
523
+ self.checkout_sessions = checkout_sessions.CheckoutSessionsResourceWithRawResponse(client.checkout_sessions)
523
524
  self.payments = payments.PaymentsResourceWithRawResponse(client.payments)
524
525
  self.subscriptions = subscriptions.SubscriptionsResourceWithRawResponse(client.subscriptions)
525
526
  self.invoices = invoices.InvoicesResourceWithRawResponse(client.invoices)
@@ -538,11 +539,13 @@ class DodoPaymentsWithRawResponse:
538
539
  self.addons = addons.AddonsResourceWithRawResponse(client.addons)
539
540
  self.brands = brands.BrandsResourceWithRawResponse(client.brands)
540
541
  self.webhooks = webhooks.WebhooksResourceWithRawResponse(client.webhooks)
541
- self.your_webhook_url = your_webhook_url.YourWebhookURLResourceWithRawResponse(client.your_webhook_url)
542
542
 
543
543
 
544
544
  class AsyncDodoPaymentsWithRawResponse:
545
545
  def __init__(self, client: AsyncDodoPayments) -> None:
546
+ self.checkout_sessions = checkout_sessions.AsyncCheckoutSessionsResourceWithRawResponse(
547
+ client.checkout_sessions
548
+ )
546
549
  self.payments = payments.AsyncPaymentsResourceWithRawResponse(client.payments)
547
550
  self.subscriptions = subscriptions.AsyncSubscriptionsResourceWithRawResponse(client.subscriptions)
548
551
  self.invoices = invoices.AsyncInvoicesResourceWithRawResponse(client.invoices)
@@ -561,11 +564,13 @@ class AsyncDodoPaymentsWithRawResponse:
561
564
  self.addons = addons.AsyncAddonsResourceWithRawResponse(client.addons)
562
565
  self.brands = brands.AsyncBrandsResourceWithRawResponse(client.brands)
563
566
  self.webhooks = webhooks.AsyncWebhooksResourceWithRawResponse(client.webhooks)
564
- self.your_webhook_url = your_webhook_url.AsyncYourWebhookURLResourceWithRawResponse(client.your_webhook_url)
565
567
 
566
568
 
567
569
  class DodoPaymentsWithStreamedResponse:
568
570
  def __init__(self, client: DodoPayments) -> None:
571
+ self.checkout_sessions = checkout_sessions.CheckoutSessionsResourceWithStreamingResponse(
572
+ client.checkout_sessions
573
+ )
569
574
  self.payments = payments.PaymentsResourceWithStreamingResponse(client.payments)
570
575
  self.subscriptions = subscriptions.SubscriptionsResourceWithStreamingResponse(client.subscriptions)
571
576
  self.invoices = invoices.InvoicesResourceWithStreamingResponse(client.invoices)
@@ -584,11 +589,13 @@ class DodoPaymentsWithStreamedResponse:
584
589
  self.addons = addons.AddonsResourceWithStreamingResponse(client.addons)
585
590
  self.brands = brands.BrandsResourceWithStreamingResponse(client.brands)
586
591
  self.webhooks = webhooks.WebhooksResourceWithStreamingResponse(client.webhooks)
587
- self.your_webhook_url = your_webhook_url.YourWebhookURLResourceWithStreamingResponse(client.your_webhook_url)
588
592
 
589
593
 
590
594
  class AsyncDodoPaymentsWithStreamedResponse:
591
595
  def __init__(self, client: AsyncDodoPayments) -> None:
596
+ self.checkout_sessions = checkout_sessions.AsyncCheckoutSessionsResourceWithStreamingResponse(
597
+ client.checkout_sessions
598
+ )
592
599
  self.payments = payments.AsyncPaymentsResourceWithStreamingResponse(client.payments)
593
600
  self.subscriptions = subscriptions.AsyncSubscriptionsResourceWithStreamingResponse(client.subscriptions)
594
601
  self.invoices = invoices.AsyncInvoicesResourceWithStreamingResponse(client.invoices)
@@ -607,9 +614,6 @@ class AsyncDodoPaymentsWithStreamedResponse:
607
614
  self.addons = addons.AsyncAddonsResourceWithStreamingResponse(client.addons)
608
615
  self.brands = brands.AsyncBrandsResourceWithStreamingResponse(client.brands)
609
616
  self.webhooks = webhooks.AsyncWebhooksResourceWithStreamingResponse(client.webhooks)
610
- self.your_webhook_url = your_webhook_url.AsyncYourWebhookURLResourceWithStreamingResponse(
611
- client.your_webhook_url
612
- )
613
617
 
614
618
 
615
619
  Client = DodoPayments
dodopayments/_models.py CHANGED
@@ -304,7 +304,7 @@ class BaseModel(pydantic.BaseModel):
304
304
  exclude_none=exclude_none,
305
305
  )
306
306
 
307
- return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
307
+ return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped
308
308
 
309
309
  @override
310
310
  def model_dump_json(
dodopayments/_types.py CHANGED
@@ -13,10 +13,21 @@ from typing import (
13
13
  Mapping,
14
14
  TypeVar,
15
15
  Callable,
16
+ Iterator,
16
17
  Optional,
17
18
  Sequence,
18
19
  )
19
- from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
20
+ from typing_extensions import (
21
+ Set,
22
+ Literal,
23
+ Protocol,
24
+ TypeAlias,
25
+ TypedDict,
26
+ SupportsIndex,
27
+ overload,
28
+ override,
29
+ runtime_checkable,
30
+ )
20
31
 
21
32
  import httpx
22
33
  import pydantic
@@ -217,3 +228,26 @@ class _GenericAlias(Protocol):
217
228
  class HttpxSendArgs(TypedDict, total=False):
218
229
  auth: httpx.Auth
219
230
  follow_redirects: bool
231
+
232
+
233
+ _T_co = TypeVar("_T_co", covariant=True)
234
+
235
+
236
+ if TYPE_CHECKING:
237
+ # This works because str.__contains__ does not accept object (either in typeshed or at runtime)
238
+ # https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
239
+ class SequenceNotStr(Protocol[_T_co]):
240
+ @overload
241
+ def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
242
+ @overload
243
+ def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
244
+ def __contains__(self, value: object, /) -> bool: ...
245
+ def __len__(self) -> int: ...
246
+ def __iter__(self) -> Iterator[_T_co]: ...
247
+ def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
248
+ def count(self, value: Any, /) -> int: ...
249
+ def __reversed__(self) -> Iterator[_T_co]: ...
250
+ else:
251
+ # just point this to a normal `Sequence` at runtime to avoid having to special case
252
+ # deserializing our custom sequence type
253
+ SequenceNotStr = Sequence
@@ -38,6 +38,7 @@ from ._typing import (
38
38
  extract_type_arg as extract_type_arg,
39
39
  is_iterable_type as is_iterable_type,
40
40
  is_required_type as is_required_type,
41
+ is_sequence_type as is_sequence_type,
41
42
  is_annotated_type as is_annotated_type,
42
43
  is_type_alias_type as is_type_alias_type,
43
44
  strip_annotated_type as strip_annotated_type,
@@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
26
26
  return (get_origin(typ) or typ) == list
27
27
 
28
28
 
29
+ def is_sequence_type(typ: type) -> bool:
30
+ origin = get_origin(typ) or typ
31
+ return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence
32
+
33
+
29
34
  def is_iterable_type(typ: type) -> bool:
30
35
  """If the given type is `typing.Iterable[T]`"""
31
36
  origin = get_origin(typ) or typ
dodopayments/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "dodopayments"
4
- __version__ = "1.49.0" # x-release-please-version
4
+ __version__ = "1.51.1" # x-release-please-version
@@ -120,13 +120,13 @@ from .subscriptions import (
120
120
  SubscriptionsResourceWithStreamingResponse,
121
121
  AsyncSubscriptionsResourceWithStreamingResponse,
122
122
  )
123
- from .your_webhook_url import (
124
- YourWebhookURLResource,
125
- AsyncYourWebhookURLResource,
126
- YourWebhookURLResourceWithRawResponse,
127
- AsyncYourWebhookURLResourceWithRawResponse,
128
- YourWebhookURLResourceWithStreamingResponse,
129
- AsyncYourWebhookURLResourceWithStreamingResponse,
123
+ from .checkout_sessions import (
124
+ CheckoutSessionsResource,
125
+ AsyncCheckoutSessionsResource,
126
+ CheckoutSessionsResourceWithRawResponse,
127
+ AsyncCheckoutSessionsResourceWithRawResponse,
128
+ CheckoutSessionsResourceWithStreamingResponse,
129
+ AsyncCheckoutSessionsResourceWithStreamingResponse,
130
130
  )
131
131
  from .license_key_instances import (
132
132
  LicenseKeyInstancesResource,
@@ -138,6 +138,12 @@ from .license_key_instances import (
138
138
  )
139
139
 
140
140
  __all__ = [
141
+ "CheckoutSessionsResource",
142
+ "AsyncCheckoutSessionsResource",
143
+ "CheckoutSessionsResourceWithRawResponse",
144
+ "AsyncCheckoutSessionsResourceWithRawResponse",
145
+ "CheckoutSessionsResourceWithStreamingResponse",
146
+ "AsyncCheckoutSessionsResourceWithStreamingResponse",
141
147
  "PaymentsResource",
142
148
  "AsyncPaymentsResource",
143
149
  "PaymentsResourceWithRawResponse",
@@ -234,10 +240,4 @@ __all__ = [
234
240
  "AsyncWebhooksResourceWithRawResponse",
235
241
  "WebhooksResourceWithStreamingResponse",
236
242
  "AsyncWebhooksResourceWithStreamingResponse",
237
- "YourWebhookURLResource",
238
- "AsyncYourWebhookURLResource",
239
- "YourWebhookURLResourceWithRawResponse",
240
- "AsyncYourWebhookURLResourceWithRawResponse",
241
- "YourWebhookURLResourceWithStreamingResponse",
242
- "AsyncYourWebhookURLResourceWithStreamingResponse",
243
243
  ]
@@ -0,0 +1,272 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Dict, List, Iterable, Optional
6
+
7
+ import httpx
8
+
9
+ from ..types import Currency, checkout_session_create_params
10
+ from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11
+ from .._utils import maybe_transform, async_maybe_transform
12
+ from .._compat import cached_property
13
+ from .._resource import SyncAPIResource, AsyncAPIResource
14
+ from .._response import (
15
+ to_raw_response_wrapper,
16
+ to_streamed_response_wrapper,
17
+ async_to_raw_response_wrapper,
18
+ async_to_streamed_response_wrapper,
19
+ )
20
+ from .._base_client import make_request_options
21
+ from ..types.currency import Currency
22
+ from ..types.payment_method_types import PaymentMethodTypes
23
+ from ..types.customer_request_param import CustomerRequestParam
24
+ from ..types.checkout_session_response import CheckoutSessionResponse
25
+
26
+ __all__ = ["CheckoutSessionsResource", "AsyncCheckoutSessionsResource"]
27
+
28
+
29
+ class CheckoutSessionsResource(SyncAPIResource):
30
+ @cached_property
31
+ def with_raw_response(self) -> CheckoutSessionsResourceWithRawResponse:
32
+ """
33
+ This property can be used as a prefix for any HTTP method call to return
34
+ the raw response object instead of the parsed content.
35
+
36
+ For more information, see https://www.github.com/dodopayments/dodopayments-python#accessing-raw-response-data-eg-headers
37
+ """
38
+ return CheckoutSessionsResourceWithRawResponse(self)
39
+
40
+ @cached_property
41
+ def with_streaming_response(self) -> CheckoutSessionsResourceWithStreamingResponse:
42
+ """
43
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
44
+
45
+ For more information, see https://www.github.com/dodopayments/dodopayments-python#with_streaming_response
46
+ """
47
+ return CheckoutSessionsResourceWithStreamingResponse(self)
48
+
49
+ def create(
50
+ self,
51
+ *,
52
+ product_cart: Iterable[checkout_session_create_params.ProductCart],
53
+ allowed_payment_method_types: Optional[List[PaymentMethodTypes]] | NotGiven = NOT_GIVEN,
54
+ billing_address: Optional[checkout_session_create_params.BillingAddress] | NotGiven = NOT_GIVEN,
55
+ billing_currency: Optional[Currency] | NotGiven = NOT_GIVEN,
56
+ confirm: bool | NotGiven = NOT_GIVEN,
57
+ customer: Optional[CustomerRequestParam] | NotGiven = NOT_GIVEN,
58
+ customization: checkout_session_create_params.Customization | NotGiven = NOT_GIVEN,
59
+ discount_code: Optional[str] | NotGiven = NOT_GIVEN,
60
+ feature_flags: checkout_session_create_params.FeatureFlags | NotGiven = NOT_GIVEN,
61
+ metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
62
+ return_url: Optional[str] | NotGiven = NOT_GIVEN,
63
+ show_saved_payment_methods: bool | NotGiven = NOT_GIVEN,
64
+ subscription_data: Optional[checkout_session_create_params.SubscriptionData] | NotGiven = NOT_GIVEN,
65
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
66
+ # The extra values given here take precedence over values defined on the client or passed to this method.
67
+ extra_headers: Headers | None = None,
68
+ extra_query: Query | None = None,
69
+ extra_body: Body | None = None,
70
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
71
+ ) -> CheckoutSessionResponse:
72
+ """
73
+ Args:
74
+ allowed_payment_method_types: Customers will never see payment methods that are not in this list. However,
75
+ adding a method here does not guarantee customers will see it. Availability
76
+ still depends on other factors (e.g., customer location, merchant settings).
77
+
78
+ Disclaimar: Always provide 'credit' and 'debit' as a fallback. If all payment
79
+ methods are unavailable, checkout session will fail.
80
+
81
+ billing_address: Billing address information for the session
82
+
83
+ billing_currency: This field is ingored if adaptive pricing is disabled
84
+
85
+ confirm: If confirm is true, all the details will be finalized. If required data is
86
+ missing, an API error is thrown.
87
+
88
+ customer: Customer details for the session
89
+
90
+ customization: Customization for the checkout session page
91
+
92
+ metadata: Additional metadata associated with the payment. Defaults to empty if not
93
+ provided.
94
+
95
+ return_url: The url to redirect after payment failure or success.
96
+
97
+ show_saved_payment_methods: Display saved payment methods of a returning customer False by default
98
+
99
+ extra_headers: Send extra headers
100
+
101
+ extra_query: Add additional query parameters to the request
102
+
103
+ extra_body: Add additional JSON properties to the request
104
+
105
+ timeout: Override the client-level default timeout for this request, in seconds
106
+ """
107
+ return self._post(
108
+ "/checkouts",
109
+ body=maybe_transform(
110
+ {
111
+ "product_cart": product_cart,
112
+ "allowed_payment_method_types": allowed_payment_method_types,
113
+ "billing_address": billing_address,
114
+ "billing_currency": billing_currency,
115
+ "confirm": confirm,
116
+ "customer": customer,
117
+ "customization": customization,
118
+ "discount_code": discount_code,
119
+ "feature_flags": feature_flags,
120
+ "metadata": metadata,
121
+ "return_url": return_url,
122
+ "show_saved_payment_methods": show_saved_payment_methods,
123
+ "subscription_data": subscription_data,
124
+ },
125
+ checkout_session_create_params.CheckoutSessionCreateParams,
126
+ ),
127
+ options=make_request_options(
128
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
129
+ ),
130
+ cast_to=CheckoutSessionResponse,
131
+ )
132
+
133
+
134
+ class AsyncCheckoutSessionsResource(AsyncAPIResource):
135
+ @cached_property
136
+ def with_raw_response(self) -> AsyncCheckoutSessionsResourceWithRawResponse:
137
+ """
138
+ This property can be used as a prefix for any HTTP method call to return
139
+ the raw response object instead of the parsed content.
140
+
141
+ For more information, see https://www.github.com/dodopayments/dodopayments-python#accessing-raw-response-data-eg-headers
142
+ """
143
+ return AsyncCheckoutSessionsResourceWithRawResponse(self)
144
+
145
+ @cached_property
146
+ def with_streaming_response(self) -> AsyncCheckoutSessionsResourceWithStreamingResponse:
147
+ """
148
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
149
+
150
+ For more information, see https://www.github.com/dodopayments/dodopayments-python#with_streaming_response
151
+ """
152
+ return AsyncCheckoutSessionsResourceWithStreamingResponse(self)
153
+
154
+ async def create(
155
+ self,
156
+ *,
157
+ product_cart: Iterable[checkout_session_create_params.ProductCart],
158
+ allowed_payment_method_types: Optional[List[PaymentMethodTypes]] | NotGiven = NOT_GIVEN,
159
+ billing_address: Optional[checkout_session_create_params.BillingAddress] | NotGiven = NOT_GIVEN,
160
+ billing_currency: Optional[Currency] | NotGiven = NOT_GIVEN,
161
+ confirm: bool | NotGiven = NOT_GIVEN,
162
+ customer: Optional[CustomerRequestParam] | NotGiven = NOT_GIVEN,
163
+ customization: checkout_session_create_params.Customization | NotGiven = NOT_GIVEN,
164
+ discount_code: Optional[str] | NotGiven = NOT_GIVEN,
165
+ feature_flags: checkout_session_create_params.FeatureFlags | NotGiven = NOT_GIVEN,
166
+ metadata: Optional[Dict[str, str]] | NotGiven = NOT_GIVEN,
167
+ return_url: Optional[str] | NotGiven = NOT_GIVEN,
168
+ show_saved_payment_methods: bool | NotGiven = NOT_GIVEN,
169
+ subscription_data: Optional[checkout_session_create_params.SubscriptionData] | NotGiven = NOT_GIVEN,
170
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
171
+ # The extra values given here take precedence over values defined on the client or passed to this method.
172
+ extra_headers: Headers | None = None,
173
+ extra_query: Query | None = None,
174
+ extra_body: Body | None = None,
175
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
176
+ ) -> CheckoutSessionResponse:
177
+ """
178
+ Args:
179
+ allowed_payment_method_types: Customers will never see payment methods that are not in this list. However,
180
+ adding a method here does not guarantee customers will see it. Availability
181
+ still depends on other factors (e.g., customer location, merchant settings).
182
+
183
+ Disclaimar: Always provide 'credit' and 'debit' as a fallback. If all payment
184
+ methods are unavailable, checkout session will fail.
185
+
186
+ billing_address: Billing address information for the session
187
+
188
+ billing_currency: This field is ingored if adaptive pricing is disabled
189
+
190
+ confirm: If confirm is true, all the details will be finalized. If required data is
191
+ missing, an API error is thrown.
192
+
193
+ customer: Customer details for the session
194
+
195
+ customization: Customization for the checkout session page
196
+
197
+ metadata: Additional metadata associated with the payment. Defaults to empty if not
198
+ provided.
199
+
200
+ return_url: The url to redirect after payment failure or success.
201
+
202
+ show_saved_payment_methods: Display saved payment methods of a returning customer False by default
203
+
204
+ extra_headers: Send extra headers
205
+
206
+ extra_query: Add additional query parameters to the request
207
+
208
+ extra_body: Add additional JSON properties to the request
209
+
210
+ timeout: Override the client-level default timeout for this request, in seconds
211
+ """
212
+ return await self._post(
213
+ "/checkouts",
214
+ body=await async_maybe_transform(
215
+ {
216
+ "product_cart": product_cart,
217
+ "allowed_payment_method_types": allowed_payment_method_types,
218
+ "billing_address": billing_address,
219
+ "billing_currency": billing_currency,
220
+ "confirm": confirm,
221
+ "customer": customer,
222
+ "customization": customization,
223
+ "discount_code": discount_code,
224
+ "feature_flags": feature_flags,
225
+ "metadata": metadata,
226
+ "return_url": return_url,
227
+ "show_saved_payment_methods": show_saved_payment_methods,
228
+ "subscription_data": subscription_data,
229
+ },
230
+ checkout_session_create_params.CheckoutSessionCreateParams,
231
+ ),
232
+ options=make_request_options(
233
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
234
+ ),
235
+ cast_to=CheckoutSessionResponse,
236
+ )
237
+
238
+
239
+ class CheckoutSessionsResourceWithRawResponse:
240
+ def __init__(self, checkout_sessions: CheckoutSessionsResource) -> None:
241
+ self._checkout_sessions = checkout_sessions
242
+
243
+ self.create = to_raw_response_wrapper(
244
+ checkout_sessions.create,
245
+ )
246
+
247
+
248
+ class AsyncCheckoutSessionsResourceWithRawResponse:
249
+ def __init__(self, checkout_sessions: AsyncCheckoutSessionsResource) -> None:
250
+ self._checkout_sessions = checkout_sessions
251
+
252
+ self.create = async_to_raw_response_wrapper(
253
+ checkout_sessions.create,
254
+ )
255
+
256
+
257
+ class CheckoutSessionsResourceWithStreamingResponse:
258
+ def __init__(self, checkout_sessions: CheckoutSessionsResource) -> None:
259
+ self._checkout_sessions = checkout_sessions
260
+
261
+ self.create = to_streamed_response_wrapper(
262
+ checkout_sessions.create,
263
+ )
264
+
265
+
266
+ class AsyncCheckoutSessionsResourceWithStreamingResponse:
267
+ def __init__(self, checkout_sessions: AsyncCheckoutSessionsResource) -> None:
268
+ self._checkout_sessions = checkout_sessions
269
+
270
+ self.create = async_to_streamed_response_wrapper(
271
+ checkout_sessions.create,
272
+ )
@@ -37,6 +37,7 @@ from ..types.payment_method_types import PaymentMethodTypes
37
37
  from ..types.billing_address_param import BillingAddressParam
38
38
  from ..types.customer_request_param import CustomerRequestParam
39
39
  from ..types.subscription_list_response import SubscriptionListResponse
40
+ from ..types.on_demand_subscription_param import OnDemandSubscriptionParam
40
41
  from ..types.subscription_charge_response import SubscriptionChargeResponse
41
42
  from ..types.subscription_create_response import SubscriptionCreateResponse
42
43
 
@@ -75,7 +76,7 @@ class SubscriptionsResource(SyncAPIResource):
75
76
  billing_currency: Optional[Currency] | NotGiven = NOT_GIVEN,
76
77
  discount_code: Optional[str] | NotGiven = NOT_GIVEN,
77
78
  metadata: Dict[str, str] | NotGiven = NOT_GIVEN,
78
- on_demand: Optional[subscription_create_params.OnDemand] | NotGiven = NOT_GIVEN,
79
+ on_demand: Optional[OnDemandSubscriptionParam] | NotGiven = NOT_GIVEN,
79
80
  payment_link: Optional[bool] | NotGiven = NOT_GIVEN,
80
81
  return_url: Optional[str] | NotGiven = NOT_GIVEN,
81
82
  show_saved_payment_methods: bool | NotGiven = NOT_GIVEN,
@@ -213,6 +214,8 @@ class SubscriptionsResource(SyncAPIResource):
213
214
  ) -> Subscription:
214
215
  """
215
216
  Args:
217
+ cancel_at_next_billing_date: When set, the subscription will remain active until the end of billing period
218
+
216
219
  extra_headers: Send extra headers
217
220
 
218
221
  extra_query: Add additional query parameters to the request
@@ -458,7 +461,7 @@ class AsyncSubscriptionsResource(AsyncAPIResource):
458
461
  billing_currency: Optional[Currency] | NotGiven = NOT_GIVEN,
459
462
  discount_code: Optional[str] | NotGiven = NOT_GIVEN,
460
463
  metadata: Dict[str, str] | NotGiven = NOT_GIVEN,
461
- on_demand: Optional[subscription_create_params.OnDemand] | NotGiven = NOT_GIVEN,
464
+ on_demand: Optional[OnDemandSubscriptionParam] | NotGiven = NOT_GIVEN,
462
465
  payment_link: Optional[bool] | NotGiven = NOT_GIVEN,
463
466
  return_url: Optional[str] | NotGiven = NOT_GIVEN,
464
467
  show_saved_payment_methods: bool | NotGiven = NOT_GIVEN,
@@ -596,6 +599,8 @@ class AsyncSubscriptionsResource(AsyncAPIResource):
596
599
  ) -> Subscription:
597
600
  """
598
601
  Args:
602
+ cancel_at_next_billing_date: When set, the subscription will remain active until the end of billing period
603
+
599
604
  extra_headers: Send extra headers
600
605
 
601
606
  extra_query: Add additional query parameters to the request