diff --git a/API_VERSION b/API_VERSION index e2854d256..dc9d80dc3 100644 --- a/API_VERSION +++ b/API_VERSION @@ -1 +1 @@ -7f436e73385732b1c5502f408a6fe37f7b6b0612 \ No newline at end of file +368be7755d15d02a1038325c7d159703b01662b0 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 14a7088b6..20f3f77bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Changelog +## 14.1.0b1 - 2025-11-18 +This release changes the pinned API version to `2025-11-17.preview`. + +* [#1663](https://github.com/stripe/stripe-python/pull/1663) Update generated code for beta + * Add support for new resources `v2.core.AccountPersonToken` and `v2.core.AccountToken` + * Remove support for resource `v2.payments.OffSessionPayment` + * Add support for `create` and `retrieve` methods on resources `v2.core.AccountPersonToken` and `v2.core.AccountToken` + * Remove support for `cancel`, `capture`, `create`, `list`, and `retrieve` methods on resource `v2.payments.OffSessionPayment` + * Change `Tax.Association.tax_transaction_attempts` to be required + * Add support for `specified_commercial_transactions_act_url` on `Account.BusinessProfile`, `AccountCreateParamsBusinessProfile`, and `AccountModifyParamsBusinessProfile` + * Add support for `paypay_payments` on `Account.Setting`, `AccountCreateParamsSetting`, and `AccountModifyParamsSetting` + * Change type of `billing.analytics.MeterUsageRetrieveParamsMeter.dimension_filters` from `string` to `array(string)` + * Change type of `billing.analytics.MeterUsageRetrieveParamsMeter.tenant_filters` from `string` to `array(string)` + * Add support for `car_rental_data`, `flight_data`, and `lodging_data` on `ChargeCaptureParamsPaymentDetail`, `ChargeModifyParamsPaymentDetail`, `PaymentIntentCaptureParamsPaymentDetail`, `PaymentIntentConfirmParamsPaymentDetail`, `PaymentIntentCreateParamsPaymentDetail`, and `PaymentIntentModifyParamsPaymentDetail` + * Add support for `supplementary_purchase_data` on `OrderCreateParamsPaymentSettingPaymentMethodOptionKlarna`, `OrderModifyParamsPaymentSettingPaymentMethodOptionKlarna`, `PaymentIntentConfirmParamsPaymentMethodOptionKlarna`, `PaymentIntentCreateParamsPaymentMethodOptionKlarna`, and `PaymentIntentModifyParamsPaymentMethodOptionKlarna` + * Add support for `allow_redisplay` and `customer_account` on `PaymentMethodListParams` + * Add support for `future_requirements` on `V2.Core.Account` + * Add support for `konbini_payments` and `script_statement_descriptor` on `V2.Core.Account.Configuration.Merchant`, `v2.core.AccountCreateParamsConfigurationMerchant`, and `v2.core.AccountModifyParamsConfigurationMerchant` + * Add support for `eur` on `V2.Core.Account.Configuration.Storer.Capability.HoldsCurrency`, `v2.core.AccountCreateParamsConfigurationStorerCapabilityHoldsCurrency`, and `v2.core.AccountModifyParamsConfigurationStorerCapabilityHoldsCurrency` + * Add support for `requirements_collector` on `V2.Core.Account.Default.Responsibility` + * Add support for new value `ar_cuit` on enums `V2.Core.Account.Identity.BusinessDetail.IdNumber.type`, `v2.core.AccountCreateParamsIdentityBusinessDetailIdNumber.type`, and `v2.core.AccountModifyParamsIdentityBusinessDetailIdNumber.type` + * Add support for new value `ar_dni` on enums `V2.Core.Account.Identity.Individual.IdNumber.type`, `V2.Core.AccountPerson.IdNumber.type`, `v2.core.AccountCreateParamsIdentityIndividualIdNumber.type`, `v2.core.AccountModifyParamsIdentityIndividualIdNumber.type`, `v2.core.AccountPersonCreateParamsIdNumber.type`, and `v2.core.AccountPersonModifyParamsIdNumber.type` + * Remove support for `collector` on `V2.Core.Account.Requirement` + * Add support for new value `holds_currencies.eur` on enum `V2.Core.Account.Requirement.Entry.Impact.RestrictsCapability.capability` + * Add support for new values `payment_method` and `person` on enum `V2.Core.Account.Requirement.Entry.Reference.type` + * Remove support for value `resource` from enum `V2.Core.Account.Requirement.Entry.Reference.type` + * Remove support for value `future_requirements` from enum `V2.Core.Account.Requirement.Entry.RequestedReason.code` + * Add support for `changes` on `V2.Core.Event` + * Remove support for value `sepa_bank_account` from enums `V2.MoneyManagement.FinancialAddress.Credential.type` and `v2.money_management.FinancialAddressCreateParams.type` + * Add support for `account_token` on `v2.core.AccountCreateParams` and `v2.core.AccountModifyParams` + * Add support for new value `future_requirements` on enums `v2.core.AccountCreateParams.include`, `v2.core.AccountModifyParams.include`, and `v2.core.AccountRetrieveParams.include` + * Add support for `person_token` on `v2.core.AccountPersonCreateParams` and `v2.core.AccountPersonModifyParams` + * Add support for thin event `V2CoreHealthEventGenerationFailureResolvedEvent` + * Remove support for thin events `V2PaymentsOffSessionPaymentAuthorizationAttemptFailedEvent`, `V2PaymentsOffSessionPaymentAuthorizationAttemptStartedEvent`, `V2PaymentsOffSessionPaymentCanceledEvent`, `V2PaymentsOffSessionPaymentCreatedEvent`, `V2PaymentsOffSessionPaymentFailedEvent`, `V2PaymentsOffSessionPaymentRequiresCaptureEvent`, and `V2PaymentsOffSessionPaymentSucceededEvent` with related object `v2.payments.OffSessionPayment` + ## 14.1.0a2 - 2025-11-20 This release changes the pinned API version to `2025-11-17.preview`. @@ -147,40 +182,10 @@ This release changes the pinned API version to `2025-11-17.preview`. * Add support for new value `2025-11-17.clover` on enum `WebhookEndpointCreateParams.api_version` * Add support for snapshot events `financial_connections.account.account_numbers_updated` and `financial_connections.account.upcoming_account_number_expiry` with resource `financial_connections.Account` -## 14.1.0b1 - 2025-11-18 -This release changes the pinned API version to `2025-11-17.preview`. - -* [#1663](https://github.com/stripe/stripe-python/pull/1663) Update generated code for beta - * Add support for new resources `v2.core.AccountPersonToken` and `v2.core.AccountToken` - * Remove support for resource `v2.payments.OffSessionPayment` - * Add support for `create` and `retrieve` methods on resources `v2.core.AccountPersonToken` and `v2.core.AccountToken` - * Remove support for `cancel`, `capture`, `create`, `list`, and `retrieve` methods on resource `v2.payments.OffSessionPayment` - * Change `Tax.Association.tax_transaction_attempts` to be required - * Add support for `specified_commercial_transactions_act_url` on `Account.BusinessProfile`, `AccountCreateParamsBusinessProfile`, and `AccountModifyParamsBusinessProfile` - * Add support for `paypay_payments` on `Account.Setting`, `AccountCreateParamsSetting`, and `AccountModifyParamsSetting` - * Change type of `billing.analytics.MeterUsageRetrieveParamsMeter.dimension_filters` from `string` to `array(string)` - * Change type of `billing.analytics.MeterUsageRetrieveParamsMeter.tenant_filters` from `string` to `array(string)` - * Add support for `car_rental_data`, `flight_data`, and `lodging_data` on `ChargeCaptureParamsPaymentDetail`, `ChargeModifyParamsPaymentDetail`, `PaymentIntentCaptureParamsPaymentDetail`, `PaymentIntentConfirmParamsPaymentDetail`, `PaymentIntentCreateParamsPaymentDetail`, and `PaymentIntentModifyParamsPaymentDetail` - * Add support for `supplementary_purchase_data` on `OrderCreateParamsPaymentSettingPaymentMethodOptionKlarna`, `OrderModifyParamsPaymentSettingPaymentMethodOptionKlarna`, `PaymentIntentConfirmParamsPaymentMethodOptionKlarna`, `PaymentIntentCreateParamsPaymentMethodOptionKlarna`, and `PaymentIntentModifyParamsPaymentMethodOptionKlarna` - * Add support for `allow_redisplay` and `customer_account` on `PaymentMethodListParams` - * Add support for `future_requirements` on `V2.Core.Account` - * Add support for `konbini_payments` and `script_statement_descriptor` on `V2.Core.Account.Configuration.Merchant`, `v2.core.AccountCreateParamsConfigurationMerchant`, and `v2.core.AccountModifyParamsConfigurationMerchant` - * Add support for `eur` on `V2.Core.Account.Configuration.Storer.Capability.HoldsCurrency`, `v2.core.AccountCreateParamsConfigurationStorerCapabilityHoldsCurrency`, and `v2.core.AccountModifyParamsConfigurationStorerCapabilityHoldsCurrency` - * Add support for `requirements_collector` on `V2.Core.Account.Default.Responsibility` - * Add support for new value `ar_cuit` on enums `V2.Core.Account.Identity.BusinessDetail.IdNumber.type`, `v2.core.AccountCreateParamsIdentityBusinessDetailIdNumber.type`, and `v2.core.AccountModifyParamsIdentityBusinessDetailIdNumber.type` - * Add support for new value `ar_dni` on enums `V2.Core.Account.Identity.Individual.IdNumber.type`, `V2.Core.AccountPerson.IdNumber.type`, `v2.core.AccountCreateParamsIdentityIndividualIdNumber.type`, `v2.core.AccountModifyParamsIdentityIndividualIdNumber.type`, `v2.core.AccountPersonCreateParamsIdNumber.type`, and `v2.core.AccountPersonModifyParamsIdNumber.type` - * Remove support for `collector` on `V2.Core.Account.Requirement` - * Add support for new value `holds_currencies.eur` on enum `V2.Core.Account.Requirement.Entry.Impact.RestrictsCapability.capability` - * Add support for new values `payment_method` and `person` on enum `V2.Core.Account.Requirement.Entry.Reference.type` - * Remove support for value `resource` from enum `V2.Core.Account.Requirement.Entry.Reference.type` - * Remove support for value `future_requirements` from enum `V2.Core.Account.Requirement.Entry.RequestedReason.code` - * Add support for `changes` on `V2.Core.Event` - * Remove support for value `sepa_bank_account` from enums `V2.MoneyManagement.FinancialAddress.Credential.type` and `v2.money_management.FinancialAddressCreateParams.type` - * Add support for `account_token` on `v2.core.AccountCreateParams` and `v2.core.AccountModifyParams` - * Add support for new value `future_requirements` on enums `v2.core.AccountCreateParams.include`, `v2.core.AccountModifyParams.include`, and `v2.core.AccountRetrieveParams.include` - * Add support for `person_token` on `v2.core.AccountPersonCreateParams` and `v2.core.AccountPersonModifyParams` - * Add support for thin event `V2CoreHealthEventGenerationFailureResolvedEvent` - * Remove support for thin events `V2PaymentsOffSessionPaymentAuthorizationAttemptFailedEvent`, `V2PaymentsOffSessionPaymentAuthorizationAttemptStartedEvent`, `V2PaymentsOffSessionPaymentCanceledEvent`, `V2PaymentsOffSessionPaymentCreatedEvent`, `V2PaymentsOffSessionPaymentFailedEvent`, `V2PaymentsOffSessionPaymentRequiresCaptureEvent`, and `V2PaymentsOffSessionPaymentSucceededEvent` with related object `v2.payments.OffSessionPayment` +## 14.0.1 - 2025-11-21 +* [#1684](https://github.com/stripe/stripe-python/pull/1684) Update generated code + * `stripe.error` module is now accessible globally. Fixes [#1682](https://github.com/stripe/stripe-python/issues/1682) +* [#1681](https://github.com/stripe/stripe-python/pull/1681) Throw a specific error when accessing `payment_intent` property on `Invoice` object to ease debugging. ## 14.0.0 - 2025-11-18 This release changes the pinned API version to `2025-11-17.clover`. diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 1d5ad796c..3809bd615 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v2128 \ No newline at end of file +v2129 \ No newline at end of file diff --git a/stripe/__init__.py b/stripe/__init__.py index 9e6e98d37..8945b21fb 100644 --- a/stripe/__init__.py +++ b/stripe/__init__.py @@ -143,6 +143,7 @@ def add_beta_version( if TYPE_CHECKING: from stripe import ( + _error as error, apps as apps, billing as billing, billing_portal as billing_portal, @@ -158,6 +159,7 @@ def add_beta_version( issuing as issuing, params as params, privacy as privacy, + product_catalog as product_catalog, radar as radar, reporting as reporting, sigma as sigma, @@ -483,6 +485,9 @@ def add_beta_version( from stripe._price_service import PriceService as PriceService from stripe._privacy_service import PrivacyService as PrivacyService from stripe._product import Product as Product + from stripe._product_catalog_service import ( + ProductCatalogService as ProductCatalogService, + ) from stripe._product_feature import ProductFeature as ProductFeature from stripe._product_feature_service import ( ProductFeatureService as ProductFeatureService, @@ -630,6 +635,7 @@ def add_beta_version( # name -> (import_target, is_submodule) _import_map = { + "error": ("stripe._error", True), "apps": ("stripe.apps", True), "billing": ("stripe.billing", True), "billing_portal": ("stripe.billing_portal", True), @@ -645,6 +651,7 @@ def add_beta_version( "issuing": ("stripe.issuing", True), "params": ("stripe.params", True), "privacy": ("stripe.privacy", True), + "product_catalog": ("stripe.product_catalog", True), "radar": ("stripe.radar", True), "reporting": ("stripe.reporting", True), "sigma": ("stripe.sigma", True), @@ -903,6 +910,7 @@ def add_beta_version( "PriceService": ("stripe._price_service", False), "PrivacyService": ("stripe._privacy_service", False), "Product": ("stripe._product", False), + "ProductCatalogService": ("stripe._product_catalog_service", False), "ProductFeature": ("stripe._product_feature", False), "ProductFeatureService": ("stripe._product_feature_service", False), "ProductService": ("stripe._product_service", False), diff --git a/stripe/_object_classes.py b/stripe/_object_classes.py index ce97d7c91..9e80ea5c1 100644 --- a/stripe/_object_classes.py +++ b/stripe/_object_classes.py @@ -256,6 +256,10 @@ "RedactionJobValidationError", ), "product": ("stripe._product", "Product"), + "product_catalog.trial_offer": ( + "stripe.product_catalog._trial_offer", + "TrialOffer", + ), "product_feature": ("stripe._product_feature", "ProductFeature"), "promotion_code": ("stripe._promotion_code", "PromotionCode"), "quote": ("stripe._quote", "Quote"), diff --git a/stripe/_payment_intent.py b/stripe/_payment_intent.py index f25f033d7..a099f01ad 100644 --- a/stripe/_payment_intent.py +++ b/stripe/_payment_intent.py @@ -3308,6 +3308,12 @@ class Zip(StripeObject): "zip": Zip, } + class PaymentsOrchestration(StripeObject): + enabled: bool + """ + Whether this feature is enabled. + """ + class PresentmentDetails(StripeObject): presentment_amount: int """ @@ -3613,6 +3619,10 @@ class TransferData(StripeObject): """ The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. A comprehensive list of valid payment method types can be found [here](https://docs.stripe.com/api/payment_methods/object#payment_method_object-type). """ + payments_orchestration: Optional[PaymentsOrchestration] + """ + When you enable this parameter, this PaymentIntent will route your payment to processors that you configure in the dashboard. + """ presentment_details: Optional[PresentmentDetails] processing: Optional[Processing] """ @@ -5441,6 +5451,7 @@ async def list_amount_details_line_items_async( "payment_details": PaymentDetails, "payment_method_configuration_details": PaymentMethodConfigurationDetails, "payment_method_options": PaymentMethodOptions, + "payments_orchestration": PaymentsOrchestration, "presentment_details": PresentmentDetails, "processing": Processing, "shipping": Shipping, diff --git a/stripe/_product_catalog_service.py b/stripe/_product_catalog_service.py new file mode 100644 index 000000000..dd7561b5d --- /dev/null +++ b/stripe/_product_catalog_service.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.product_catalog._trial_offer_service import TrialOfferService + +_subservices = { + "trial_offers": [ + "stripe.product_catalog._trial_offer_service", + "TrialOfferService", + ], +} + + +class ProductCatalogService(StripeService): + trial_offers: "TrialOfferService" + + def __init__(self, requestor): + super().__init__(requestor) + + def __getattr__(self, name): + try: + import_from, service = _subservices[name] + service_class = getattr( + import_module(import_from), + service, + ) + setattr( + self, + name, + service_class(self._requestor), + ) + return getattr(self, name) + except KeyError: + raise AttributeError() diff --git a/stripe/_stripe_client.py b/stripe/_stripe_client.py index ea87b19c7..e727fcfbb 100644 --- a/stripe/_stripe_client.py +++ b/stripe/_stripe_client.py @@ -108,6 +108,7 @@ from stripe._price_service import PriceService from stripe._privacy_service import PrivacyService from stripe._product_service import ProductService + from stripe._product_catalog_service import ProductCatalogService from stripe._promotion_code_service import PromotionCodeService from stripe._quote_service import QuoteService from stripe._radar_service import RadarService @@ -947,6 +948,17 @@ def privacy(self) -> "PrivacyService": def products(self) -> "ProductService": return self.v1.products + @property + @deprecated( + """ + StripeClient.product_catalog is deprecated, use StripeClient.v1.product_catalog instead. + All functionality under it has been copied over to StripeClient.v1.product_catalog. + See [migration guide](https://github.com/stripe/stripe-python/wiki/v1-namespace-in-StripeClient) for more on this and tips on migrating to the new v1 namespace. + """, + ) + def product_catalog(self) -> "ProductCatalogService": + return self.v1.product_catalog + @property @deprecated( """ diff --git a/stripe/_stripe_object.py b/stripe/_stripe_object.py index 0f44342f4..6ce504aa6 100644 --- a/stripe/_stripe_object.py +++ b/stripe/_stripe_object.py @@ -216,6 +216,15 @@ def __getitem__(self, k: str) -> Any: % (k, k, ", ".join(list(self.keys()))) ) else: + from stripe._invoice import Invoice + + # super specific one-off case to help users debug this property disappearing + # see also: https://go/j/DEVSDK-2835 + if isinstance(self, Invoice) and k == "payment_intent": + raise KeyError( + "The 'payment_intent' attribute is no longer available on Invoice objects. See the docs for more details: https://docs.stripe.com/changelog/basil/2025-03-31/add-support-for-multiple-partial-payments-on-invoices#why-is-this-a-breaking-change" + ) + raise err def __delitem__(self, k: str) -> None: diff --git a/stripe/_v1_services.py b/stripe/_v1_services.py index 29fd03a52..4d31cff3c 100644 --- a/stripe/_v1_services.py +++ b/stripe/_v1_services.py @@ -70,6 +70,7 @@ from stripe._plan_service import PlanService from stripe._price_service import PriceService from stripe._privacy_service import PrivacyService + from stripe._product_catalog_service import ProductCatalogService from stripe._product_service import ProductService from stripe._promotion_code_service import PromotionCodeService from stripe._quote_service import QuoteService @@ -219,6 +220,10 @@ "prices": ["stripe._price_service", "PriceService"], "privacy": ["stripe._privacy_service", "PrivacyService"], "products": ["stripe._product_service", "ProductService"], + "product_catalog": [ + "stripe._product_catalog_service", + "ProductCatalogService", + ], "promotion_codes": [ "stripe._promotion_code_service", "PromotionCodeService", @@ -316,6 +321,7 @@ class V1Services(StripeService): prices: "PriceService" privacy: "PrivacyService" products: "ProductService" + product_catalog: "ProductCatalogService" promotion_codes: "PromotionCodeService" quotes: "QuoteService" radar: "RadarService" diff --git a/stripe/delegated_checkout/_requested_session.py b/stripe/delegated_checkout/_requested_session.py index f6fac6d09..41e115336 100644 --- a/stripe/delegated_checkout/_requested_session.py +++ b/stripe/delegated_checkout/_requested_session.py @@ -164,14 +164,6 @@ class LineItemDetail(StripeObject): """ The total before any discounts or taxes are applied. """ - amount_subtotal_after_discount: int - """ - The total after discounts but before taxes are applied. - """ - amount_total: int - """ - The total after discounts and taxes. - """ description: Optional[str] """ The description of the line item. @@ -200,14 +192,6 @@ class LineItemDetail(StripeObject): """ The per-unit amount of the item before any discounts or taxes are applied. """ - unit_amount_after_discount: int - """ - The per-unit amount of the item after discounts but before taxes are applied. - """ - unit_discount: int - """ - The per-unit discount amount. If no discount were applied, defaults to 0. - """ class OrderDetails(StripeObject): order_id: Optional[str] @@ -311,17 +295,17 @@ class ApplicableFee(StripeObject): The display name of the applicable fee. """ - amount_discount: Optional[int] + amount_cart_discount: Optional[int] """ - The amount discount of the total details. + The amount of order-level discounts applied to the cart. The total discount amount for this session can be computed by summing the cart discount and the item discounts. """ amount_fulfillment: Optional[int] """ The amount fulfillment of the total details. """ - amount_subtotal_after_discount: Optional[int] + amount_items_discount: Optional[int] """ - Total of all items after discounts but before taxes are applied. + The amount of item-level discounts applied to the cart. The total discount amount for this session can be computed by summing the cart discount and the item discounts. """ amount_tax: Optional[int] """ diff --git a/stripe/params/__init__.py b/stripe/params/__init__.py index cbdbc6be0..57d433db6 100644 --- a/stripe/params/__init__.py +++ b/stripe/params/__init__.py @@ -18,6 +18,7 @@ identity as identity, issuing as issuing, privacy as privacy, + product_catalog as product_catalog, radar as radar, reporting as reporting, sigma as sigma, @@ -2734,6 +2735,7 @@ PaymentIntentCreateParamsPaymentMethodOptionsUsBankAccountNetworks as PaymentIntentCreateParamsPaymentMethodOptionsUsBankAccountNetworks, PaymentIntentCreateParamsPaymentMethodOptionsWechatPay as PaymentIntentCreateParamsPaymentMethodOptionsWechatPay, PaymentIntentCreateParamsPaymentMethodOptionsZip as PaymentIntentCreateParamsPaymentMethodOptionsZip, + PaymentIntentCreateParamsPaymentsOrchestration as PaymentIntentCreateParamsPaymentsOrchestration, PaymentIntentCreateParamsRadarOptions as PaymentIntentCreateParamsRadarOptions, PaymentIntentCreateParamsShipping as PaymentIntentCreateParamsShipping, PaymentIntentCreateParamsShippingAddress as PaymentIntentCreateParamsShippingAddress, @@ -5651,6 +5653,7 @@ "identity": ("stripe.params.identity", True), "issuing": ("stripe.params.issuing", True), "privacy": ("stripe.params.privacy", True), + "product_catalog": ("stripe.params.product_catalog", True), "radar": ("stripe.params.radar", True), "reporting": ("stripe.params.reporting", True), "sigma": ("stripe.params.sigma", True), @@ -14382,6 +14385,10 @@ "stripe.params._payment_intent_create_params", False, ), + "PaymentIntentCreateParamsPaymentsOrchestration": ( + "stripe.params._payment_intent_create_params", + False, + ), "PaymentIntentCreateParamsRadarOptions": ( "stripe.params._payment_intent_create_params", False, diff --git a/stripe/params/_payment_intent_create_params.py b/stripe/params/_payment_intent_create_params.py index 251b21357..f5b9a219e 100644 --- a/stripe/params/_payment_intent_create_params.py +++ b/stripe/params/_payment_intent_create_params.py @@ -262,6 +262,12 @@ class PaymentIntentCreateParams(RequestOptions): """ Set to `true` when confirming server-side and using Stripe.js, iOS, or Android client-side SDKs to handle the next actions. """ + payments_orchestration: NotRequired[ + "PaymentIntentCreateParamsPaymentsOrchestration" + ] + """ + When you enable this parameter, this PaymentIntent will route your payment to processors that you configure in the dashboard. + """ class PaymentIntentCreateParamsAllocatedFunds(TypedDict): @@ -6742,3 +6748,10 @@ class PaymentIntentCreateParamsTransferData(TypedDict): to the destination account. The ID of the resulting transfer will be returned on the successful charge's `transfer` field. """ + + +class PaymentIntentCreateParamsPaymentsOrchestration(TypedDict): + enabled: bool + """ + Whether this feature is enabled. + """ diff --git a/stripe/params/product_catalog/__init__.py b/stripe/params/product_catalog/__init__.py new file mode 100644 index 000000000..f07d44c67 --- /dev/null +++ b/stripe/params/product_catalog/__init__.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.params.product_catalog._trial_offer_create_params import ( + TrialOfferCreateParams as TrialOfferCreateParams, + TrialOfferCreateParamsDuration as TrialOfferCreateParamsDuration, + TrialOfferCreateParamsDurationRelative as TrialOfferCreateParamsDurationRelative, + TrialOfferCreateParamsEndBehavior as TrialOfferCreateParamsEndBehavior, + TrialOfferCreateParamsEndBehaviorTransition as TrialOfferCreateParamsEndBehaviorTransition, + ) + +# name -> (import_target, is_submodule) +_import_map = { + "TrialOfferCreateParams": ( + "stripe.params.product_catalog._trial_offer_create_params", + False, + ), + "TrialOfferCreateParamsDuration": ( + "stripe.params.product_catalog._trial_offer_create_params", + False, + ), + "TrialOfferCreateParamsDurationRelative": ( + "stripe.params.product_catalog._trial_offer_create_params", + False, + ), + "TrialOfferCreateParamsEndBehavior": ( + "stripe.params.product_catalog._trial_offer_create_params", + False, + ), + "TrialOfferCreateParamsEndBehaviorTransition": ( + "stripe.params.product_catalog._trial_offer_create_params", + False, + ), +} +if not TYPE_CHECKING: + + def __getattr__(name): + try: + target, is_submodule = _import_map[name] + module = import_module(target) + if is_submodule: + return module + + return getattr( + module, + name, + ) + except KeyError: + raise AttributeError() diff --git a/stripe/params/product_catalog/_trial_offer_create_params.py b/stripe/params/product_catalog/_trial_offer_create_params.py new file mode 100644 index 000000000..9c21d70f1 --- /dev/null +++ b/stripe/params/product_catalog/_trial_offer_create_params.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._request_options import RequestOptions +from typing import List +from typing_extensions import Literal, NotRequired, TypedDict + + +class TrialOfferCreateParams(RequestOptions): + duration: "TrialOfferCreateParamsDuration" + """ + Duration of one service period of the trial. + """ + end_behavior: "TrialOfferCreateParamsEndBehavior" + """ + Define behavior that occurs at the end of the trial. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + price: str + """ + Price configuration during the trial period (amount, billing scheme, etc). + """ + + +class TrialOfferCreateParamsDuration(TypedDict): + relative: NotRequired["TrialOfferCreateParamsDurationRelative"] + """ + The relative duration of the trial period computed as the number of recurring price intervals. + """ + type: Literal["relative", "timestamp"] + """ + Specifies how the trial offer duration is determined. + """ + + +class TrialOfferCreateParamsDurationRelative(TypedDict): + iterations: int + """ + The number of recurring price's interval to apply for the trial period. + """ + + +class TrialOfferCreateParamsEndBehavior(TypedDict): + transition: "TrialOfferCreateParamsEndBehaviorTransition" + """ + The transition to apply when the trial offer ends. + """ + + +class TrialOfferCreateParamsEndBehaviorTransition(TypedDict): + price: str + """ + The price to transition the recurring item to when the trial offer ends. + """ diff --git a/stripe/product_catalog/__init__.py b/stripe/product_catalog/__init__.py new file mode 100644 index 000000000..e9169be92 --- /dev/null +++ b/stripe/product_catalog/__init__.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from importlib import import_module +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe.product_catalog._trial_offer import TrialOffer as TrialOffer + from stripe.product_catalog._trial_offer_service import ( + TrialOfferService as TrialOfferService, + ) + +# name -> (import_target, is_submodule) +_import_map = { + "TrialOffer": ("stripe.product_catalog._trial_offer", False), + "TrialOfferService": ( + "stripe.product_catalog._trial_offer_service", + False, + ), +} +if not TYPE_CHECKING: + + def __getattr__(name): + try: + target, is_submodule = _import_map[name] + module = import_module(target) + if is_submodule: + return module + + return getattr( + module, + name, + ) + except KeyError: + raise AttributeError() diff --git a/stripe/product_catalog/_trial_offer.py b/stripe/product_catalog/_trial_offer.py new file mode 100644 index 000000000..f59d72b62 --- /dev/null +++ b/stripe/product_catalog/_trial_offer.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._createable_api_resource import CreateableAPIResource +from stripe._expandable_field import ExpandableField +from stripe._stripe_object import StripeObject +from typing import ClassVar, cast +from typing_extensions import Literal, Unpack, TYPE_CHECKING + +if TYPE_CHECKING: + from stripe._price import Price + from stripe.params.product_catalog._trial_offer_create_params import ( + TrialOfferCreateParams, + ) + + +class TrialOffer(CreateableAPIResource["TrialOffer"]): + """ + Resource for the TrialOffer API, used to describe a subscription item's trial period settings. + Renders a TrialOffer object that describes the price, duration, end_behavior of a trial offer. + """ + + OBJECT_NAME: ClassVar[Literal["product_catalog.trial_offer"]] = ( + "product_catalog.trial_offer" + ) + + class Duration(StripeObject): + class Relative(StripeObject): + iterations: int + """ + The number of iterations of the price's interval for this trial offer. + """ + + relative: Relative + type: Literal["relative", "timestamp"] + """ + The type of trial offer duration. + """ + _inner_class_types = {"relative": Relative} + + class EndBehavior(StripeObject): + class Transition(StripeObject): + price: str + """ + The new price to use at the end of the trial offer period. + """ + + transition: Transition + type: Literal["transition"] + """ + The type of behavior when the trial offer ends. + """ + _inner_class_types = {"transition": Transition} + + duration: Duration + end_behavior: EndBehavior + id: str + """ + Unique identifier for the object. + """ + livemode: bool + """ + Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + """ + object: Literal["product_catalog.trial_offer"] + """ + String representing the object's type. Objects of the same type share the same value. + """ + price: ExpandableField["Price"] + """ + The price during the trial offer. + """ + + @classmethod + def create( + cls, **params: Unpack["TrialOfferCreateParams"] + ) -> "TrialOffer": + """ + Creates a trial offer. + """ + return cast( + "TrialOffer", + cls._static_request( + "post", + cls.class_url(), + params=params, + ), + ) + + @classmethod + async def create_async( + cls, **params: Unpack["TrialOfferCreateParams"] + ) -> "TrialOffer": + """ + Creates a trial offer. + """ + return cast( + "TrialOffer", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + + _inner_class_types = {"duration": Duration, "end_behavior": EndBehavior} diff --git a/stripe/product_catalog/_trial_offer_service.py b/stripe/product_catalog/_trial_offer_service.py new file mode 100644 index 000000000..21086018e --- /dev/null +++ b/stripe/product_catalog/_trial_offer_service.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_service import StripeService +from typing import Optional, cast +from typing_extensions import TYPE_CHECKING + +if TYPE_CHECKING: + from stripe._request_options import RequestOptions + from stripe.params.product_catalog._trial_offer_create_params import ( + TrialOfferCreateParams, + ) + from stripe.product_catalog._trial_offer import TrialOffer + + +class TrialOfferService(StripeService): + def create( + self, + params: "TrialOfferCreateParams", + options: Optional["RequestOptions"] = None, + ) -> "TrialOffer": + """ + Creates a trial offer. + """ + return cast( + "TrialOffer", + self._request( + "post", + "/v1/product_catalog/trial_offers", + base_address="api", + params=params, + options=options, + ), + ) + + async def create_async( + self, + params: "TrialOfferCreateParams", + options: Optional["RequestOptions"] = None, + ) -> "TrialOffer": + """ + Creates a trial offer. + """ + return cast( + "TrialOffer", + await self._request_async( + "post", + "/v1/product_catalog/trial_offers", + base_address="api", + params=params, + options=options, + ), + ) diff --git a/tests/test_stripe_object.py b/tests/test_stripe_object.py index c6356d672..a963fcc5d 100644 --- a/tests/test_stripe_object.py +++ b/tests/test_stripe_object.py @@ -6,6 +6,7 @@ import pytest import stripe +from stripe._invoice import Invoice from stripe._stripe_object import StripeObject # We use this because it has a map, "restriction.currency_options" from string -> CurrencyOptions nested class. @@ -433,3 +434,36 @@ def test_can_update_api_key(self, http_client_mock): api_key="key2", stripe_account=None, ) + + def test_invoice_payment_method_gets_special_error(self): + def is_good_error(e: Exception) -> bool: + return "multiple-partial-payments-on-invoices" in str(e) + + i = Invoice() + + with pytest.raises(AttributeError) as e: + i.payment_intent # type: ignore + assert is_good_error(e.value) + + with pytest.raises(KeyError) as e: + i["payment_intent"] + assert is_good_error(e.value) + + # only that property gets the special error + with pytest.raises(AttributeError) as e: + i.blah # type: ignore + assert not is_good_error(e.value) + + with pytest.raises(KeyError) as e: + i["blah"] + assert not is_good_error(e.value) + + # other classes don't have that special error + so = StripeObject() + with pytest.raises(AttributeError) as e: + so.payment_intent # type: ignore + assert not is_good_error(e.value) + + with pytest.raises(KeyError) as e: + so["payment_intent"] + assert not is_good_error(e.value)