Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "pypy-3.7"
- "pypy-3.8"
- "pypy-3.9"
Expand Down
2 changes: 1 addition & 1 deletion API_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3602014a6583f6c0fbfdde3c575839ac7d0b4e9c
5abe0e44caedb3474ee672265284096ec89e0fa3
84 changes: 63 additions & 21 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2141
v2150
4 changes: 2 additions & 2 deletions stripe/_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def _api_encode(data) -> Generator[Tuple[str, Any], None, None]:
for key, value in data.items():
if value is None:
continue
elif hasattr(value, "stripe_id"):
yield (key, value.stripe_id)
elif hasattr(value, "id"):
yield (key, getattr(value, "id"))
elif isinstance(value, list) or isinstance(value, tuple):
for i, sv in enumerate(value):
# Always use indexed format for arrays
Expand Down
4 changes: 4 additions & 0 deletions stripe/_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,10 @@ class ScheduleDetails(StripeObject):
"""
The schedule that generated this invoice
"""
subscription: Optional[ExpandableField["Subscription"]]
"""
The subscription associated with this schedule
"""

class SubscriptionDetails(StripeObject):
class PauseCollection(StripeObject):
Expand Down
1 change: 1 addition & 0 deletions stripe/_object_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
"CalculationLineItem",
),
"tax.form": ("stripe.tax._form", "Form"),
"tax.location": ("stripe.tax._location", "Location"),
"tax.registration": ("stripe.tax._registration", "Registration"),
"tax.settings": ("stripe.tax._settings", "Settings"),
"tax.transaction": ("stripe.tax._transaction", "Transaction"),
Expand Down
4 changes: 4 additions & 0 deletions stripe/_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ class TransformUsage(StripeObject):
"""
Always true for a deleted object
"""
external_reference: Optional[str]
"""
A custom identifier for this price, such as a SKU number or product code, that can be used to reference records from external systems.
"""
id: str
"""
Unique identifier for the object.
Expand Down
4 changes: 4 additions & 0 deletions stripe/_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ class TransformQuantity(StripeObject):
"""
Always true for a deleted object
"""
external_reference: Optional[str]
"""
A custom identifier for this price, such as a SKU number or product code, that can be used to reference records from external systems.
"""
id: str
"""
Unique identifier for the object.
Expand Down
8 changes: 4 additions & 4 deletions stripe/_quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,10 @@ class Prebilling(StripeObject):
Set of [key-value pairs](https://docs.stripe.com/api/metadata) that will set metadata on the subscription or subscription schedule when the quote is accepted. If a recurring price is included in `line_items`, this field will be passed to the resulting subscription's `metadata` field. If `subscription_data.effective_date` is used, this field will be passed to the resulting subscription schedule's `phases.metadata` field. Unlike object-level metadata, this field is declarative. Updates will clear prior values.
"""
phase_effective_at: Optional[
Literal["billing_period_start", "line_start"]
Literal["billing_period_start", "phase_start"]
]
"""
Configures how the quote handles billing for line transitions. Possible values are `line_start` (default) or `billing_period_start`. `line_start` bills based on the current state of the line, ignoring changes scheduled for future lines. `billing_period_start` bills predictively for upcoming line transitions within the current billing cycle, including pricing changes and service period adjustments that will occur before the next invoice.
Configures how the subscription schedule handles billing for phase transitions when the quote is accepted.
"""
prebilling: Optional[Prebilling]
"""
Expand Down Expand Up @@ -1041,10 +1041,10 @@ class LineEndsAt(StripeObject):
Behavior of the subscription schedule and underlying subscription when it ends.
"""
phase_effective_at: Optional[
Literal["billing_period_start", "line_start"]
Literal["billing_period_start", "phase_start"]
]
"""
Configures how the quote handles billing for line transitions. Possible values are `line_start` (default) or `billing_period_start`. `line_start` bills based on the current state of the line, ignoring changes scheduled for future lines. `billing_period_start` bills predictively for upcoming line transitions within the current billing cycle, including pricing changes and service period adjustments that will occur before the next invoice.
Configures how the subscription schedule handles billing for phase transitions when the quote is accepted.
"""
proration_behavior: Optional[
Literal["always_invoice", "create_prorations", "none"]
Expand Down
2 changes: 1 addition & 1 deletion stripe/_quote_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class EndBehavior(StripeObject):
"""
effective_at: Optional[Literal["billing_period_start", "line_start"]]
"""
Configures how the subscription schedule handles billing for phase transitions. Possible values are `phase_start` (default) or `billing_period_start`. `phase_start` bills based on the current state of the subscription, ignoring changes scheduled in future phases. `billing_period_start` bills predictively for upcoming phase transitions within the current billing cycle, including pricing changes and service period adjustments that will occur before the next invoice.
Configures how the subscription schedule handles billing for phase transitions.
"""
ends_at: Optional[EndsAt]
"""
Expand Down
4 changes: 4 additions & 0 deletions stripe/_quote_preview_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,10 @@ class ScheduleDetails(StripeObject):
"""
The schedule that generated this invoice
"""
subscription: Optional[ExpandableField["Subscription"]]
"""
The subscription associated with this schedule
"""

class SubscriptionDetails(StripeObject):
class PauseCollection(StripeObject):
Expand Down
113 changes: 113 additions & 0 deletions stripe/_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
from stripe.params._subscription_modify_params import (
SubscriptionModifyParams,
)
from stripe.params._subscription_pause_params import (
SubscriptionPauseParams,
)
from stripe.params._subscription_resume_params import (
SubscriptionResumeParams,
)
Expand Down Expand Up @@ -1629,6 +1632,116 @@ async def modify_async(
),
)

@classmethod
def _cls_pause(
cls, subscription: str, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
return cast(
"Subscription",
cls._static_request(
"post",
"/v1/subscriptions/{subscription}/pause".format(
subscription=sanitize_id(subscription)
),
params=params,
),
)

@overload
@staticmethod
def pause(
subscription: str, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
...

@overload
def pause(
self, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
...

@class_method_variant("_cls_pause")
def pause( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
return cast(
"Subscription",
self._request(
"post",
"/v1/subscriptions/{subscription}/pause".format(
subscription=sanitize_id(self.get("id"))
),
params=params,
),
)

@classmethod
async def _cls_pause_async(
cls, subscription: str, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
return cast(
"Subscription",
await cls._static_request_async(
"post",
"/v1/subscriptions/{subscription}/pause".format(
subscription=sanitize_id(subscription)
),
params=params,
),
)

@overload
@staticmethod
async def pause_async(
subscription: str, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
...

@overload
async def pause_async(
self, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
...

@class_method_variant("_cls_pause_async")
async def pause_async( # pyright: ignore[reportGeneralTypeIssues]
self, **params: Unpack["SubscriptionPauseParams"]
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
return cast(
"Subscription",
await self._request_async(
"post",
"/v1/subscriptions/{subscription}/pause".format(
subscription=sanitize_id(self.get("id"))
),
params=params,
),
)

@classmethod
def _cls_resume(
cls, subscription: str, **params: Unpack["SubscriptionResumeParams"]
Expand Down
47 changes: 47 additions & 0 deletions stripe/_subscription_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
from stripe.params._subscription_migrate_params import (
SubscriptionMigrateParams,
)
from stripe.params._subscription_pause_params import (
SubscriptionPauseParams,
)
from stripe.params._subscription_resume_params import (
SubscriptionResumeParams,
)
Expand Down Expand Up @@ -502,6 +505,50 @@ async def migrate_async(
),
)

def pause(
self,
subscription: str,
params: "SubscriptionPauseParams",
options: Optional["RequestOptions"] = None,
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
return cast(
"Subscription",
self._request(
"post",
"/v1/subscriptions/{subscription}/pause".format(
subscription=sanitize_id(subscription),
),
base_address="api",
params=params,
options=options,
),
)

async def pause_async(
self,
subscription: str,
params: "SubscriptionPauseParams",
options: Optional["RequestOptions"] = None,
) -> "Subscription":
"""
Pauses a subscription by transitioning it to the paused status. A paused subscription does not generate invoices and will not advance to new billing periods. The subscription can be resumed later using the resume endpoint. Cannot pause subscriptions with attached schedules.
"""
return cast(
"Subscription",
await self._request_async(
"post",
"/v1/subscriptions/{subscription}/pause".format(
subscription=sanitize_id(subscription),
),
base_address="api",
params=params,
options=options,
),
)

def resume(
self,
subscription: str,
Expand Down
16 changes: 15 additions & 1 deletion stripe/_tax_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# File generated from our OpenAPI spec
from stripe._list_object import ListObject
from stripe._listable_api_resource import ListableAPIResource
from typing import ClassVar
from stripe._stripe_object import StripeObject
from typing import ClassVar, Optional
from typing_extensions import Literal, Unpack, TYPE_CHECKING

if TYPE_CHECKING:
Expand All @@ -16,6 +17,13 @@ class TaxCode(ListableAPIResource["TaxCode"]):
"""

OBJECT_NAME: ClassVar[Literal["tax_code"]] = "tax_code"

class Requirements(StripeObject):
performance_location: Optional[Literal["optional", "required"]]
"""
Describes whether a performance location is required for a successful tax calculation with a tax code.
"""

description: str
"""
A detailed description of which types of products the tax code represents.
Expand All @@ -32,6 +40,10 @@ class TaxCode(ListableAPIResource["TaxCode"]):
"""
String representing the object's type. Objects of the same type share the same value.
"""
requirements: Optional[Requirements]
"""
An object that describes more information about the tax location required for this tax code. Some [tax codes](https://docs.stripe.com/tax/tax-for-tickets/integration-guide#types-of-products) require a tax location of type `performance` to calculate tax correctly.
"""

@classmethod
def list(
Expand Down Expand Up @@ -94,3 +106,5 @@ async def retrieve_async(
instance = cls(id, **params)
await instance.refresh_async()
return instance

_inner_class_types = {"requirements": Requirements}
3 changes: 3 additions & 0 deletions stripe/_tax_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from stripe.tax._association_service import AssociationService
from stripe.tax._calculation_service import CalculationService
from stripe.tax._form_service import FormService
from stripe.tax._location_service import LocationService
from stripe.tax._registration_service import RegistrationService
from stripe.tax._settings_service import SettingsService
from stripe.tax._transaction_service import TransactionService
Expand All @@ -16,6 +17,7 @@
"associations": ["stripe.tax._association_service", "AssociationService"],
"calculations": ["stripe.tax._calculation_service", "CalculationService"],
"forms": ["stripe.tax._form_service", "FormService"],
"locations": ["stripe.tax._location_service", "LocationService"],
"registrations": [
"stripe.tax._registration_service",
"RegistrationService",
Expand All @@ -29,6 +31,7 @@ class TaxService(StripeService):
associations: "AssociationService"
calculations: "CalculationService"
forms: "FormService"
locations: "LocationService"
registrations: "RegistrationService"
settings: "SettingsService"
transactions: "TransactionService"
Expand Down
Loading