diff --git a/.hark/changes/2026-09-23_stripe-openapi_8c46e42d.change.md b/.hark/changes/2026-09-23_stripe-openapi_8c46e42d.change.md new file mode 100644 index 000000000..fd51eea83 --- /dev/null +++ b/.hark/changes/2026-09-23_stripe-openapi_8c46e42d.change.md @@ -0,0 +1,8 @@ +--- +title: Update generated code +pr_url: https://github.com/stripe/stripe-python/pull/1892 +semver_level: minor +is_stripe_api_change: true +--- + +* Release specs are identical. diff --git a/CODEGEN_VERSION b/CODEGEN_VERSION index 308945cbf..9dab51668 100644 --- a/CODEGEN_VERSION +++ b/CODEGEN_VERSION @@ -1 +1 @@ -baff58c9d515cdd5f5c3231d101989d588788c6f \ No newline at end of file +c6e6c59f2abca2e655c05194c60737d51f7e704f \ No newline at end of file diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 28d67d2bf..da9b3a5de 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v2442 \ No newline at end of file +v2516 \ No newline at end of file diff --git a/README.md b/README.md index 8b40fd997..f851cec19 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,10 @@ There are a few options for enabling it: logging.getLogger('stripe').setLevel(logging.DEBUG) ``` +### Suppressing Stripe notices + +The SDK may print notices from Stripe that it receives in the `Stripe-Notice` header. These notices are always printed when the SDK runs in an agent environment. For API calls to test accounts or sandboxes, notices are also printed when the SDK runs outside an agent environment. To suppress notices when the SDK runs outside an agent environment, set the `STRIPE_SUPPRESS_NOTICES` environment variable to `true` before running your integration. + ### Accessing response code and headers You can access the HTTP response code and headers using the `last_response` property of the returned resource. diff --git a/examples/async_event_notification_handler_endpoint.py b/examples/async_event_notification_handler_endpoint.py index 2cad998ed..3a7f6a9ec 100644 --- a/examples/async_event_notification_handler_endpoint.py +++ b/examples/async_event_notification_handler_endpoint.py @@ -22,7 +22,7 @@ app = FastAPI() api_key = os.environ.get("STRIPE_API_KEY", "") -webhook_secret = os.environ.get("WEBHOOK_SECRET", "") +webhook_secret = os.environ["WEBHOOK_SECRET"] # Webhooks can be delivered more than once, so we track ids we've already # processed. In production, back this with something durable and shared diff --git a/examples/event_notification_handler_endpoint.py b/examples/event_notification_handler_endpoint.py index 115ed2f0d..b15f64201 100644 --- a/examples/event_notification_handler_endpoint.py +++ b/examples/event_notification_handler_endpoint.py @@ -20,7 +20,7 @@ app = Flask(__name__) api_key = os.environ.get("STRIPE_API_KEY", "") -webhook_secret = os.environ.get("WEBHOOK_SECRET", "") +webhook_secret = os.environ["WEBHOOK_SECRET"] # Webhooks can be delivered more than once, so we track ids we've already # processed. In production, back this with something durable and shared diff --git a/examples/event_notification_webhook_handler.py b/examples/event_notification_webhook_handler.py index 16264a997..a9d288455 100644 --- a/examples/event_notification_webhook_handler.py +++ b/examples/event_notification_webhook_handler.py @@ -27,7 +27,7 @@ app = Flask(__name__) api_key = os.environ.get("STRIPE_API_KEY", "") -webhook_secret = os.environ.get("WEBHOOK_SECRET", "") +webhook_secret = os.environ["WEBHOOK_SECRET"] client = StripeClient(api_key) diff --git a/examples/webhooks.py b/examples/webhooks.py index 79352b1a6..5f393bf00 100644 --- a/examples/webhooks.py +++ b/examples/webhooks.py @@ -6,7 +6,7 @@ # this is for handling v1-style Snapshot Events. # To handle v2-style Events, see `event_notification_webhook_handler.py` -webhook_secret = os.environ.get("WEBHOOK_SECRET") +webhook_secret = os.environ["WEBHOOK_SECRET"] app = Flask(__name__) diff --git a/pyproject.toml b/pyproject.toml index 8be39ba70..c37c6b01f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ reportUnnecessaryComparison = true reportUnnecessaryContains = true reportUnnecessaryIsInstance = true reportPrivateImportUsage = true -reportUnnecessaryTypeIgnoreComment = true +reportUnnecessaryTypeIgnoreComment = false [tool.mypy] follow_imports = "silent" diff --git a/stripe/_api_requestor.py b/stripe/_api_requestor.py index 0a9226dae..b1803e7c3 100644 --- a/stripe/_api_requestor.py +++ b/stripe/_api_requestor.py @@ -72,12 +72,31 @@ _default_proxy: Optional[str] = None -def _maybe_emit_stripe_notice(rheaders: Mapping[str, str]) -> None: +def _maybe_emit_stripe_notice( + rheaders: Mapping[str, str], + environ: Optional[Mapping[str, str]] = None, +) -> None: notice = rheaders.get("Stripe-Notice") - if notice: - import warnings + if not notice: + return + + environ = os.environ if environ is None else environ + ai_agent = _APIRequestor._detect_ai_agent(environ) + if ( + not ai_agent + and environ.get("STRIPE_SUPPRESS_NOTICES", "").lower() == "true" + ): + return + + if not ai_agent: + notice += ( + "\nTo suppress Stripe notices in test and sandbox environments, " + "set the STRIPE_SUPPRESS_NOTICES environment variable to true." + ) + + import warnings - warnings.warn(notice) + warnings.warn(notice) def is_v2_delete_resp(method: str, api_mode: ApiMode) -> bool: @@ -535,6 +554,7 @@ def specific_oauth_error(self, rbody, rcode, resp, rheaders, error_code): ("CODEX_CI", "codex_cli"), ("CURSOR_AGENT", "cursor"), ("GEMINI_CLI", "gemini_cli"), + ("HERMES_AGENT", "hermes"), ("OPENCLAW_SHELL", "openclaw"), ("OPENCODE", "open_code"), # aiAgents: The end of the section generated from our OpenAPI spec diff --git a/stripe/_discount.py b/stripe/_discount.py index d62b10208..3f034e979 100644 --- a/stripe/_discount.py +++ b/stripe/_discount.py @@ -2,7 +2,7 @@ # File generated from our OpenAPI spec from stripe._expandable_field import ExpandableField from stripe._stripe_object import StripeObject -from typing import ClassVar, Optional +from typing import ClassVar, Optional, Union from typing_extensions import Literal, TYPE_CHECKING if TYPE_CHECKING: @@ -26,7 +26,7 @@ class Source(StripeObject): """ The coupon that was redeemed to create this discount. """ - type: Literal["coupon"] + type: Union[Literal["coupon"], str] """ The source type of the discount. """ diff --git a/stripe/_order.py b/stripe/_order.py index c0f36bcc9..11a60bfb0 100644 --- a/stripe/_order.py +++ b/stripe/_order.py @@ -557,7 +557,7 @@ class WechatPay(StripeObject): """ The client type that the end customer will pay from """ - setup_future_usage: Optional[Literal["none"]] + setup_future_usage: Optional[Union[Literal["none"], str]] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/_payment_attempt_record.py b/stripe/_payment_attempt_record.py index 4957deb3a..c05ccc110 100644 --- a/stripe/_payment_attempt_record.py +++ b/stripe/_payment_attempt_record.py @@ -280,7 +280,7 @@ class Card(StripeObject): """ card: Optional[Card] - type: Optional[Literal["card"]] + type: Optional[Union[Literal["card"], str]] """ funding type of the underlying payment method. """ @@ -1826,7 +1826,7 @@ class Card(StripeObject): """ card: Optional[Card] - type: Optional[Literal["card"]] + type: Optional[Union[Literal["card"], str]] """ Funding type of the underlying payment method. """ diff --git a/stripe/_payment_intent.py b/stripe/_payment_intent.py index 748c84714..a90fe4e24 100644 --- a/stripe/_payment_intent.py +++ b/stripe/_payment_intent.py @@ -4417,7 +4417,7 @@ class WechatPay(StripeObject): """ The client type that the end customer will pay from """ - setup_future_usage: Optional[Literal["none"]] + setup_future_usage: Optional[Union[Literal["none"], str]] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/_payment_record.py b/stripe/_payment_record.py index 777f8970e..47988625b 100644 --- a/stripe/_payment_record.py +++ b/stripe/_payment_record.py @@ -300,7 +300,7 @@ class Card(StripeObject): """ card: Optional[Card] - type: Optional[Literal["card"]] + type: Optional[Union[Literal["card"], str]] """ funding type of the underlying payment method. """ @@ -1846,7 +1846,7 @@ class Card(StripeObject): """ card: Optional[Card] - type: Optional[Literal["card"]] + type: Optional[Union[Literal["card"], str]] """ Funding type of the underlying payment method. """ diff --git a/stripe/_stripe_client.py b/stripe/_stripe_client.py index e0115b127..dfd53af55 100644 --- a/stripe/_stripe_client.py +++ b/stripe/_stripe_client.py @@ -363,7 +363,6 @@ def with_stripe_context( """ return StripeClient( api_key=self._requestor.api_key, # type: ignore - stripe_account=self._requestor._options.stripe_account, stripe_context=stripe_context, stripe_version=self._requestor._options.stripe_version, base_addresses=self._requestor._options.base_addresses, diff --git a/stripe/_subscription.py b/stripe/_subscription.py index 1ba407dc3..15c8d05e9 100644 --- a/stripe/_subscription.py +++ b/stripe/_subscription.py @@ -868,7 +868,7 @@ class Subscription(StripeObject): """ Unix timestamp in seconds of when the subscription status transitioned to `paused`. """ - type: Literal["subscription"] + type: Union[Literal["subscription"], str] """ The type of pause. """ diff --git a/stripe/checkout/_session.py b/stripe/checkout/_session.py index 317ceea07..6aa745f45 100644 --- a/stripe/checkout/_session.py +++ b/stripe/checkout/_session.py @@ -1019,7 +1019,7 @@ class AfterpayClearpay(StripeObject): """ class Alipay(StripeObject): - setup_future_usage: Optional[Literal["none"]] + setup_future_usage: Optional[Union[Literal["none"], str]] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -1993,7 +1993,7 @@ class WechatPay(StripeObject): """ The client type that the end customer will pay from """ - setup_future_usage: Optional[Literal["none"]] + setup_future_usage: Optional[Union[Literal["none"], str]] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/events/_v2_core_account_including_configuration_customer_capability_status_updated_event.py b/stripe/events/_v2_core_account_including_configuration_customer_capability_status_updated_event.py index e15b8704b..ebb479694 100644 --- a/stripe/events/_v2_core_account_including_configuration_customer_capability_status_updated_event.py +++ b/stripe/events/_v2_core_account_including_configuration_customer_capability_status_updated_event.py @@ -5,7 +5,7 @@ from stripe._stripe_response import StripeResponse from stripe._util import get_api_mode from stripe.v2.core._event import Event, EventNotification, RelatedObject -from typing import Any, Dict, Optional, cast +from typing import Any, Dict, Optional, Union, cast from typing_extensions import Literal, TYPE_CHECKING, override if TYPE_CHECKING: @@ -98,7 +98,7 @@ class V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEvent( class V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEventData( StripeObject, ): - updated_capability: Literal["automatic_indirect_tax"] + updated_capability: Union[Literal["automatic_indirect_tax"], str] """ Open Enum. The capability which had its status updated. """ diff --git a/stripe/params/_invoice_create_preview_params.py b/stripe/params/_invoice_create_preview_params.py index 0d0c69c32..2317f8014 100644 --- a/stripe/params/_invoice_create_preview_params.py +++ b/stripe/params/_invoice_create_preview_params.py @@ -2268,7 +2268,7 @@ class InvoiceCreatePreviewParamsSubscriptionDetailsPause(TypedDict): """ Determines how to handle debits and credits when pausing. Defaults to `pending_invoice_item`. """ - type: NotRequired[Literal["subscription"]] + type: NotRequired["Literal['subscription']|str"] """ The type of pause to apply. Defaults to `subscription`. """ diff --git a/stripe/params/_order_create_params.py b/stripe/params/_order_create_params.py index 39dbcf848..3197039e7 100644 --- a/stripe/params/_order_create_params.py +++ b/stripe/params/_order_create_params.py @@ -2081,7 +2081,7 @@ class OrderCreateParamsPaymentSettingsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_order_modify_params.py b/stripe/params/_order_modify_params.py index 16f082804..db9e40be3 100644 --- a/stripe/params/_order_modify_params.py +++ b/stripe/params/_order_modify_params.py @@ -2091,7 +2091,7 @@ class OrderModifyParamsPaymentSettingsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_order_update_params.py b/stripe/params/_order_update_params.py index f4583aedf..e9c574fea 100644 --- a/stripe/params/_order_update_params.py +++ b/stripe/params/_order_update_params.py @@ -2090,7 +2090,7 @@ class OrderUpdateParamsPaymentSettingsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_payment_intent_confirm_params.py b/stripe/params/_payment_intent_confirm_params.py index a916e3e84..390608292 100644 --- a/stripe/params/_payment_intent_confirm_params.py +++ b/stripe/params/_payment_intent_confirm_params.py @@ -6590,7 +6590,7 @@ class PaymentIntentConfirmParamsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_payment_intent_create_params.py b/stripe/params/_payment_intent_create_params.py index ba1c4df03..6315b9ee2 100644 --- a/stripe/params/_payment_intent_create_params.py +++ b/stripe/params/_payment_intent_create_params.py @@ -6710,7 +6710,7 @@ class PaymentIntentCreateParamsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_payment_intent_modify_params.py b/stripe/params/_payment_intent_modify_params.py index fea6c40b0..ce4fe5325 100644 --- a/stripe/params/_payment_intent_modify_params.py +++ b/stripe/params/_payment_intent_modify_params.py @@ -6563,7 +6563,7 @@ class PaymentIntentModifyParamsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_payment_intent_update_params.py b/stripe/params/_payment_intent_update_params.py index 9a0356742..4dd4609de 100644 --- a/stripe/params/_payment_intent_update_params.py +++ b/stripe/params/_payment_intent_update_params.py @@ -6562,7 +6562,7 @@ class PaymentIntentUpdateParamsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/_subscription_pause_params.py b/stripe/params/_subscription_pause_params.py index 8bd4a447e..41e9e5257 100644 --- a/stripe/params/_subscription_pause_params.py +++ b/stripe/params/_subscription_pause_params.py @@ -20,7 +20,7 @@ class SubscriptionPauseParams(RequestOptions): """ Determines how to handle debits and credits when pausing. Defaults to `pending_invoice_item`. """ - type: NotRequired[Literal["subscription"]] + type: NotRequired["Literal['subscription']|str"] """ The type of pause to apply. Defaults to `subscription`. """ diff --git a/stripe/params/checkout/_session_create_params.py b/stripe/params/checkout/_session_create_params.py index 71d083fbc..bd1004ef1 100644 --- a/stripe/params/checkout/_session_create_params.py +++ b/stripe/params/checkout/_session_create_params.py @@ -1541,7 +1541,7 @@ class SessionCreateParamsPaymentMethodOptionsAfterpayClearpay(TypedDict): class SessionCreateParamsPaymentMethodOptionsAlipay(TypedDict): - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -2615,7 +2615,7 @@ class SessionCreateParamsPaymentMethodOptionsWechatPay(TypedDict): """ The client type that the end customer will pay from """ - setup_future_usage: NotRequired[Literal["none"]] + setup_future_usage: NotRequired["Literal['none']|str"] """ Indicates that you intend to make future payments with this PaymentIntent's payment method. diff --git a/stripe/params/tax/_registration_create_params.py b/stripe/params/tax/_registration_create_params.py index dd0aa8138..93bc71f1d 100644 --- a/stripe/params/tax/_registration_create_params.py +++ b/stripe/params/tax/_registration_create_params.py @@ -2060,7 +2060,7 @@ class RegistrationCreateParamsCountryOptionsSrStandard(TypedDict): class RegistrationCreateParamsCountryOptionsTh(TypedDict): - type: Literal["simplified"] + type: Union[Literal["simplified"], str] """ Type of registration to be created in `country`. """ diff --git a/stripe/params/v2/billing/_cadence_list_params.py b/stripe/params/v2/billing/_cadence_list_params.py index ee791b64b..8b87cbb0f 100644 --- a/stripe/params/v2/billing/_cadence_list_params.py +++ b/stripe/params/v2/billing/_cadence_list_params.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec -from typing import List +from typing import List, Union from typing_extensions import Literal, NotRequired, TypedDict class CadenceListParams(TypedDict): - include: NotRequired[List[Literal["settings_data"]]] + include: NotRequired[List[Union[Literal["settings_data"], str]]] """ Additional resource to include in the response. """ @@ -35,7 +35,7 @@ class CadenceListParamsPayer(TypedDict): """ The ID of the Customer object. If provided, only cadences that specifically reference the provided customer ID will be returned. """ - type: Literal["customer"] + type: Union[Literal["customer"], str] """ A string identifying the type of the payer. Currently the only supported value is `customer`. """ diff --git a/stripe/params/v2/billing/_cadence_retrieve_params.py b/stripe/params/v2/billing/_cadence_retrieve_params.py index 8324c83d1..2629799cc 100644 --- a/stripe/params/v2/billing/_cadence_retrieve_params.py +++ b/stripe/params/v2/billing/_cadence_retrieve_params.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec -from typing import List +from typing import List, Union from typing_extensions import Literal, NotRequired, TypedDict class CadenceRetrieveParams(TypedDict): - include: NotRequired[List[Literal["settings_data"]]] + include: NotRequired[List[Union[Literal["settings_data"], str]]] """ Additional resource to include in the response. """ diff --git a/stripe/params/v2/billing/_collection_setting_create_params.py b/stripe/params/v2/billing/_collection_setting_create_params.py index 9d8c260af..7ef3011f0 100644 --- a/stripe/params/v2/billing/_collection_setting_create_params.py +++ b/stripe/params/v2/billing/_collection_setting_create_params.py @@ -180,7 +180,7 @@ class CollectionSettingCreateParamsPaymentMethodOptionsCustomerBalance( """ Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. """ - funding_type: NotRequired[Literal["bank_transfer"]] + funding_type: NotRequired["Literal['bank_transfer']|str"] """ The funding method type to be used when there are not enough funds in the customer balance. Currently the only supported value is `bank_transfer`. """ diff --git a/stripe/params/v2/billing/_collection_setting_update_params.py b/stripe/params/v2/billing/_collection_setting_update_params.py index f9878966d..89c19dc4a 100644 --- a/stripe/params/v2/billing/_collection_setting_update_params.py +++ b/stripe/params/v2/billing/_collection_setting_update_params.py @@ -186,7 +186,7 @@ class CollectionSettingUpdateParamsPaymentMethodOptionsCustomerBalance( """ Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. """ - funding_type: NotRequired[Literal["bank_transfer"]] + funding_type: NotRequired["Literal['bank_transfer']|str"] """ The funding method type to be used when there are not enough funds in the customer balance. Currently the only supported value is `bank_transfer`. """ diff --git a/stripe/params/v2/billing/_meter_event_adjustment_create_params.py b/stripe/params/v2/billing/_meter_event_adjustment_create_params.py index b39cc81f2..2de4e99d4 100644 --- a/stripe/params/v2/billing/_meter_event_adjustment_create_params.py +++ b/stripe/params/v2/billing/_meter_event_adjustment_create_params.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec +from typing import Union from typing_extensions import Literal, TypedDict @@ -12,7 +13,7 @@ class MeterEventAdjustmentCreateParams(TypedDict): """ The name of the meter event. Corresponds with the `event_name` field on a meter. """ - type: Literal["cancel"] + type: Union[Literal["cancel"], str] """ Specifies the type of cancellation. Currently supports canceling a single event. """ diff --git a/stripe/params/v2/core/_account_create_params.py b/stripe/params/v2/core/_account_create_params.py index 8a52e2cc5..837b4f0e2 100644 --- a/stripe/params/v2/core/_account_create_params.py +++ b/stripe/params/v2/core/_account_create_params.py @@ -2210,7 +2210,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsBankAccountOwnershipVer """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2223,7 +2223,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsCompanyLicense( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2236,7 +2236,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsCompanyMemorandumOfAsso """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2249,7 +2249,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsCompanyMinisterialDecre """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2262,7 +2262,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsCompanyRegistrationVeri """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2275,7 +2275,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsCompanyTaxIdVerificatio """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2288,7 +2288,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsPrimaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -2314,7 +2314,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsProofOfAddress( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2333,7 +2333,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsProofOfRegistration( """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2361,7 +2361,7 @@ class AccountCreateParamsIdentityBusinessDetailsDocumentsProofOfUltimateBenefici """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2865,7 +2865,7 @@ class AccountCreateParamsIdentityIndividualDocumentsCompanyAuthorization( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2876,7 +2876,7 @@ class AccountCreateParamsIdentityIndividualDocumentsPassport(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2889,7 +2889,7 @@ class AccountCreateParamsIdentityIndividualDocumentsPrimaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -2915,7 +2915,7 @@ class AccountCreateParamsIdentityIndividualDocumentsSecondaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -2939,7 +2939,7 @@ class AccountCreateParamsIdentityIndividualDocumentsVisa(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/params/v2/core/_account_token_create_params.py b/stripe/params/v2/core/_account_token_create_params.py index 9a7025f73..6cfc56b0d 100644 --- a/stripe/params/v2/core/_account_token_create_params.py +++ b/stripe/params/v2/core/_account_token_create_params.py @@ -392,7 +392,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsBankAccountOwnersh """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -405,7 +405,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsCompanyLicense( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -418,7 +418,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsCompanyMemorandumO """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -431,7 +431,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsCompanyMinisterial """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -444,7 +444,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsCompanyRegistratio """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -457,7 +457,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsCompanyTaxIdVerifi """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -470,7 +470,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsPrimaryVerificatio """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -496,7 +496,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsProofOfAddress( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -515,7 +515,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsProofOfRegistratio """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -543,7 +543,7 @@ class AccountTokenCreateParamsIdentityBusinessDetailsDocumentsProofOfUltimateBen """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -1063,7 +1063,7 @@ class AccountTokenCreateParamsIdentityIndividualDocumentsCompanyAuthorization( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -1074,7 +1074,7 @@ class AccountTokenCreateParamsIdentityIndividualDocumentsPassport(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -1087,7 +1087,7 @@ class AccountTokenCreateParamsIdentityIndividualDocumentsPrimaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -1113,7 +1113,7 @@ class AccountTokenCreateParamsIdentityIndividualDocumentsSecondaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -1137,7 +1137,7 @@ class AccountTokenCreateParamsIdentityIndividualDocumentsVisa(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/params/v2/core/_account_update_params.py b/stripe/params/v2/core/_account_update_params.py index 27098b211..360a700e2 100644 --- a/stripe/params/v2/core/_account_update_params.py +++ b/stripe/params/v2/core/_account_update_params.py @@ -2267,7 +2267,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsBankAccountOwnershipVer """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2280,7 +2280,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsCompanyLicense( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2293,7 +2293,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsCompanyMemorandumOfAsso """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2306,7 +2306,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsCompanyMinisterialDecre """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2319,7 +2319,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsCompanyRegistrationVeri """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2332,7 +2332,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsCompanyTaxIdVerificatio """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2345,7 +2345,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsPrimaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -2371,7 +2371,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsProofOfAddress( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2390,7 +2390,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsProofOfRegistration( """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2418,7 +2418,7 @@ class AccountUpdateParamsIdentityBusinessDetailsDocumentsProofOfUltimateBenefici """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2924,7 +2924,7 @@ class AccountUpdateParamsIdentityIndividualDocumentsCompanyAuthorization( """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2935,7 +2935,7 @@ class AccountUpdateParamsIdentityIndividualDocumentsPassport(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -2948,7 +2948,7 @@ class AccountUpdateParamsIdentityIndividualDocumentsPrimaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -2974,7 +2974,7 @@ class AccountUpdateParamsIdentityIndividualDocumentsSecondaryVerification( """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -2998,7 +2998,7 @@ class AccountUpdateParamsIdentityIndividualDocumentsVisa(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/params/v2/core/_event_destination_list_params.py b/stripe/params/v2/core/_event_destination_list_params.py index c0320468a..d0cd324a3 100644 --- a/stripe/params/v2/core/_event_destination_list_params.py +++ b/stripe/params/v2/core/_event_destination_list_params.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec -from typing import List +from typing import List, Union from typing_extensions import Literal, NotRequired, TypedDict class EventDestinationListParams(TypedDict): - include: NotRequired[List[Literal["webhook_endpoint.url"]]] + include: NotRequired[List[Union[Literal["webhook_endpoint.url"], str]]] """ Additional fields to include in the response. Currently supports `webhook_endpoint.url`. """ diff --git a/stripe/params/v2/core/_event_destination_retrieve_params.py b/stripe/params/v2/core/_event_destination_retrieve_params.py index d43606b1d..ad0200416 100644 --- a/stripe/params/v2/core/_event_destination_retrieve_params.py +++ b/stripe/params/v2/core/_event_destination_retrieve_params.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec -from typing import List +from typing import List, Union from typing_extensions import Literal, NotRequired, TypedDict class EventDestinationRetrieveParams(TypedDict): - include: NotRequired[List[Literal["webhook_endpoint.url"]]] + include: NotRequired[List[Union[Literal["webhook_endpoint.url"], str]]] """ Additional fields to include in the response. """ diff --git a/stripe/params/v2/core/_event_destination_update_params.py b/stripe/params/v2/core/_event_destination_update_params.py index bc0feb0b8..b9b59ba83 100644 --- a/stripe/params/v2/core/_event_destination_update_params.py +++ b/stripe/params/v2/core/_event_destination_update_params.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec from stripe._stripe_object import UntypedStripeObject -from typing import Dict, List, Optional +from typing import Dict, List, Optional, Union from typing_extensions import Literal, NotRequired, TypedDict @@ -14,7 +14,7 @@ class EventDestinationUpdateParams(TypedDict): """ The list of events to enable for this endpoint. """ - include: NotRequired[List[Literal["webhook_endpoint.url"]]] + include: NotRequired[List[Union[Literal["webhook_endpoint.url"], str]]] """ Additional fields to include in the response. Currently supports `webhook_endpoint.url`. """ diff --git a/stripe/params/v2/core/accounts/_person_create_params.py b/stripe/params/v2/core/accounts/_person_create_params.py index 4e7b02531..74e36cf35 100644 --- a/stripe/params/v2/core/accounts/_person_create_params.py +++ b/stripe/params/v2/core/accounts/_person_create_params.py @@ -245,7 +245,7 @@ class PersonCreateParamsDocumentsCompanyAuthorization(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -256,7 +256,7 @@ class PersonCreateParamsDocumentsPassport(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -267,7 +267,7 @@ class PersonCreateParamsDocumentsPrimaryVerification(TypedDict): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -289,7 +289,7 @@ class PersonCreateParamsDocumentsSecondaryVerification(TypedDict): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -311,7 +311,7 @@ class PersonCreateParamsDocumentsVisa(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/params/v2/core/accounts/_person_token_create_params.py b/stripe/params/v2/core/accounts/_person_token_create_params.py index 15a321f83..3b1b8fc23 100644 --- a/stripe/params/v2/core/accounts/_person_token_create_params.py +++ b/stripe/params/v2/core/accounts/_person_token_create_params.py @@ -239,7 +239,7 @@ class PersonTokenCreateParamsDocumentsCompanyAuthorization(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -250,7 +250,7 @@ class PersonTokenCreateParamsDocumentsPassport(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -261,7 +261,7 @@ class PersonTokenCreateParamsDocumentsPrimaryVerification(TypedDict): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -285,7 +285,7 @@ class PersonTokenCreateParamsDocumentsSecondaryVerification(TypedDict): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -309,7 +309,7 @@ class PersonTokenCreateParamsDocumentsVisa(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/params/v2/core/accounts/_person_update_params.py b/stripe/params/v2/core/accounts/_person_update_params.py index ed45a4816..2318e45f2 100644 --- a/stripe/params/v2/core/accounts/_person_update_params.py +++ b/stripe/params/v2/core/accounts/_person_update_params.py @@ -247,7 +247,7 @@ class PersonUpdateParamsDocumentsCompanyAuthorization(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -258,7 +258,7 @@ class PersonUpdateParamsDocumentsPassport(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -269,7 +269,7 @@ class PersonUpdateParamsDocumentsPrimaryVerification(TypedDict): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -291,7 +291,7 @@ class PersonUpdateParamsDocumentsSecondaryVerification(TypedDict): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens referring to each side of the document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -313,7 +313,7 @@ class PersonUpdateParamsDocumentsVisa(TypedDict): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/params/v2/money_management/_outbound_payment_create_params.py b/stripe/params/v2/money_management/_outbound_payment_create_params.py index 177953f7e..018963c5f 100644 --- a/stripe/params/v2/money_management/_outbound_payment_create_params.py +++ b/stripe/params/v2/money_management/_outbound_payment_create_params.py @@ -32,7 +32,7 @@ class OutboundPaymentCreateParams(_OutboundPaymentCreateParamsBase): """ The quote for this OutboundPayment. Only required for countries with regulatory mandates to display fee estimates before OutboundPayment creation. """ - purpose: NotRequired[Literal["payroll"]] + purpose: NotRequired["Literal['payroll']|str"] """ The purpose of the OutboundPayment. """ diff --git a/stripe/product_catalog/_trial_offer.py b/stripe/product_catalog/_trial_offer.py index d9e9fcf3e..1b740f53a 100644 --- a/stripe/product_catalog/_trial_offer.py +++ b/stripe/product_catalog/_trial_offer.py @@ -59,7 +59,7 @@ class Transition(StripeObject): """ transition: Transition - type: Literal["transition"] + type: Union[Literal["transition"], str] """ The type of behavior when the trial offer ends. """ diff --git a/stripe/tax/_registration.py b/stripe/tax/_registration.py index dd2d5d50c..cf72a920c 100644 --- a/stripe/tax/_registration.py +++ b/stripe/tax/_registration.py @@ -1166,7 +1166,7 @@ class Sr(StripeObject): """ class Th(StripeObject): - type: Literal["simplified"] + type: Union[Literal["simplified"], str] """ Type of registration in `country`. """ diff --git a/stripe/treasury/_outbound_payment.py b/stripe/treasury/_outbound_payment.py index 6cc41a812..4512897ec 100644 --- a/stripe/treasury/_outbound_payment.py +++ b/stripe/treasury/_outbound_payment.py @@ -300,7 +300,7 @@ class UsDomesticWire(StripeObject): """ String representing the object's type. Objects of the same type share the same value. """ - purpose: Optional[Literal["payroll"]] + purpose: Optional[Union[Literal["payroll"], str]] """ The purpose of the OutboundPayment, if applicable. """ diff --git a/stripe/v2/billing/_cadence.py b/stripe/v2/billing/_cadence.py index 5bf8081b9..87c25020a 100644 --- a/stripe/v2/billing/_cadence.py +++ b/stripe/v2/billing/_cadence.py @@ -179,7 +179,7 @@ class Payer(StripeObject): """ The ID of the Customer object. """ - type: Literal["customer"] + type: Union[Literal["customer"], str] """ A string identifying the type of the payer. Currently the only supported value is `customer`. """ @@ -391,7 +391,9 @@ class EuBankTransfer(StripeObject): """ Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. """ - funding_type: Optional[Literal["bank_transfer"]] + funding_type: Optional[ + Union[Literal["bank_transfer"], str] + ] """ The funding method type to be used when there are not enough funds in the customer balance. Currently the only supported value is `bank_transfer`. """ diff --git a/stripe/v2/billing/_collection_setting.py b/stripe/v2/billing/_collection_setting.py index 910efe646..61dc994d9 100644 --- a/stripe/v2/billing/_collection_setting.py +++ b/stripe/v2/billing/_collection_setting.py @@ -131,7 +131,7 @@ class EuBankTransfer(StripeObject): """ Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. """ - funding_type: Optional[Literal["bank_transfer"]] + funding_type: Optional[Union[Literal["bank_transfer"], str]] """ The funding method type to be used when there are not enough funds in the customer balance. Currently the only supported value is `bank_transfer`. """ diff --git a/stripe/v2/billing/_collection_setting_version.py b/stripe/v2/billing/_collection_setting_version.py index 9e7502b1c..85b248ebd 100644 --- a/stripe/v2/billing/_collection_setting_version.py +++ b/stripe/v2/billing/_collection_setting_version.py @@ -131,7 +131,7 @@ class EuBankTransfer(StripeObject): """ Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. """ - funding_type: Optional[Literal["bank_transfer"]] + funding_type: Optional[Union[Literal["bank_transfer"], str]] """ The funding method type to be used when there are not enough funds in the customer balance. Currently the only supported value is `bank_transfer`. """ diff --git a/stripe/v2/billing/_meter_event_adjustment.py b/stripe/v2/billing/_meter_event_adjustment.py index 741df9078..1a74d9bc3 100644 --- a/stripe/v2/billing/_meter_event_adjustment.py +++ b/stripe/v2/billing/_meter_event_adjustment.py @@ -48,7 +48,7 @@ class Cancel(StripeObject): """ Open Enum. The meter event adjustment's status. """ - type: Literal["cancel"] + type: Union[Literal["cancel"], str] """ Open Enum. Specifies the type of cancellation. Currently supports canceling a single event. """ diff --git a/stripe/v2/core/__init__.py b/stripe/v2/core/__init__.py index bab1d4e54..3f1561264 100644 --- a/stripe/v2/core/__init__.py +++ b/stripe/v2/core/__init__.py @@ -6,6 +6,7 @@ from stripe.v2.core._event import ( EventNotification as EventNotification, RelatedObject as RelatedObject, + RelatedSingletonObject as RelatedSingletonObject, Reason as Reason, ReasonRequest as ReasonRequest, ) diff --git a/stripe/v2/core/_account.py b/stripe/v2/core/_account.py index 04fd9c1bd..3709ed331 100644 --- a/stripe/v2/core/_account.py +++ b/stripe/v2/core/_account.py @@ -4183,7 +4183,7 @@ class BankAccountOwnershipVerification(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4193,7 +4193,7 @@ class CompanyLicense(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4203,7 +4203,7 @@ class CompanyMemorandumOfAssociation(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4213,7 +4213,7 @@ class CompanyMinisterialDecree(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4223,7 +4223,7 @@ class CompanyRegistrationVerification(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4233,7 +4233,7 @@ class CompanyTaxIdVerification(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4253,7 +4253,7 @@ class FrontBack(StripeObject): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens for the front and back of the verification document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -4264,7 +4264,7 @@ class ProofOfAddress(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4284,7 +4284,7 @@ class Signer(StripeObject): """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4305,7 +4305,7 @@ class Signer(StripeObject): """ Person that is signing the document. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4836,7 +4836,7 @@ class CompanyAuthorization(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4846,7 +4846,7 @@ class Passport(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -4866,7 +4866,7 @@ class FrontBack(StripeObject): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens for the front and back of the verification document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -4887,7 +4887,7 @@ class FrontBack(StripeObject): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens for the front and back of the verification document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -4898,7 +4898,7 @@ class Visa(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/v2/core/_account_person.py b/stripe/v2/core/_account_person.py index f4f06045a..e1c4a1608 100644 --- a/stripe/v2/core/_account_person.py +++ b/stripe/v2/core/_account_person.py @@ -138,7 +138,7 @@ class CompanyAuthorization(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -148,7 +148,7 @@ class Passport(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ @@ -168,7 +168,7 @@ class FrontBack(StripeObject): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens for the front and back of the verification document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -189,7 +189,7 @@ class FrontBack(StripeObject): """ The [file upload](https://docs.stripe.com/api/persons/update#create_file) tokens for the front and back of the verification document. """ - type: Literal["front_back"] + type: Union[Literal["front_back"], str] """ The format of the verification document. Currently supports `front_back` only. """ @@ -200,7 +200,7 @@ class Visa(StripeObject): """ One or more document IDs returned by a [file upload](https://docs.stripe.com/api/persons/update#create_file) with a purpose value of `account_requirement`. """ - type: Literal["files"] + type: Union[Literal["files"], str] """ The format of the document. Currently supports `files` only. """ diff --git a/stripe/v2/core/_event.py b/stripe/v2/core/_event.py index afc31bc5c..ea42ce25a 100644 --- a/stripe/v2/core/_event.py +++ b/stripe/v2/core/_event.py @@ -42,7 +42,7 @@ class Request(StripeObject): """ Information on the API request that instigated the event. """ - type: Literal["request"] + type: Union[Literal["request"], str] """ Event reason type. """ @@ -125,6 +125,18 @@ def __repr__(self) -> str: return f"" +class RelatedSingletonObject: + type: str + url: str + + def __init__(self, d) -> None: + self.type = d["type"] + self.url = d["url"] + + def __repr__(self) -> str: + return f"" + + class EventNotification: """ EventNotification represents the json that's delivered from an Event Destination. It's a basic struct-like object with a few convenience methods. Use `fetch_event()` to get the full event object. diff --git a/stripe/v2/data/reporting/_query_run.py b/stripe/v2/data/reporting/_query_run.py index 2b217fa40..2fe5eee1d 100644 --- a/stripe/v2/data/reporting/_query_run.py +++ b/stripe/v2/data/reporting/_query_run.py @@ -47,7 +47,7 @@ class DownloadUrl(StripeObject): Contains metadata about the file produced by the `ReportRun` or `QueryRun`, including its content type, size, and a URL to download its contents. """ - type: Literal["file"] + type: Union[Literal["file"], str] """ The type of the `ReportRun` or `QueryRun` result. """ diff --git a/stripe/v2/iam/_activity_log.py b/stripe/v2/iam/_activity_log.py index f400b6d85..843dc981b 100644 --- a/stripe/v2/iam/_activity_log.py +++ b/stripe/v2/iam/_activity_log.py @@ -54,7 +54,7 @@ class Application(StripeObject): """ An application. """ - type: Literal["application"] + type: Union[Literal["application"], str] """ The type of entity. """ diff --git a/stripe/v2/money_management/_outbound_payment.py b/stripe/v2/money_management/_outbound_payment.py index afeae7178..0f7d9b7c9 100644 --- a/stripe/v2/money_management/_outbound_payment.py +++ b/stripe/v2/money_management/_outbound_payment.py @@ -61,7 +61,7 @@ class Failed(StripeObject): """ class Processing(StripeObject): - reason: Literal["under_review"] + reason: Union[Literal["under_review"], str] """ Open Enum. The `processing` status reason. """ @@ -204,7 +204,7 @@ class TraceId(StripeObject): """ The quote for this OutboundPayment. Only required for countries with regulatory mandates to display fee estimates before OutboundPayment creation. """ - purpose: Optional[Literal["payroll"]] + purpose: Optional[Union[Literal["payroll"], str]] """ The purpose of the OutboundPayment. """ diff --git a/stripe/v2/money_management/_outbound_transfer.py b/stripe/v2/money_management/_outbound_transfer.py index 461c5e5dd..81c7f34b7 100644 --- a/stripe/v2/money_management/_outbound_transfer.py +++ b/stripe/v2/money_management/_outbound_transfer.py @@ -54,7 +54,7 @@ class Failed(StripeObject): """ class Processing(StripeObject): - reason: Literal["under_review"] + reason: Union[Literal["under_review"], str] """ Open Enum. The `processing` status reason. """ diff --git a/stripe/v2/money_management/_received_credit.py b/stripe/v2/money_management/_received_credit.py index 7031faf79..5e21a021f 100644 --- a/stripe/v2/money_management/_received_credit.py +++ b/stripe/v2/money_management/_received_credit.py @@ -94,7 +94,7 @@ class SepaBankAccount(StripeObject): """ The IBAN that originated the transfer. """ - network: Literal["sepa_credit_transfer"] + network: Union[Literal["sepa_credit_transfer"], str] """ The money transmission network used to send funds for this ReceivedCredit. """ @@ -170,7 +170,7 @@ class Failed(StripeObject): """ class Returned(StripeObject): - reason: Literal["originator_initiated_reversal"] + reason: Union[Literal["originator_initiated_reversal"], str] """ Open Enum. The `returned` status reason. """ diff --git a/stripe/v2/money_management/_received_debit.py b/stripe/v2/money_management/_received_debit.py index 75ce02518..e875eb3e8 100644 --- a/stripe/v2/money_management/_received_debit.py +++ b/stripe/v2/money_management/_received_debit.py @@ -21,7 +21,7 @@ class UsBankAccount(StripeObject): """ The name of the bank the debit originated from. """ - network: Literal["ach"] + network: Union[Literal["ach"], str] """ Open Enum. The bank network the debit was originated on. """ @@ -34,7 +34,7 @@ class UsBankAccount(StripeObject): """ The Financial Address that was debited. """ - payment_method_type: Literal["us_bank_account"] + payment_method_type: Union[Literal["us_bank_account"], str] """ Open Enum. The type of the payment method used to originate the debit. """ diff --git a/tests/test_api_requestor.py b/tests/test_api_requestor.py index e077b2057..dadb1232e 100644 --- a/tests/test_api_requestor.py +++ b/tests/test_api_requestor.py @@ -11,7 +11,11 @@ import stripe import io -from stripe._api_requestor import _api_encode, _APIRequestor +from stripe._api_requestor import ( + _api_encode, + _APIRequestor, + _maybe_emit_stripe_notice, +) from stripe._customer import Customer from stripe._request_options import RequestOptions from stripe._requestor_options import ( @@ -1100,6 +1104,55 @@ def test_stripe_notice_header_emits_warning( with pytest.warns(UserWarning, match="test notice value"): requestor.request("get", self.v1_path, {}, base_address="api") + def test_stripe_notice_tells_humans_how_to_suppress_notices(self): + with pytest.warns(UserWarning) as warning: + _maybe_emit_stripe_notice( + {"Stripe-Notice": "test notice value"}, {} + ) + + assert str(warning[0].message) == ( + "test notice value\n" + "To suppress Stripe notices in test and sandbox environments, " + "set the STRIPE_SUPPRESS_NOTICES environment variable to true." + ) + + @pytest.mark.parametrize("suppression_value", ["true", "TRUE"]) + def test_stripe_notice_can_be_suppressed_for_humans( + self, suppression_value + ): + import warnings + + with warnings.catch_warnings(): + warnings.simplefilter("error") + _maybe_emit_stripe_notice( + {"Stripe-Notice": "test notice value"}, + {"STRIPE_SUPPRESS_NOTICES": suppression_value}, + ) + + @pytest.mark.parametrize( + "suppression_value", ["", "false", "1", "invalid"] + ) + def test_stripe_notice_is_not_suppressed_for_other_values( + self, suppression_value + ): + with pytest.warns(UserWarning): + _maybe_emit_stripe_notice( + {"Stripe-Notice": "test notice value"}, + {"STRIPE_SUPPRESS_NOTICES": suppression_value}, + ) + + def test_stripe_notice_is_not_suppressed_for_ai_agents(self): + with pytest.warns(UserWarning) as warning: + _maybe_emit_stripe_notice( + {"Stripe-Notice": "test notice value"}, + { + "STRIPE_SUPPRESS_NOTICES": "true", + "CODEX_SANDBOX": "1", + }, + ) + + assert str(warning[0].message) == "test notice value" + @pytest.mark.anyio async def test_stripe_notice_header_emits_warning_async( self, requestor, http_client_mock diff --git a/tests/test_event_notification_handler.py b/tests/test_event_notification_handler.py index c47460589..74dad1855 100644 --- a/tests/test_event_notification_handler.py +++ b/tests/test_event_notification_handler.py @@ -29,6 +29,7 @@ class TestEventNotificationHandler: def stripe_client(self, http_client_mock: HTTPClientMock) -> StripeClient: return StripeClient( api_key="sk_test_1234", + stripe_account="acct_123", stripe_context=StripeContext.parse("original_context_123"), http_client=http_client_mock.get_mock_http_client(), ) @@ -249,12 +250,14 @@ def test_handler_uses_event_stripe_context( ) -> None: """Test that the handler receives a client with stripe_context from the event""" received_context: Optional[StripeContext | str] = None + received_account: Optional[str] = None def handler( event: V1BillingMeterErrorReportTriggeredEventNotification, client: StripeClient, ) -> None: - nonlocal received_context + nonlocal received_account, received_context + received_account = client._requestor._options.stripe_account received_context = client._requestor._options.stripe_context event_handler.on_v1_billing_meter_error_report_triggered(handler) @@ -268,6 +271,7 @@ def handler( event_handler.handle(v1_billing_meter_payload, sig_header) assert str(received_context) == "event_context_456" + assert received_account is None def test_stripe_context_restored_after_handler_success( self, diff --git a/tests/test_exports.py b/tests/test_exports.py index 3aff0a530..e9c3a04cd 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -45,6 +45,16 @@ def test_can_import_webhook_members() -> None: ) +def test_can_import_event_notification_members() -> None: + from stripe.v2.core import ( + EventNotification, # pyright: ignore[reportUnusedImport] + Reason, # pyright: ignore[reportUnusedImport] + ReasonRequest, # pyright: ignore[reportUnusedImport] + RelatedObject, # pyright: ignore[reportUnusedImport] + RelatedSingletonObject, # pyright: ignore[reportUnusedImport] + ) + + def test_can_import_abstract() -> None: from stripe import ( APIResource, # pyright: ignore[reportUnusedImport] diff --git a/tests/test_v2_event.py b/tests/test_v2_event.py index f2d545706..5a16cee35 100644 --- a/tests/test_v2_event.py +++ b/tests/test_v2_event.py @@ -16,7 +16,11 @@ V1BillingMeterErrorReportTriggeredEventNotification, V1BillingMeterErrorReportTriggeredEvent, ) -from stripe.v2.core._event import EventNotification, UnknownEventNotification +from stripe.v2.core._event import ( + EventNotification, + RelatedSingletonObject, + UnknownEventNotification, +) from stripe.events._event_classes import ALL_EVENT_NOTIFICATIONS from stripe._webhook import WebhookPayload, WebhookSignature from tests.test_webhook import DUMMY_WEBHOOK_SECRET @@ -200,6 +204,19 @@ def test_parses_unknown_event_notif(self, parse_event_notif: EventParser): assert type(event) is UnknownEventNotification assert event.related_object + def test_related_singleton_object_omits_id(self): + """ + events whose related object is a singleton get a `RelatedSingletonObject`, + which has no `id` at all (instead of a perpetually-`None` one) + """ + related_object = RelatedSingletonObject( + {"type": "balance", "url": "/v1/balance"} + ) + + assert related_object.type == "balance" + assert related_object.url == "/v1/balance" + assert not hasattr(related_object, "id") + def test_raise_on_v1_payload(self, parse_event_notif: EventParser): v1_payload = json.dumps( { diff --git a/tests/test_webhook.py b/tests/test_webhook.py index 9b1420a8d..08c9e20b7 100644 --- a/tests/test_webhook.py +++ b/tests/test_webhook.py @@ -274,6 +274,16 @@ def test_raise_on_v2_payload(self, stripe_mock_stripe_client): ) assert "parse_event_notification" in str(e.value) + @pytest.mark.parametrize("secret", [None, ""]) + def test_raise_on_missing_secret(self, stripe_mock_stripe_client, secret): + with pytest.raises( + SignatureVerificationError, + match="No webhook secret value was provided", + ): + stripe_mock_stripe_client.construct_event( + DUMMY_WEBHOOK_PAYLOAD, generate_header(), secret + ) + def test_construct_event_inherits_requestor(self, http_client_mock): http_client_mock.stub_request("delete", "/v1/terminal/readers/rdr_123")