Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

## Conventions

- Uses `requests` library by default for sync HTTP, `httpx` for async
- Uses `requests` library by default for sync HTTP, `httpx2` (falling back to `httpx`) for async
- Type hints throughout
- Virtual env managed in `.venv/`; `just` recipes handle setup automatically
- Work is not complete until `just test`, `just lint` and `just typecheck` complete successfully.
Expand Down
101 changes: 101 additions & 0 deletions .hark/changes/2026-11-19_stripe-openapi_f73a4635.change.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CODEGEN_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5b1e713ce463b45ef5e0d44fe81667a61fd28115
f3581f76eec818aa658fd9635eaf0107d13e3441
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2600
v2602
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,12 @@ async for c in await stripe.Customer.list_async().auto_paging_iter():
There is no `.save_async` as `.save` is [deprecated since stripe-python v5](https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v5#deprecated). Please migrate to `.modify_async`.

The default HTTP client uses `requests` for making synchronous requests but
`httpx` for making async requests. If you're migrating to async, we recommend
you to explicitly initialize your own http client and pass it to StripeClient
or set it as the global default.
`httpx2` for making async requests, falling back to `httpx` if `httpx2` isn't
installed (and to `aiohttp` if neither is). We recommend `pip install httpx2`
for async use, since `httpx` is no longer actively maintained. `httpx` support
is deprecated and will be removed in the next major version of stripe-python.
If you're migrating to async, we recommend you to explicitly initialize your own
http client and pass it to StripeClient or set it as the global default.

If you don't already have a dependency on an async-compatible HTTP library, `pip install stripe[async]` will install one for you (new in `v13.0.1`).

Expand All @@ -382,7 +385,7 @@ If you don't already have a dependency on an async-compatible HTTP library, `pip
# make sure you don't unintentionally make a synchronous request.
my_http_client = stripe.HTTPXClient()

# If you want to use httpx to make sync requests, you can disable this
# If you want to use httpx2 to make sync requests, you can disable this
# behavior.
my_http_client = stripe.HTTPXClient(allow_sync_methods=True)

Expand Down
19 changes: 8 additions & 11 deletions deps/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# packages needed to run unit tests (including extra supported http libraries)
# version requirements: all supported versions (currently 3.6-3.12)
# version requirements: all supported versions (currently 3.9-3.14)

# This is the last version of httpx compatible with Python 3.6
httpx == 0.22.0; python_version == "3.6"
httpx >= 0.24.1; python_version == "3.7"
httpx >= 0.27.0; python_version >= "3.8"
aiohttp == 3.8.6; python_version <= "3.7"
aiohttp == 3.10.11; python_version == "3.8"
aiohttp == 3.12.15; python_version >= "3.9"
anyio[trio] == 3.6.2; python_version < "3.13"
anyio[trio] == 4.11.0; python_version >= "3.13"
httpx2 >= 2.0.0
# fallback when httpx2 isn't installed
# TODO: (DEVSDK-3427) remove httpx in the next major version
httpx >= 0.27.0
aiohttp == 3.12.15
# httpx2 requires anyio >= 4.10 since 2.9.0
anyio[trio] == 4.10.0

pytest-mock >= 2.0.0
mock >= 4.0; python_version < "3.8"
pytest-xdist >= 1.31.0
pytest >= 6.0.0,<9.0.0
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
13 changes: 13 additions & 0 deletions stripe/_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

from stripe._base_address import BaseAddress
from stripe._api_mode import ApiMode
from stripe._stripe_object import API_KEY_SERIALIZATION_CONSTANT

if TYPE_CHECKING:
from stripe._app_info import AppInfo
Expand Down Expand Up @@ -166,6 +167,12 @@ def _new_requestor_with_options(
"""
Returns a new _APIRequestor instance with the same HTTP client but a (potentially) updated set of options. Useful for ensuring the original isn't modified, but any options the original had are still used.
"""
if self.api_key == API_KEY_SERIALIZATION_CONSTANT:
raise error.AuthenticationError(
"This object was unpickled without API credentials. "
"Call reattach_api_key(api_key) on the object before making requests."
)

options = options or {}
new_options = self._options.to_dict()
for key in PERSISTENT_OPTIONS_KEYS:
Expand Down Expand Up @@ -702,6 +709,12 @@ def _args_for_request_with_retries(
"""
Mechanism for issuing an API call. Used by request_raw and request_raw_async.
"""
if self.api_key == API_KEY_SERIALIZATION_CONSTANT:
raise error.AuthenticationError(
"This object was unpickled without API credentials. "
"Call reattach_api_key(api_key) on the object before making requests."
)

request_options = merge_options(self._options, options)

# Special stripe_version handling for v2 requests:
Expand Down
2 changes: 1 addition & 1 deletion stripe/_api_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
class _ApiVersion:
CURRENT = "2026-10-28.preview"
CURRENT = "2026-11-18.preview"
CURRENT_MAJOR = ""
8 changes: 7 additions & 1 deletion stripe/_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,13 @@ class Crypto(StripeObject):
network: Optional[
Union[
Literal[
"base", "ethereum", "polygon", "solana", "sui", "tempo"
"base",
"ethereum",
"polygon",
"solana",
"sui",
"tempo",
"tron",
],
str,
]
Expand Down
24 changes: 23 additions & 1 deletion stripe/_coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ class CurrencyOptions(StripeObject):
Amount (in the `currency` specified) that will be taken off the subtotal of any invoices for this customer.
"""

class Custom(StripeObject):
class Extension(StripeObject):
id: str
"""
The Extension Prototype ID.
"""
version: str
"""
The semantic version of the extension.
"""

configuration: UntypedStripeObject[Any]
"""
The configuration supplied to the extension.
"""
extension: Extension
_inner_class_types = {"extension": Extension}

class Script(StripeObject):
configuration: UntypedStripeObject[Any]
"""
Expand Down Expand Up @@ -100,6 +118,7 @@ class Iterations(StripeObject):
"""
Coupons defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
"""
custom: Optional[Custom]
deleted: Optional[Literal[True]]
"""
Always true for a deleted object
Expand Down Expand Up @@ -155,7 +174,9 @@ class Iterations(StripeObject):
"""
Number of times this coupon has been applied to a customer.
"""
type: Optional[Union[Literal["amount_off", "percent_off", "script"], str]]
type: Optional[
Union[Literal["amount_off", "custom", "percent_off", "script"], str]
]
"""
The type of coupon logic used to calculate the discount.
"""
Expand Down Expand Up @@ -391,6 +412,7 @@ async def retrieve_async(
_inner_class_types = {
"applies_to": AppliesTo,
"currency_options": CurrencyOptions,
"custom": Custom,
"script": Script,
"service_period": ServicePeriod,
}
2 changes: 1 addition & 1 deletion stripe/_dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class SmartDisputes(StripeObject):
"""
balance_transactions: List["BalanceTransaction"]
"""
List of zero, one, or two balance transactions that show funds withdrawn and reinstated to your Stripe account as a result of this dispute.
List of balance transactions that show funds withdrawn and reinstated to your Stripe account as a result of this dispute.
"""
charge: ExpandableField["Charge"]
"""
Expand Down
6 changes: 3 additions & 3 deletions stripe/_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Request(StripeObject):
"""
pending_webhooks: int
"""
Number of webhooks that haven't been successfully delivered (for example, to return a 20x response) to the URLs you specify.
Number of webhooks that haven't been successfully delivered (for example, to return a 20x response). This count can include deliveries to endpoints that belong to Connect platforms or apps with access to your account. These endpoints don't appear when you list your account's webhook endpoints or event destinations. To see the delivery status for each endpoint, view the event in [Workbench](https://docs.stripe.com/workbench/overview#events).
"""
reason: Optional[Reason]
"""
Expand Down Expand Up @@ -472,7 +472,7 @@ class Request(StripeObject):
@classmethod
def list(cls, **params: Unpack["EventListParams"]) -> ListObject["Event"]:
"""
List events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in [event object](https://docs.stripe.com/api/events/object) api_version attribute (not according to your current Stripe API version or Stripe-Version header).
List events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in [event object api_version attribute (not according to your current Stripe API version or Stripe-Version header). The list includes only events for the account that makes the request. A platform's list doesn't include events from its connected accounts. To list a connected account's events, make the request <a href="https://docs.stripe.com/connect/authentication">as the connected account](https://docs.stripe.com/api/events/object) using the Stripe-Account header.
"""
result = cls._static_request(
"get",
Expand All @@ -492,7 +492,7 @@ async def list_async(
cls, **params: Unpack["EventListParams"]
) -> ListObject["Event"]:
"""
List events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in [event object](https://docs.stripe.com/api/events/object) api_version attribute (not according to your current Stripe API version or Stripe-Version header).
List events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in [event object api_version attribute (not according to your current Stripe API version or Stripe-Version header). The list includes only events for the account that makes the request. A platform's list doesn't include events from its connected accounts. To list a connected account's events, make the request <a href="https://docs.stripe.com/connect/authentication">as the connected account](https://docs.stripe.com/api/events/object) using the Stripe-Account header.
"""
result = await cls._static_request_async(
"get",
Expand Down
Loading