From 791fc11538d1292cbb02d372ed11f90199962dcc Mon Sep 17 00:00:00 2001 From: "stripe-openapi[bot]" <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:35:58 -0700 Subject: [PATCH] Update generated code (#1400) * Update generated code for v1268 * Update generated code for v1268 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> --- OPENAPI_VERSION | 2 +- stripe/__init__.py | 1 + stripe/_api_version.py | 2 +- stripe/_billing_service.py | 14 + stripe/_capability.py | 2 +- stripe/_credit_note.py | 25 + stripe/_credit_note_line_item.py | 25 + stripe/_customer.py | 5 +- stripe/_invoice.py | 30 + stripe/_invoice_line_item.py | 30 + stripe/_margin.py | 50 ++ stripe/_object_classes.py | 4 + stripe/_product.py | 26 +- stripe/_product_service.py | 26 +- stripe/_promotion_code.py | 6 +- stripe/_promotion_code_service.py | 4 +- stripe/_subscription.py | 48 +- stripe/_subscription_service.py | 12 +- stripe/_webhook_endpoint.py | 1 + stripe/_webhook_endpoint_service.py | 1 + stripe/api_resources/__init__.py | 1 + stripe/api_resources/billing/__init__.py | 7 + .../billing/credit_balance_summary.py | 21 + .../billing/credit_balance_transaction.py | 21 + stripe/api_resources/billing/credit_grant.py | 21 + stripe/api_resources/margin.py | 21 + stripe/billing/__init__.py | 16 + stripe/billing/_alert.py | 61 +- stripe/billing/_alert_service.py | 36 +- stripe/billing/_credit_balance_summary.py | 158 +++++ .../_credit_balance_summary_service.py | 83 +++ stripe/billing/_credit_balance_transaction.py | 242 +++++++ .../_credit_balance_transaction_service.py | 125 ++++ stripe/billing/_credit_grant.py | 599 ++++++++++++++++++ stripe/billing/_credit_grant_service.py | 381 +++++++++++ stripe/billing_portal/_configuration.py | 11 +- .../billing_portal/_configuration_service.py | 11 +- stripe/checkout/_session.py | 2 +- stripe/checkout/_session_service.py | 2 +- stripe/tax/_settings.py | 2 +- stripe/terminal/_reader.py | 10 +- stripe/terminal/_reader_service.py | 10 +- stripe/treasury/_received_credit.py | 7 +- tests/test_generated_examples.py | 86 --- 44 files changed, 2045 insertions(+), 203 deletions(-) create mode 100644 stripe/_margin.py create mode 100644 stripe/api_resources/billing/credit_balance_summary.py create mode 100644 stripe/api_resources/billing/credit_balance_transaction.py create mode 100644 stripe/api_resources/billing/credit_grant.py create mode 100644 stripe/api_resources/margin.py create mode 100644 stripe/billing/_credit_balance_summary.py create mode 100644 stripe/billing/_credit_balance_summary_service.py create mode 100644 stripe/billing/_credit_balance_transaction.py create mode 100644 stripe/billing/_credit_balance_transaction_service.py create mode 100644 stripe/billing/_credit_grant.py create mode 100644 stripe/billing/_credit_grant_service.py diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 5f5b31119..8f166ae2e 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1267 \ No newline at end of file +v1268 \ No newline at end of file diff --git a/stripe/__init__.py b/stripe/__init__.py index 9edd2b715..90e300584 100644 --- a/stripe/__init__.py +++ b/stripe/__init__.py @@ -397,6 +397,7 @@ def __getattr__(name): from stripe._login_link import LoginLink as LoginLink from stripe._mandate import Mandate as Mandate from stripe._mandate_service import MandateService as MandateService +from stripe._margin import Margin as Margin from stripe._payment_intent import PaymentIntent as PaymentIntent from stripe._payment_intent_service import ( PaymentIntentService as PaymentIntentService, diff --git a/stripe/_api_version.py b/stripe/_api_version.py index 3e3f977ff..e23615373 100644 --- a/stripe/_api_version.py +++ b/stripe/_api_version.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # File generated from our OpenAPI spec class _ApiVersion: - CURRENT = "2024-06-20" + CURRENT = "2024-09-30.acacia" diff --git a/stripe/_billing_service.py b/stripe/_billing_service.py index e30f30081..a94b4f57c 100644 --- a/stripe/_billing_service.py +++ b/stripe/_billing_service.py @@ -2,6 +2,13 @@ # File generated from our OpenAPI spec from stripe._stripe_service import StripeService from stripe.billing._alert_service import AlertService +from stripe.billing._credit_balance_summary_service import ( + CreditBalanceSummaryService, +) +from stripe.billing._credit_balance_transaction_service import ( + CreditBalanceTransactionService, +) +from stripe.billing._credit_grant_service import CreditGrantService from stripe.billing._meter_event_adjustment_service import ( MeterEventAdjustmentService, ) @@ -13,6 +20,13 @@ class BillingService(StripeService): def __init__(self, requestor): super().__init__(requestor) self.alerts = AlertService(self._requestor) + self.credit_balance_summary = CreditBalanceSummaryService( + self._requestor, + ) + self.credit_balance_transactions = CreditBalanceTransactionService( + self._requestor, + ) + self.credit_grants = CreditGrantService(self._requestor) self.meters = MeterService(self._requestor) self.meter_events = MeterEventService(self._requestor) self.meter_event_adjustments = MeterEventAdjustmentService( diff --git a/stripe/_capability.py b/stripe/_capability.py index 944236d60..d83ba3b62 100644 --- a/stripe/_capability.py +++ b/stripe/_capability.py @@ -368,7 +368,7 @@ class Error(StripeObject): requirements: Optional[Requirements] status: Literal["active", "disabled", "inactive", "pending", "unrequested"] """ - The status of the capability. Can be `active`, `inactive`, `pending`, or `unrequested`. + The status of the capability. """ def instance_url(self): diff --git a/stripe/_credit_note.py b/stripe/_credit_note.py index 8054b28e5..6e5ae51ff 100644 --- a/stripe/_credit_note.py +++ b/stripe/_credit_note.py @@ -27,6 +27,9 @@ from stripe._refund import Refund from stripe._shipping_rate import ShippingRate from stripe._tax_rate import TaxRate + from stripe.billing._credit_balance_transaction import ( + CreditBalanceTransaction, + ) @nested_resource_class_methods("line") @@ -53,6 +56,26 @@ class DiscountAmount(StripeObject): The discount that was applied to get this discount amount. """ + class PretaxCreditAmount(StripeObject): + amount: int + """ + The amount, in cents (or local equivalent), of the pretax credit amount. + """ + credit_balance_transaction: Optional[ + ExpandableField["CreditBalanceTransaction"] + ] + """ + The credit balance transaction that was applied to get this pretax credit amount. + """ + discount: Optional[ExpandableField["Discount"]] + """ + The discount that was applied to get this pretax credit amount. + """ + type: Literal["credit_balance_transaction", "discount"] + """ + Type of the pretax credit amount referenced. + """ + class ShippingCost(StripeObject): class Tax(StripeObject): amount: int @@ -711,6 +734,7 @@ class VoidCreditNoteParams(RequestOptions): """ The link to download the PDF of the credit note. """ + pretax_credit_amounts: Optional[List[PretaxCreditAmount]] reason: Optional[ Literal[ "duplicate", "fraudulent", "order_change", "product_unsatisfactory" @@ -1122,6 +1146,7 @@ async def list_lines_async( _inner_class_types = { "discount_amounts": DiscountAmount, + "pretax_credit_amounts": PretaxCreditAmount, "shipping_cost": ShippingCost, "tax_amounts": TaxAmount, } diff --git a/stripe/_credit_note_line_item.py b/stripe/_credit_note_line_item.py index 40ebeb2df..04505cf83 100644 --- a/stripe/_credit_note_line_item.py +++ b/stripe/_credit_note_line_item.py @@ -8,6 +8,9 @@ if TYPE_CHECKING: from stripe._discount import Discount from stripe._tax_rate import TaxRate + from stripe.billing._credit_balance_transaction import ( + CreditBalanceTransaction, + ) class CreditNoteLineItem(StripeObject): @@ -29,6 +32,26 @@ class DiscountAmount(StripeObject): The discount that was applied to get this discount amount. """ + class PretaxCreditAmount(StripeObject): + amount: int + """ + The amount, in cents (or local equivalent), of the pretax credit amount. + """ + credit_balance_transaction: Optional[ + ExpandableField["CreditBalanceTransaction"] + ] + """ + The credit balance transaction that was applied to get this pretax credit amount. + """ + discount: Optional[ExpandableField["Discount"]] + """ + The discount that was applied to get this pretax credit amount. + """ + type: Literal["credit_balance_transaction", "discount"] + """ + Type of the pretax credit amount referenced. + """ + class TaxAmount(StripeObject): amount: int """ @@ -105,6 +128,7 @@ class TaxAmount(StripeObject): """ String representing the object's type. Objects of the same type share the same value. """ + pretax_credit_amounts: Optional[List[PretaxCreditAmount]] quantity: Optional[int] """ The number of units of product being credited. @@ -135,5 +159,6 @@ class TaxAmount(StripeObject): """ _inner_class_types = { "discount_amounts": DiscountAmount, + "pretax_credit_amounts": PretaxCreditAmount, "tax_amounts": TaxAmount, } diff --git a/stripe/_customer.py b/stripe/_customer.py index b163859fc..001126339 100644 --- a/stripe/_customer.py +++ b/stripe/_customer.py @@ -63,9 +63,8 @@ class Customer( UpdateableAPIResource["Customer"], ): """ - This object represents a customer of your business. Use it to create recurring charges and track payments that belong to the same customer. - - Related guide: [Save a card during payment](https://stripe.com/docs/payments/save-during-payment) + This object represents a customer of your business. Use it to [create recurring charges](https://stripe.com/docs/invoicing/customer), [save payment](https://stripe.com/docs/payments/save-during-payment) and contact information, + and track payments that belong to the same customer. """ OBJECT_NAME: ClassVar[Literal["customer"]] = "customer" diff --git a/stripe/_invoice.py b/stripe/_invoice.py index 07f217f9e..db9966044 100644 --- a/stripe/_invoice.py +++ b/stripe/_invoice.py @@ -40,6 +40,7 @@ from stripe._customer import Customer from stripe._discount import Discount from stripe._invoice_line_item import InvoiceLineItem + from stripe._margin import Margin from stripe._payment_intent import PaymentIntent from stripe._payment_method import PaymentMethod from stripe._quote import Quote @@ -49,6 +50,9 @@ from stripe._subscription import Subscription from stripe._tax_id import TaxId from stripe._tax_rate import TaxRate + from stripe.billing._credit_balance_transaction import ( + CreditBalanceTransaction, + ) from stripe.test_helpers._test_clock import TestClock @@ -965,6 +969,30 @@ class TotalDiscountAmount(StripeObject): The discount that was applied to get this discount amount. """ + class TotalPretaxCreditAmount(StripeObject): + amount: int + """ + The amount, in cents (or local equivalent), of the pretax credit amount. + """ + credit_balance_transaction: Optional[ + ExpandableField["CreditBalanceTransaction"] + ] + """ + The credit balance transaction that was applied to get this pretax credit amount. + """ + discount: Optional[ExpandableField["Discount"]] + """ + The discount that was applied to get this pretax credit amount. + """ + margin: Optional[ExpandableField["Margin"]] + """ + The margin that was applied to get this pretax credit amount. + """ + type: Literal["credit_balance_transaction", "discount"] + """ + Type of the pretax credit amount referenced. + """ + class TotalTaxAmount(StripeObject): amount: int """ @@ -6445,6 +6473,7 @@ class VoidInvoiceParams(RequestOptions): """ The integer amount in cents (or local equivalent) representing the total amount of the invoice including all discounts but excluding all tax. """ + total_pretax_credit_amounts: Optional[List[TotalPretaxCreditAmount]] total_tax_amounts: List[TotalTaxAmount] """ The aggregate amounts calculated per tax rate for all line items. @@ -7811,6 +7840,7 @@ async def list_lines_async( "subscription_details": SubscriptionDetails, "threshold_reason": ThresholdReason, "total_discount_amounts": TotalDiscountAmount, + "total_pretax_credit_amounts": TotalPretaxCreditAmount, "total_tax_amounts": TotalTaxAmount, "transfer_data": TransferData, } diff --git a/stripe/_invoice_line_item.py b/stripe/_invoice_line_item.py index 0985834a8..c81defb72 100644 --- a/stripe/_invoice_line_item.py +++ b/stripe/_invoice_line_item.py @@ -17,11 +17,15 @@ if TYPE_CHECKING: from stripe._discount import Discount from stripe._invoice_item import InvoiceItem + from stripe._margin import Margin from stripe._plan import Plan from stripe._price import Price from stripe._subscription import Subscription from stripe._subscription_item import SubscriptionItem from stripe._tax_rate import TaxRate + from stripe.billing._credit_balance_transaction import ( + CreditBalanceTransaction, + ) class InvoiceLineItem(UpdateableAPIResource["InvoiceLineItem"]): @@ -53,6 +57,30 @@ class Period(StripeObject): The start of the period. This value is inclusive. """ + class PretaxCreditAmount(StripeObject): + amount: int + """ + The amount, in cents (or local equivalent), of the pretax credit amount. + """ + credit_balance_transaction: Optional[ + ExpandableField["CreditBalanceTransaction"] + ] + """ + The credit balance transaction that was applied to get this pretax credit amount. + """ + discount: Optional[ExpandableField["Discount"]] + """ + The discount that was applied to get this pretax credit amount. + """ + margin: Optional[ExpandableField["Margin"]] + """ + The margin that was applied to get this pretax credit amount. + """ + type: Literal["credit_balance_transaction", "discount"] + """ + Type of the pretax credit amount referenced. + """ + class ProrationDetails(StripeObject): class CreditedItems(StripeObject): invoice: str @@ -362,6 +390,7 @@ class ModifyParamsTaxAmountTaxRateData(TypedDict): """ The plan of the subscription, if the line item is a subscription or a proration. """ + pretax_credit_amounts: Optional[List[PretaxCreditAmount]] price: Optional["Price"] """ The price of the line item. @@ -446,6 +475,7 @@ async def modify_async( _inner_class_types = { "discount_amounts": DiscountAmount, "period": Period, + "pretax_credit_amounts": PretaxCreditAmount, "proration_details": ProrationDetails, "tax_amounts": TaxAmount, } diff --git a/stripe/_margin.py b/stripe/_margin.py new file mode 100644 index 000000000..949e35f9b --- /dev/null +++ b/stripe/_margin.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._stripe_object import StripeObject +from typing import ClassVar, Dict, Optional +from typing_extensions import Literal + + +class Margin(StripeObject): + """ + A (partner) margin represents a specific discount distributed in partner reseller programs to business partners who + resell products and services and earn a discount (margin) for doing so. + """ + + OBJECT_NAME: ClassVar[Literal["margin"]] = "margin" + active: bool + """ + Whether the margin can be applied to invoices, invoice items, or invoice line items. Defaults to `true`. + """ + created: int + """ + Time at which the object was created. Measured in seconds since the Unix epoch. + """ + 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. + """ + metadata: Optional[Dict[str, str]] + """ + Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + """ + name: Optional[str] + """ + Name of the margin that's displayed on, for example, invoices. + """ + object: Literal["margin"] + """ + String representing the object's type. Objects of the same type share the same value. + """ + percent_off: float + """ + Percent that will be taken off the subtotal before tax (after all other discounts and promotions) of any invoice to which the margin is applied. + """ + updated: int + """ + Time at which the object was last updated. Measured in seconds since the Unix epoch. + """ diff --git a/stripe/_object_classes.py b/stripe/_object_classes.py index 083d02566..027e50d72 100644 --- a/stripe/_object_classes.py +++ b/stripe/_object_classes.py @@ -22,6 +22,9 @@ stripe.billing_portal.Session.OBJECT_NAME: stripe.billing_portal.Session, stripe.billing.Alert.OBJECT_NAME: stripe.billing.Alert, stripe.billing.AlertTriggered.OBJECT_NAME: stripe.billing.AlertTriggered, + stripe.billing.CreditBalanceSummary.OBJECT_NAME: stripe.billing.CreditBalanceSummary, + stripe.billing.CreditBalanceTransaction.OBJECT_NAME: stripe.billing.CreditBalanceTransaction, + stripe.billing.CreditGrant.OBJECT_NAME: stripe.billing.CreditGrant, stripe.billing.Meter.OBJECT_NAME: stripe.billing.Meter, stripe.billing.MeterEvent.OBJECT_NAME: stripe.billing.MeterEvent, stripe.billing.MeterEventAdjustment.OBJECT_NAME: stripe.billing.MeterEventAdjustment, @@ -78,6 +81,7 @@ stripe.LineItem.OBJECT_NAME: stripe.LineItem, stripe.LoginLink.OBJECT_NAME: stripe.LoginLink, stripe.Mandate.OBJECT_NAME: stripe.Mandate, + stripe.Margin.OBJECT_NAME: stripe.Margin, stripe.PaymentIntent.OBJECT_NAME: stripe.PaymentIntent, stripe.PaymentLink.OBJECT_NAME: stripe.PaymentLink, stripe.PaymentMethod.OBJECT_NAME: stripe.PaymentMethod, diff --git a/stripe/_product.py b/stripe/_product.py index ea3cda794..4bda6d1ca 100644 --- a/stripe/_product.py +++ b/stripe/_product.py @@ -176,6 +176,12 @@ class CreateParamsDefaultPriceData(TypedDict): """ Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). """ + custom_unit_amount: NotRequired[ + "Product.CreateParamsDefaultPriceDataCustomUnitAmount" + ] + """ + When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. + """ recurring: NotRequired["Product.CreateParamsDefaultPriceDataRecurring"] """ The recurring components of a price such as `interval` and `interval_count`. @@ -188,7 +194,7 @@ class CreateParamsDefaultPriceData(TypedDict): """ unit_amount: NotRequired[int] """ - A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. One of `unit_amount` or `unit_amount_decimal` is required. + A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. One of `unit_amount`, `unit_amount_decimal`, or `custom_unit_amount` is required. """ unit_amount_decimal: NotRequired[str] """ @@ -265,6 +271,24 @@ class CreateParamsDefaultPriceDataCurrencyOptionsTier(TypedDict): Specifies the upper bound of this tier. The lower bound of a tier is the upper bound of the previous tier adding one. Use `inf` to define a fallback tier. """ + class CreateParamsDefaultPriceDataCustomUnitAmount(TypedDict): + enabled: bool + """ + Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. + """ + maximum: NotRequired[int] + """ + The maximum unit amount the customer can specify for this item. + """ + minimum: NotRequired[int] + """ + The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. + """ + preset: NotRequired[int] + """ + The starting unit amount which can be updated by the customer. + """ + class CreateParamsDefaultPriceDataRecurring(TypedDict): interval: Literal["day", "month", "week", "year"] """ diff --git a/stripe/_product_service.py b/stripe/_product_service.py index 817c190b6..3e1b632c2 100644 --- a/stripe/_product_service.py +++ b/stripe/_product_service.py @@ -105,6 +105,12 @@ class CreateParamsDefaultPriceData(TypedDict): """ Prices defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). """ + custom_unit_amount: NotRequired[ + "ProductService.CreateParamsDefaultPriceDataCustomUnitAmount" + ] + """ + When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. + """ recurring: NotRequired[ "ProductService.CreateParamsDefaultPriceDataRecurring" ] @@ -119,7 +125,7 @@ class CreateParamsDefaultPriceData(TypedDict): """ unit_amount: NotRequired[int] """ - A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. One of `unit_amount` or `unit_amount_decimal` is required. + A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. One of `unit_amount`, `unit_amount_decimal`, or `custom_unit_amount` is required. """ unit_amount_decimal: NotRequired[str] """ @@ -198,6 +204,24 @@ class CreateParamsDefaultPriceDataCurrencyOptionsTier(TypedDict): Specifies the upper bound of this tier. The lower bound of a tier is the upper bound of the previous tier adding one. Use `inf` to define a fallback tier. """ + class CreateParamsDefaultPriceDataCustomUnitAmount(TypedDict): + enabled: bool + """ + Pass in `true` to enable `custom_unit_amount`, otherwise omit `custom_unit_amount`. + """ + maximum: NotRequired[int] + """ + The maximum unit amount the customer can specify for this item. + """ + minimum: NotRequired[int] + """ + The minimum unit amount the customer can specify for this item. Must be at least the minimum charge amount. + """ + preset: NotRequired[int] + """ + The starting unit amount which can be updated by the customer. + """ + class CreateParamsDefaultPriceDataRecurring(TypedDict): interval: Literal["day", "month", "week", "year"] """ diff --git a/stripe/_promotion_code.py b/stripe/_promotion_code.py index 13fb3c528..e11786c09 100644 --- a/stripe/_promotion_code.py +++ b/stripe/_promotion_code.py @@ -67,7 +67,9 @@ class CreateParams(RequestOptions): """ code: NotRequired[str] """ - The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for a specific customer. If left blank, we will generate one automatically. + The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for a specific customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), and digits (0-9). + + If left blank, we will generate one automatically. """ coupon: str """ @@ -224,7 +226,7 @@ class RetrieveParams(RequestOptions): """ code: str """ - The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer. + The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), and digits (0-9). """ coupon: "Coupon" """ diff --git a/stripe/_promotion_code_service.py b/stripe/_promotion_code_service.py index b3eeed7b3..4da95a810 100644 --- a/stripe/_promotion_code_service.py +++ b/stripe/_promotion_code_service.py @@ -17,7 +17,9 @@ class CreateParams(TypedDict): """ code: NotRequired[str] """ - The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for a specific customer. If left blank, we will generate one automatically. + The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for a specific customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), and digits (0-9). + + If left blank, we will generate one automatically. """ coupon: str """ diff --git a/stripe/_subscription.py b/stripe/_subscription.py index ad418161e..93c9edeb6 100644 --- a/stripe/_subscription.py +++ b/stripe/_subscription.py @@ -2270,11 +2270,11 @@ def _cls_cancel( **params: Unpack["Subscription.CancelParams"], ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ return cast( "Subscription", @@ -2296,11 +2296,11 @@ def cancel( **params: Unpack["Subscription.CancelParams"], ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ ... @@ -2309,11 +2309,11 @@ def cancel( self, **params: Unpack["Subscription.CancelParams"] ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ ... @@ -2322,11 +2322,11 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] self, **params: Unpack["Subscription.CancelParams"] ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ return cast( "Subscription", @@ -2346,11 +2346,11 @@ async def _cls_cancel_async( **params: Unpack["Subscription.CancelParams"], ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ return cast( "Subscription", @@ -2372,11 +2372,11 @@ async def cancel_async( **params: Unpack["Subscription.CancelParams"], ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ ... @@ -2385,11 +2385,11 @@ async def cancel_async( self, **params: Unpack["Subscription.CancelParams"] ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ ... @@ -2398,11 +2398,11 @@ async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] self, **params: Unpack["Subscription.CancelParams"] ) -> "Subscription": """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ return cast( "Subscription", diff --git a/stripe/_subscription_service.py b/stripe/_subscription_service.py index e034f9751..adad3f820 100644 --- a/stripe/_subscription_service.py +++ b/stripe/_subscription_service.py @@ -1647,11 +1647,11 @@ def cancel( options: RequestOptions = {}, ) -> Subscription: """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ return cast( Subscription, @@ -1675,11 +1675,11 @@ async def cancel_async( options: RequestOptions = {}, ) -> Subscription: """ - Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + Cancels a customer's subscription immediately. The customer won't be charged again for the subscription. After it's canceled, you can no longer update the subscription or its [metadata](https://stripe.com/metadata). - Note, however, that any pending invoice items that you've created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations will be removed. + Any pending invoice items that you've created are still charged at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). If you've set the subscription to cancel at the end of the period, any pending prorations are also left in place and collected at the end of the period. But if the subscription is set to cancel immediately, pending prorations are removed. - By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + By default, upon subscription cancellation, Stripe stops automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. """ return cast( Subscription, diff --git a/stripe/_webhook_endpoint.py b/stripe/_webhook_endpoint.py index 9fc7bcb79..bd4140848 100644 --- a/stripe/_webhook_endpoint.py +++ b/stripe/_webhook_endpoint.py @@ -134,6 +134,7 @@ class CreateParams(RequestOptions): "2023-10-16", "2024-04-10", "2024-06-20", + "2024-09-30.acacia", ] ] """ diff --git a/stripe/_webhook_endpoint_service.py b/stripe/_webhook_endpoint_service.py index 2acb57b8c..c29a6db8c 100644 --- a/stripe/_webhook_endpoint_service.py +++ b/stripe/_webhook_endpoint_service.py @@ -115,6 +115,7 @@ class CreateParams(TypedDict): "2023-10-16", "2024-04-10", "2024-06-20", + "2024-09-30.acacia", ] ] """ diff --git a/stripe/api_resources/__init__.py b/stripe/api_resources/__init__.py index 99bf65826..d142b58af 100644 --- a/stripe/api_resources/__init__.py +++ b/stripe/api_resources/__init__.py @@ -85,6 +85,7 @@ from stripe.api_resources.list_object import ListObject from stripe.api_resources.login_link import LoginLink from stripe.api_resources.mandate import Mandate + from stripe.api_resources.margin import Margin from stripe.api_resources.payment_intent import PaymentIntent from stripe.api_resources.payment_link import PaymentLink from stripe.api_resources.payment_method import PaymentMethod diff --git a/stripe/api_resources/billing/__init__.py b/stripe/api_resources/billing/__init__.py index e469ff8d7..3375658a4 100644 --- a/stripe/api_resources/billing/__init__.py +++ b/stripe/api_resources/billing/__init__.py @@ -18,6 +18,13 @@ if not TYPE_CHECKING: from stripe.api_resources.billing.alert import Alert from stripe.api_resources.billing.alert_triggered import AlertTriggered + from stripe.api_resources.billing.credit_balance_summary import ( + CreditBalanceSummary, + ) + from stripe.api_resources.billing.credit_balance_transaction import ( + CreditBalanceTransaction, + ) + from stripe.api_resources.billing.credit_grant import CreditGrant from stripe.api_resources.billing.meter import Meter from stripe.api_resources.billing.meter_event import MeterEvent from stripe.api_resources.billing.meter_event_adjustment import ( diff --git a/stripe/api_resources/billing/credit_balance_summary.py b/stripe/api_resources/billing/credit_balance_summary.py new file mode 100644 index 000000000..48e8754c2 --- /dev/null +++ b/stripe/api_resources/billing/credit_balance_summary.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing_extensions import TYPE_CHECKING +from warnings import warn + +warn( + """ + The stripe.api_resources.billing.credit_balance_summary package is deprecated, please change your + imports to import from stripe.billing directly. + From: + from stripe.api_resources.billing.credit_balance_summary import CreditBalanceSummary + To: + from stripe.billing import CreditBalanceSummary + """, + DeprecationWarning, + stacklevel=2, +) +if not TYPE_CHECKING: + from stripe.billing._credit_balance_summary import ( # noqa + CreditBalanceSummary, + ) diff --git a/stripe/api_resources/billing/credit_balance_transaction.py b/stripe/api_resources/billing/credit_balance_transaction.py new file mode 100644 index 000000000..8797820ad --- /dev/null +++ b/stripe/api_resources/billing/credit_balance_transaction.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing_extensions import TYPE_CHECKING +from warnings import warn + +warn( + """ + The stripe.api_resources.billing.credit_balance_transaction package is deprecated, please change your + imports to import from stripe.billing directly. + From: + from stripe.api_resources.billing.credit_balance_transaction import CreditBalanceTransaction + To: + from stripe.billing import CreditBalanceTransaction + """, + DeprecationWarning, + stacklevel=2, +) +if not TYPE_CHECKING: + from stripe.billing._credit_balance_transaction import ( # noqa + CreditBalanceTransaction, + ) diff --git a/stripe/api_resources/billing/credit_grant.py b/stripe/api_resources/billing/credit_grant.py new file mode 100644 index 000000000..4d50815d7 --- /dev/null +++ b/stripe/api_resources/billing/credit_grant.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing_extensions import TYPE_CHECKING +from warnings import warn + +warn( + """ + The stripe.api_resources.billing.credit_grant package is deprecated, please change your + imports to import from stripe.billing directly. + From: + from stripe.api_resources.billing.credit_grant import CreditGrant + To: + from stripe.billing import CreditGrant + """, + DeprecationWarning, + stacklevel=2, +) +if not TYPE_CHECKING: + from stripe.billing._credit_grant import ( # noqa + CreditGrant, + ) diff --git a/stripe/api_resources/margin.py b/stripe/api_resources/margin.py new file mode 100644 index 000000000..2a94240be --- /dev/null +++ b/stripe/api_resources/margin.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from typing_extensions import TYPE_CHECKING +from warnings import warn + +warn( + """ + The stripe.api_resources.margin package is deprecated, please change your + imports to import from stripe directly. + From: + from stripe.api_resources.margin import Margin + To: + from stripe import Margin + """, + DeprecationWarning, + stacklevel=2, +) +if not TYPE_CHECKING: + from stripe._margin import ( # noqa + Margin, + ) diff --git a/stripe/billing/__init__.py b/stripe/billing/__init__.py index a6aea1532..29a9770a6 100644 --- a/stripe/billing/__init__.py +++ b/stripe/billing/__init__.py @@ -3,6 +3,22 @@ from stripe.billing._alert import Alert as Alert from stripe.billing._alert_service import AlertService as AlertService from stripe.billing._alert_triggered import AlertTriggered as AlertTriggered +from stripe.billing._credit_balance_summary import ( + CreditBalanceSummary as CreditBalanceSummary, +) +from stripe.billing._credit_balance_summary_service import ( + CreditBalanceSummaryService as CreditBalanceSummaryService, +) +from stripe.billing._credit_balance_transaction import ( + CreditBalanceTransaction as CreditBalanceTransaction, +) +from stripe.billing._credit_balance_transaction_service import ( + CreditBalanceTransactionService as CreditBalanceTransactionService, +) +from stripe.billing._credit_grant import CreditGrant as CreditGrant +from stripe.billing._credit_grant_service import ( + CreditGrantService as CreditGrantService, +) from stripe.billing._meter import Meter as Meter from stripe.billing._meter_event import MeterEvent as MeterEvent from stripe.billing._meter_event_adjustment import ( diff --git a/stripe/billing/_alert.py b/stripe/billing/_alert.py index 02aecb7da..0141ba0e7 100644 --- a/stripe/billing/_alert.py +++ b/stripe/billing/_alert.py @@ -28,13 +28,18 @@ class Alert(CreateableAPIResource["Alert"], ListableAPIResource["Alert"]): OBJECT_NAME: ClassVar[Literal["billing.alert"]] = "billing.alert" - class Filter(StripeObject): - customer: Optional[ExpandableField["Customer"]] + class UsageThreshold(StripeObject): + class Filter(StripeObject): + customer: Optional[ExpandableField["Customer"]] + """ + Limit the scope of the alert to this customer ID + """ + type: Literal["customer"] + + filters: Optional[List[Filter]] """ - Limit the scope of the alert to this customer ID + The filters allow limiting the scope of this usage alert. You can only specify up to one filter at this time. """ - - class UsageThresholdConfig(StripeObject): gte: int """ The value at which this alert will trigger. @@ -47,6 +52,7 @@ class UsageThresholdConfig(StripeObject): """ Defines how the alert will behave. """ + _inner_class_types = {"filters": Filter} class ActivateParams(RequestOptions): expand: NotRequired[List[str]] @@ -69,36 +75,20 @@ class CreateParams(RequestOptions): """ Specifies which fields in the response should be expanded. """ - filter: NotRequired["Alert.CreateParamsFilter"] - """ - Filters to limit the scope of an alert. - """ title: str """ The title of the alert. """ - usage_threshold_config: NotRequired[ - "Alert.CreateParamsUsageThresholdConfig" - ] + usage_threshold: NotRequired["Alert.CreateParamsUsageThreshold"] """ The configuration of the usage threshold. """ - class CreateParamsFilter(TypedDict): - customer: NotRequired[str] - """ - Limit the scope to this alert only to this customer. - """ - subscription: NotRequired[str] - """ - Limit the scope of this rated usage alert to this subscription. - """ - subscription_item: NotRequired[str] + class CreateParamsUsageThreshold(TypedDict): + filters: NotRequired[List["Alert.CreateParamsUsageThresholdFilter"]] """ - Limit the scope of this rated usage alert to this subscription item. + The filters allows limiting the scope of this usage alert. You can only specify up to one filter at this time. """ - - class CreateParamsUsageThresholdConfig(TypedDict): gte: int """ Defines at which value the alert will fire. @@ -112,6 +102,16 @@ class CreateParamsUsageThresholdConfig(TypedDict): Whether the alert should only fire only once, or once per billing cycle. """ + class CreateParamsUsageThresholdFilter(TypedDict): + customer: NotRequired[str] + """ + Limit the scope to this usage alert only to this customer. + """ + type: Literal["customer"] + """ + What type of filter is being applied to this usage alert. + """ + class DeactivateParams(RequestOptions): expand: NotRequired[List[str]] """ @@ -154,10 +154,6 @@ class RetrieveParams(RequestOptions): """ Defines the type of the alert. """ - filter: Optional[Filter] - """ - Limits the scope of the alert to a specific [customer](https://stripe.com/docs/api/customers). - """ id: str """ Unique identifier for the object. @@ -178,7 +174,7 @@ class RetrieveParams(RequestOptions): """ Title of the alert. """ - usage_threshold_config: Optional[UsageThresholdConfig] + usage_threshold: Optional[UsageThreshold] """ Encapsulates configuration of the alert to monitor usage on a specific [Billing Meter](https://stripe.com/docs/api/billing/meter). """ @@ -587,7 +583,4 @@ async def retrieve_async( await instance.refresh_async() return instance - _inner_class_types = { - "filter": Filter, - "usage_threshold_config": UsageThresholdConfig, - } + _inner_class_types = {"usage_threshold": UsageThreshold} diff --git a/stripe/billing/_alert_service.py b/stripe/billing/_alert_service.py index 39649a26a..457fefda8 100644 --- a/stripe/billing/_alert_service.py +++ b/stripe/billing/_alert_service.py @@ -31,36 +31,22 @@ class CreateParams(TypedDict): """ Specifies which fields in the response should be expanded. """ - filter: NotRequired["AlertService.CreateParamsFilter"] - """ - Filters to limit the scope of an alert. - """ title: str """ The title of the alert. """ - usage_threshold_config: NotRequired[ - "AlertService.CreateParamsUsageThresholdConfig" - ] + usage_threshold: NotRequired["AlertService.CreateParamsUsageThreshold"] """ The configuration of the usage threshold. """ - class CreateParamsFilter(TypedDict): - customer: NotRequired[str] - """ - Limit the scope to this alert only to this customer. - """ - subscription: NotRequired[str] - """ - Limit the scope of this rated usage alert to this subscription. - """ - subscription_item: NotRequired[str] + class CreateParamsUsageThreshold(TypedDict): + filters: NotRequired[ + List["AlertService.CreateParamsUsageThresholdFilter"] + ] """ - Limit the scope of this rated usage alert to this subscription item. + The filters allows limiting the scope of this usage alert. You can only specify up to one filter at this time. """ - - class CreateParamsUsageThresholdConfig(TypedDict): gte: int """ Defines at which value the alert will fire. @@ -74,6 +60,16 @@ class CreateParamsUsageThresholdConfig(TypedDict): Whether the alert should only fire only once, or once per billing cycle. """ + class CreateParamsUsageThresholdFilter(TypedDict): + customer: NotRequired[str] + """ + Limit the scope to this usage alert only to this customer. + """ + type: Literal["customer"] + """ + What type of filter is being applied to this usage alert. + """ + class DeactivateParams(TypedDict): expand: NotRequired[List[str]] """ diff --git a/stripe/billing/_credit_balance_summary.py b/stripe/billing/_credit_balance_summary.py new file mode 100644 index 000000000..d91252dbf --- /dev/null +++ b/stripe/billing/_credit_balance_summary.py @@ -0,0 +1,158 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._expandable_field import ExpandableField +from stripe._request_options import RequestOptions +from stripe._singleton_api_resource import SingletonAPIResource +from stripe._stripe_object import StripeObject +from typing import ClassVar, List, Optional +from typing_extensions import ( + Literal, + NotRequired, + TypedDict, + Unpack, + TYPE_CHECKING, +) + +if TYPE_CHECKING: + from stripe._customer import Customer + + +class CreditBalanceSummary(SingletonAPIResource["CreditBalanceSummary"]): + """ + Indicates the credit balance for credits granted to a customer. + """ + + OBJECT_NAME: ClassVar[Literal["billing.credit_balance_summary"]] = ( + "billing.credit_balance_summary" + ) + + class Balance(StripeObject): + class AvailableBalance(StripeObject): + class Monetary(StripeObject): + currency: str + """ + Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + """ + value: int + """ + A positive integer representing the amount. + """ + + monetary: Optional[Monetary] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + The type of this amount. We currently only support `monetary` credits. + """ + _inner_class_types = {"monetary": Monetary} + + class LedgerBalance(StripeObject): + class Monetary(StripeObject): + currency: str + """ + Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + """ + value: int + """ + A positive integer representing the amount. + """ + + monetary: Optional[Monetary] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + The type of this amount. We currently only support `monetary` credits. + """ + _inner_class_types = {"monetary": Monetary} + + available_balance: AvailableBalance + ledger_balance: LedgerBalance + _inner_class_types = { + "available_balance": AvailableBalance, + "ledger_balance": LedgerBalance, + } + + class RetrieveParams(RequestOptions): + customer: str + """ + The customer for which to fetch credit balance summary. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + filter: "CreditBalanceSummary.RetrieveParamsFilter" + """ + The filter criteria for the credit balance summary. + """ + + class RetrieveParamsFilter(TypedDict): + applicability_scope: NotRequired[ + "CreditBalanceSummary.RetrieveParamsFilterApplicabilityScope" + ] + """ + The credit applicability scope for which to fetch balance summary. + """ + credit_grant: NotRequired[str] + """ + The credit grant for which to fetch balance summary. + """ + type: Literal["applicability_scope", "credit_grant"] + """ + Specify the type of this filter. + """ + + class RetrieveParamsFilterApplicabilityScope(TypedDict): + price_type: Literal["metered"] + """ + The price type to which credit grants can apply to. We currently only support `metered` price type. + """ + + balances: List[Balance] + """ + The credit balances. One entry per credit grant currency. If a customer only has credit grants in a single currency, then this will have a single balance entry. + """ + customer: ExpandableField["Customer"] + """ + The customer the balance is for. + """ + 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["billing.credit_balance_summary"] + """ + String representing the object's type. Objects of the same type share the same value. + """ + + @classmethod + def retrieve( + cls, **params: Unpack["CreditBalanceSummary.RetrieveParams"] + ) -> "CreditBalanceSummary": + """ + Retrieves the credit balance summary for a customer + """ + instance = cls(None, **params) + instance.refresh() + return instance + + @classmethod + async def retrieve_async( + cls, **params: Unpack["CreditBalanceSummary.RetrieveParams"] + ) -> "CreditBalanceSummary": + """ + Retrieves the credit balance summary for a customer + """ + instance = cls(None, **params) + await instance.refresh_async() + return instance + + @classmethod + def class_url(cls): + return "/v1/billing/credit_balance_summary" + + _inner_class_types = {"balances": Balance} diff --git a/stripe/billing/_credit_balance_summary_service.py b/stripe/billing/_credit_balance_summary_service.py new file mode 100644 index 000000000..045e093b0 --- /dev/null +++ b/stripe/billing/_credit_balance_summary_service.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._request_options import RequestOptions +from stripe._stripe_service import StripeService +from stripe.billing._credit_balance_summary import CreditBalanceSummary +from typing import List, cast +from typing_extensions import Literal, NotRequired, TypedDict + + +class CreditBalanceSummaryService(StripeService): + class RetrieveParams(TypedDict): + customer: str + """ + The customer for which to fetch credit balance summary. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + filter: "CreditBalanceSummaryService.RetrieveParamsFilter" + """ + The filter criteria for the credit balance summary. + """ + + class RetrieveParamsFilter(TypedDict): + applicability_scope: NotRequired[ + "CreditBalanceSummaryService.RetrieveParamsFilterApplicabilityScope" + ] + """ + The credit applicability scope for which to fetch balance summary. + """ + credit_grant: NotRequired[str] + """ + The credit grant for which to fetch balance summary. + """ + type: Literal["applicability_scope", "credit_grant"] + """ + Specify the type of this filter. + """ + + class RetrieveParamsFilterApplicabilityScope(TypedDict): + price_type: Literal["metered"] + """ + The price type to which credit grants can apply to. We currently only support `metered` price type. + """ + + def retrieve( + self, + params: "CreditBalanceSummaryService.RetrieveParams", + options: RequestOptions = {}, + ) -> CreditBalanceSummary: + """ + Retrieves the credit balance summary for a customer + """ + return cast( + CreditBalanceSummary, + self._request( + "get", + "/v1/billing/credit_balance_summary", + base_address="api", + params=params, + options=options, + ), + ) + + async def retrieve_async( + self, + params: "CreditBalanceSummaryService.RetrieveParams", + options: RequestOptions = {}, + ) -> CreditBalanceSummary: + """ + Retrieves the credit balance summary for a customer + """ + return cast( + CreditBalanceSummary, + await self._request_async( + "get", + "/v1/billing/credit_balance_summary", + base_address="api", + params=params, + options=options, + ), + ) diff --git a/stripe/billing/_credit_balance_transaction.py b/stripe/billing/_credit_balance_transaction.py new file mode 100644 index 000000000..ff8de6bad --- /dev/null +++ b/stripe/billing/_credit_balance_transaction.py @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._expandable_field import ExpandableField +from stripe._list_object import ListObject +from stripe._listable_api_resource import ListableAPIResource +from stripe._request_options import RequestOptions +from stripe._stripe_object import StripeObject +from typing import ClassVar, List, Optional +from typing_extensions import Literal, NotRequired, Unpack, TYPE_CHECKING + +if TYPE_CHECKING: + from stripe._invoice import Invoice + from stripe.billing._credit_grant import CreditGrant + from stripe.test_helpers._test_clock import TestClock + + +class CreditBalanceTransaction( + ListableAPIResource["CreditBalanceTransaction"] +): + """ + A credit balance transaction is a resource representing a transaction (either a credit or a debit) against an existing credit grant. + """ + + OBJECT_NAME: ClassVar[Literal["billing.credit_balance_transaction"]] = ( + "billing.credit_balance_transaction" + ) + + class Credit(StripeObject): + class Amount(StripeObject): + class Monetary(StripeObject): + currency: str + """ + Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + """ + value: int + """ + A positive integer representing the amount. + """ + + monetary: Optional[Monetary] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + The type of this amount. We currently only support `monetary` credits. + """ + _inner_class_types = {"monetary": Monetary} + + amount: Amount + type: Literal["credits_granted"] + """ + The type of credit transaction. + """ + _inner_class_types = {"amount": Amount} + + class Debit(StripeObject): + class Amount(StripeObject): + class Monetary(StripeObject): + currency: str + """ + Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + """ + value: int + """ + A positive integer representing the amount. + """ + + monetary: Optional[Monetary] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + The type of this amount. We currently only support `monetary` credits. + """ + _inner_class_types = {"monetary": Monetary} + + class CreditsApplied(StripeObject): + invoice: ExpandableField["Invoice"] + """ + The invoice to which the credits were applied. + """ + invoice_line_item: str + """ + The invoice line item to which the credits were applied. + """ + + amount: Amount + credits_applied: Optional[CreditsApplied] + """ + Details of how the credits were applied to an invoice. Only present if `type` is `credits_applied`. + """ + type: Literal["credits_applied", "credits_expired", "credits_voided"] + """ + The type of debit transaction. + """ + _inner_class_types = { + "amount": Amount, + "credits_applied": CreditsApplied, + } + + class ListParams(RequestOptions): + credit_grant: NotRequired[str] + """ + The credit grant for which to fetch credit balance transactions. + """ + customer: str + """ + The customer for which to fetch credit balance transactions. + """ + ending_before: NotRequired[str] + """ + A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + limit: NotRequired[int] + """ + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + """ + starting_after: NotRequired[str] + """ + A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + """ + + class RetrieveParams(RequestOptions): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + created: int + """ + Time at which the object was created. Measured in seconds since the Unix epoch. + """ + credit: Optional[Credit] + """ + Credit details for this balance transaction. Only present if type is `credit`. + """ + credit_grant: ExpandableField["CreditGrant"] + """ + The credit grant associated with this balance transaction. + """ + debit: Optional[Debit] + """ + Debit details for this balance transaction. Only present if type is `debit`. + """ + effective_at: int + """ + The effective time of this balance transaction. + """ + 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["billing.credit_balance_transaction"] + """ + String representing the object's type. Objects of the same type share the same value. + """ + test_clock: Optional[ExpandableField["TestClock"]] + """ + ID of the test clock this credit balance transaction belongs to. + """ + type: Optional[Literal["credit", "debit"]] + """ + The type of balance transaction (credit or debit). + """ + + @classmethod + def list( + cls, **params: Unpack["CreditBalanceTransaction.ListParams"] + ) -> ListObject["CreditBalanceTransaction"]: + """ + Retrieve a list of credit balance transactions + """ + result = cls._static_request( + "get", + cls.class_url(), + params=params, + ) + if not isinstance(result, ListObject): + raise TypeError( + "Expected list object from API, got %s" + % (type(result).__name__) + ) + + return result + + @classmethod + async def list_async( + cls, **params: Unpack["CreditBalanceTransaction.ListParams"] + ) -> ListObject["CreditBalanceTransaction"]: + """ + Retrieve a list of credit balance transactions + """ + result = await cls._static_request_async( + "get", + cls.class_url(), + params=params, + ) + if not isinstance(result, ListObject): + raise TypeError( + "Expected list object from API, got %s" + % (type(result).__name__) + ) + + return result + + @classmethod + def retrieve( + cls, + id: str, + **params: Unpack["CreditBalanceTransaction.RetrieveParams"], + ) -> "CreditBalanceTransaction": + """ + Retrieves a credit balance transaction + """ + instance = cls(id, **params) + instance.refresh() + return instance + + @classmethod + async def retrieve_async( + cls, + id: str, + **params: Unpack["CreditBalanceTransaction.RetrieveParams"], + ) -> "CreditBalanceTransaction": + """ + Retrieves a credit balance transaction + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + + _inner_class_types = {"credit": Credit, "debit": Debit} diff --git a/stripe/billing/_credit_balance_transaction_service.py b/stripe/billing/_credit_balance_transaction_service.py new file mode 100644 index 000000000..102258473 --- /dev/null +++ b/stripe/billing/_credit_balance_transaction_service.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._list_object import ListObject +from stripe._request_options import RequestOptions +from stripe._stripe_service import StripeService +from stripe._util import sanitize_id +from stripe.billing._credit_balance_transaction import CreditBalanceTransaction +from typing import List, cast +from typing_extensions import NotRequired, TypedDict + + +class CreditBalanceTransactionService(StripeService): + class ListParams(TypedDict): + credit_grant: NotRequired[str] + """ + The credit grant for which to fetch credit balance transactions. + """ + customer: str + """ + The customer for which to fetch credit balance transactions. + """ + ending_before: NotRequired[str] + """ + A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + limit: NotRequired[int] + """ + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + """ + starting_after: NotRequired[str] + """ + A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + """ + + class RetrieveParams(TypedDict): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + def list( + self, + params: "CreditBalanceTransactionService.ListParams", + options: RequestOptions = {}, + ) -> ListObject[CreditBalanceTransaction]: + """ + Retrieve a list of credit balance transactions + """ + return cast( + ListObject[CreditBalanceTransaction], + self._request( + "get", + "/v1/billing/credit_balance_transactions", + base_address="api", + params=params, + options=options, + ), + ) + + async def list_async( + self, + params: "CreditBalanceTransactionService.ListParams", + options: RequestOptions = {}, + ) -> ListObject[CreditBalanceTransaction]: + """ + Retrieve a list of credit balance transactions + """ + return cast( + ListObject[CreditBalanceTransaction], + await self._request_async( + "get", + "/v1/billing/credit_balance_transactions", + base_address="api", + params=params, + options=options, + ), + ) + + def retrieve( + self, + id: str, + params: "CreditBalanceTransactionService.RetrieveParams" = {}, + options: RequestOptions = {}, + ) -> CreditBalanceTransaction: + """ + Retrieves a credit balance transaction + """ + return cast( + CreditBalanceTransaction, + self._request( + "get", + "/v1/billing/credit_balance_transactions/{id}".format( + id=sanitize_id(id), + ), + base_address="api", + params=params, + options=options, + ), + ) + + async def retrieve_async( + self, + id: str, + params: "CreditBalanceTransactionService.RetrieveParams" = {}, + options: RequestOptions = {}, + ) -> CreditBalanceTransaction: + """ + Retrieves a credit balance transaction + """ + return cast( + CreditBalanceTransaction, + await self._request_async( + "get", + "/v1/billing/credit_balance_transactions/{id}".format( + id=sanitize_id(id), + ), + base_address="api", + params=params, + options=options, + ), + ) diff --git a/stripe/billing/_credit_grant.py b/stripe/billing/_credit_grant.py new file mode 100644 index 000000000..51858796d --- /dev/null +++ b/stripe/billing/_credit_grant.py @@ -0,0 +1,599 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._createable_api_resource import CreateableAPIResource +from stripe._expandable_field import ExpandableField +from stripe._list_object import ListObject +from stripe._listable_api_resource import ListableAPIResource +from stripe._request_options import RequestOptions +from stripe._stripe_object import StripeObject +from stripe._updateable_api_resource import UpdateableAPIResource +from stripe._util import class_method_variant, sanitize_id +from typing import ClassVar, Dict, List, Optional, cast, overload +from typing_extensions import ( + Literal, + NotRequired, + TypedDict, + Unpack, + TYPE_CHECKING, +) + +if TYPE_CHECKING: + from stripe._customer import Customer + from stripe.test_helpers._test_clock import TestClock + + +class CreditGrant( + CreateableAPIResource["CreditGrant"], + ListableAPIResource["CreditGrant"], + UpdateableAPIResource["CreditGrant"], +): + """ + A credit grant is a resource that records a grant of some credit to a customer. + """ + + OBJECT_NAME: ClassVar[Literal["billing.credit_grant"]] = ( + "billing.credit_grant" + ) + + class Amount(StripeObject): + class Monetary(StripeObject): + currency: str + """ + Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). + """ + value: int + """ + A positive integer representing the amount. + """ + + monetary: Optional[Monetary] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + The type of this amount. We currently only support `monetary` credits. + """ + _inner_class_types = {"monetary": Monetary} + + class ApplicabilityConfig(StripeObject): + class Scope(StripeObject): + price_type: Literal["metered"] + """ + The price type to which credit grants can apply to. We currently only support `metered` price type. + """ + + scope: Scope + _inner_class_types = {"scope": Scope} + + class CreateParams(RequestOptions): + amount: "CreditGrant.CreateParamsAmount" + """ + Amount of this credit grant. + """ + applicability_config: "CreditGrant.CreateParamsApplicabilityConfig" + """ + Configuration specifying what this credit grant applies to. + """ + category: Literal["paid", "promotional"] + """ + The category of this credit grant. + """ + customer: str + """ + Id of the customer to whom the credit should be granted. + """ + effective_at: NotRequired[int] + """ + The time when the credit becomes effective i.e when it is eligible to be used. Defaults to the current timestamp if not specified. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + expires_at: NotRequired[int] + """ + The time when the credit will expire. If not specified, the credit will never expire. + """ + metadata: NotRequired[Dict[str, str]] + """ + Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object (ex: cost basis) in a structured format. + """ + name: NotRequired[str] + """ + A descriptive name shown in dashboard and on invoices. + """ + + class CreateParamsAmount(TypedDict): + monetary: NotRequired["CreditGrant.CreateParamsAmountMonetary"] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + Specify the type of this amount. We currently only support `monetary` credits. + """ + + class CreateParamsAmountMonetary(TypedDict): + currency: str + """ + Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the `value` parameter. + """ + value: int + """ + A positive integer representing the amount of the credit grant. + """ + + class CreateParamsApplicabilityConfig(TypedDict): + scope: "CreditGrant.CreateParamsApplicabilityConfigScope" + """ + Specify the scope of this applicability config. + """ + + class CreateParamsApplicabilityConfigScope(TypedDict): + price_type: Literal["metered"] + """ + The price type to which credit grants can apply to. We currently only support `metered` price type. + """ + + class ExpireParams(RequestOptions): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + class ListParams(RequestOptions): + customer: NotRequired[str] + """ + Only return credit grants for this customer. + """ + ending_before: NotRequired[str] + """ + A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + limit: NotRequired[int] + """ + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + """ + starting_after: NotRequired[str] + """ + A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + """ + + class ModifyParams(RequestOptions): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + expires_at: NotRequired["Literal['']|int"] + """ + The time when the credit created by this credit grant will expire. If set to empty, the credit will never expire. + """ + metadata: NotRequired[Dict[str, str]] + """ + Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object (ex: cost basis) in a structured format. + """ + + class RetrieveParams(RequestOptions): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + class VoidGrantParams(RequestOptions): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + amount: Amount + applicability_config: ApplicabilityConfig + category: Literal["paid", "promotional"] + """ + The category of this credit grant. + """ + created: int + """ + Time at which the object was created. Measured in seconds since the Unix epoch. + """ + customer: ExpandableField["Customer"] + """ + Id of the customer to whom the credit was granted. + """ + effective_at: Optional[int] + """ + The time when the credit becomes effective i.e when it is eligible to be used. + """ + expires_at: Optional[int] + """ + The time when the credit will expire. If not present, the credit will never expire. + """ + 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. + """ + metadata: Dict[str, str] + """ + Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. + """ + name: Optional[str] + """ + A descriptive name shown in dashboard and on invoices. + """ + object: Literal["billing.credit_grant"] + """ + String representing the object's type. Objects of the same type share the same value. + """ + test_clock: Optional[ExpandableField["TestClock"]] + """ + ID of the test clock this credit grant belongs to. + """ + updated: int + """ + Time at which the object was last updated. Measured in seconds since the Unix epoch. + """ + voided_at: Optional[int] + """ + The time when this credit grant was voided. If not present, the credit grant hasn't been voided. + """ + + @classmethod + def create( + cls, **params: Unpack["CreditGrant.CreateParams"] + ) -> "CreditGrant": + """ + Creates a credit grant + """ + return cast( + "CreditGrant", + cls._static_request( + "post", + cls.class_url(), + params=params, + ), + ) + + @classmethod + async def create_async( + cls, **params: Unpack["CreditGrant.CreateParams"] + ) -> "CreditGrant": + """ + Creates a credit grant + """ + return cast( + "CreditGrant", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + + @classmethod + def _cls_expire( + cls, id: str, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + return cast( + "CreditGrant", + cls._static_request( + "post", + "/v1/billing/credit_grants/{id}/expire".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + def expire( + id: str, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + ... + + @overload + def expire( + self, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + ... + + @class_method_variant("_cls_expire") + def expire( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + return cast( + "CreditGrant", + self._request( + "post", + "/v1/billing/credit_grants/{id}/expire".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + async def _cls_expire_async( + cls, id: str, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + return cast( + "CreditGrant", + await cls._static_request_async( + "post", + "/v1/billing/credit_grants/{id}/expire".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def expire_async( + id: str, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + ... + + @overload + async def expire_async( + self, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + ... + + @class_method_variant("_cls_expire_async") + async def expire_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditGrant.ExpireParams"] + ) -> "CreditGrant": + """ + Expires a credit grant + """ + return cast( + "CreditGrant", + await self._request_async( + "post", + "/v1/billing/credit_grants/{id}/expire".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + def list( + cls, **params: Unpack["CreditGrant.ListParams"] + ) -> ListObject["CreditGrant"]: + """ + Retrieve a list of credit grants + """ + result = cls._static_request( + "get", + cls.class_url(), + params=params, + ) + if not isinstance(result, ListObject): + raise TypeError( + "Expected list object from API, got %s" + % (type(result).__name__) + ) + + return result + + @classmethod + async def list_async( + cls, **params: Unpack["CreditGrant.ListParams"] + ) -> ListObject["CreditGrant"]: + """ + Retrieve a list of credit grants + """ + result = await cls._static_request_async( + "get", + cls.class_url(), + params=params, + ) + if not isinstance(result, ListObject): + raise TypeError( + "Expected list object from API, got %s" + % (type(result).__name__) + ) + + return result + + @classmethod + def modify( + cls, id: str, **params: Unpack["CreditGrant.ModifyParams"] + ) -> "CreditGrant": + """ + Updates a credit grant + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "CreditGrant", + cls._static_request( + "post", + url, + params=params, + ), + ) + + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["CreditGrant.ModifyParams"] + ) -> "CreditGrant": + """ + Updates a credit grant + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "CreditGrant", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + + @classmethod + def retrieve( + cls, id: str, **params: Unpack["CreditGrant.RetrieveParams"] + ) -> "CreditGrant": + """ + Retrieves a credit grant + """ + instance = cls(id, **params) + instance.refresh() + return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["CreditGrant.RetrieveParams"] + ) -> "CreditGrant": + """ + Retrieves a credit grant + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + + @classmethod + def _cls_void_grant( + cls, id: str, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + return cast( + "CreditGrant", + cls._static_request( + "post", + "/v1/billing/credit_grants/{id}/void".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + def void_grant( + id: str, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + ... + + @overload + def void_grant( + self, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + ... + + @class_method_variant("_cls_void_grant") + def void_grant( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + return cast( + "CreditGrant", + self._request( + "post", + "/v1/billing/credit_grants/{id}/void".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + async def _cls_void_grant_async( + cls, id: str, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + return cast( + "CreditGrant", + await cls._static_request_async( + "post", + "/v1/billing/credit_grants/{id}/void".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def void_grant_async( + id: str, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + ... + + @overload + async def void_grant_async( + self, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + ... + + @class_method_variant("_cls_void_grant_async") + async def void_grant_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditGrant.VoidGrantParams"] + ) -> "CreditGrant": + """ + Voids a credit grant + """ + return cast( + "CreditGrant", + await self._request_async( + "post", + "/v1/billing/credit_grants/{id}/void".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + _inner_class_types = { + "amount": Amount, + "applicability_config": ApplicabilityConfig, + } diff --git a/stripe/billing/_credit_grant_service.py b/stripe/billing/_credit_grant_service.py new file mode 100644 index 000000000..011a189fb --- /dev/null +++ b/stripe/billing/_credit_grant_service.py @@ -0,0 +1,381 @@ +# -*- coding: utf-8 -*- +# File generated from our OpenAPI spec +from stripe._list_object import ListObject +from stripe._request_options import RequestOptions +from stripe._stripe_service import StripeService +from stripe._util import sanitize_id +from stripe.billing._credit_grant import CreditGrant +from typing import Dict, List, cast +from typing_extensions import Literal, NotRequired, TypedDict + + +class CreditGrantService(StripeService): + class CreateParams(TypedDict): + amount: "CreditGrantService.CreateParamsAmount" + """ + Amount of this credit grant. + """ + applicability_config: ( + "CreditGrantService.CreateParamsApplicabilityConfig" + ) + """ + Configuration specifying what this credit grant applies to. + """ + category: Literal["paid", "promotional"] + """ + The category of this credit grant. + """ + customer: str + """ + Id of the customer to whom the credit should be granted. + """ + effective_at: NotRequired[int] + """ + The time when the credit becomes effective i.e when it is eligible to be used. Defaults to the current timestamp if not specified. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + expires_at: NotRequired[int] + """ + The time when the credit will expire. If not specified, the credit will never expire. + """ + metadata: NotRequired[Dict[str, str]] + """ + Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object (ex: cost basis) in a structured format. + """ + name: NotRequired[str] + """ + A descriptive name shown in dashboard and on invoices. + """ + + class CreateParamsAmount(TypedDict): + monetary: NotRequired["CreditGrantService.CreateParamsAmountMonetary"] + """ + The monetary amount. + """ + type: Literal["monetary"] + """ + Specify the type of this amount. We currently only support `monetary` credits. + """ + + class CreateParamsAmountMonetary(TypedDict): + currency: str + """ + Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) of the `value` parameter. + """ + value: int + """ + A positive integer representing the amount of the credit grant. + """ + + class CreateParamsApplicabilityConfig(TypedDict): + scope: "CreditGrantService.CreateParamsApplicabilityConfigScope" + """ + Specify the scope of this applicability config. + """ + + class CreateParamsApplicabilityConfigScope(TypedDict): + price_type: Literal["metered"] + """ + The price type to which credit grants can apply to. We currently only support `metered` price type. + """ + + class ExpireParams(TypedDict): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + class ListParams(TypedDict): + customer: NotRequired[str] + """ + Only return credit grants for this customer. + """ + ending_before: NotRequired[str] + """ + A cursor for use in pagination. `ending_before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + """ + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + limit: NotRequired[int] + """ + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + """ + starting_after: NotRequired[str] + """ + A cursor for use in pagination. `starting_after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + """ + + class RetrieveParams(TypedDict): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + class UpdateParams(TypedDict): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + expires_at: NotRequired["Literal['']|int"] + """ + The time when the credit created by this credit grant will expire. If set to empty, the credit will never expire. + """ + metadata: NotRequired[Dict[str, str]] + """ + Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object (ex: cost basis) in a structured format. + """ + + class VoidGrantParams(TypedDict): + expand: NotRequired[List[str]] + """ + Specifies which fields in the response should be expanded. + """ + + def list( + self, + params: "CreditGrantService.ListParams" = {}, + options: RequestOptions = {}, + ) -> ListObject[CreditGrant]: + """ + Retrieve a list of credit grants + """ + return cast( + ListObject[CreditGrant], + self._request( + "get", + "/v1/billing/credit_grants", + base_address="api", + params=params, + options=options, + ), + ) + + async def list_async( + self, + params: "CreditGrantService.ListParams" = {}, + options: RequestOptions = {}, + ) -> ListObject[CreditGrant]: + """ + Retrieve a list of credit grants + """ + return cast( + ListObject[CreditGrant], + await self._request_async( + "get", + "/v1/billing/credit_grants", + base_address="api", + params=params, + options=options, + ), + ) + + def create( + self, + params: "CreditGrantService.CreateParams", + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Creates a credit grant + """ + return cast( + CreditGrant, + self._request( + "post", + "/v1/billing/credit_grants", + base_address="api", + params=params, + options=options, + ), + ) + + async def create_async( + self, + params: "CreditGrantService.CreateParams", + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Creates a credit grant + """ + return cast( + CreditGrant, + await self._request_async( + "post", + "/v1/billing/credit_grants", + base_address="api", + params=params, + options=options, + ), + ) + + def retrieve( + self, + id: str, + params: "CreditGrantService.RetrieveParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Retrieves a credit grant + """ + return cast( + CreditGrant, + self._request( + "get", + "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) + + async def retrieve_async( + self, + id: str, + params: "CreditGrantService.RetrieveParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Retrieves a credit grant + """ + return cast( + CreditGrant, + await self._request_async( + "get", + "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) + + def update( + self, + id: str, + params: "CreditGrantService.UpdateParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Updates a credit grant + """ + return cast( + CreditGrant, + self._request( + "post", + "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) + + async def update_async( + self, + id: str, + params: "CreditGrantService.UpdateParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Updates a credit grant + """ + return cast( + CreditGrant, + await self._request_async( + "post", + "/v1/billing/credit_grants/{id}".format(id=sanitize_id(id)), + base_address="api", + params=params, + options=options, + ), + ) + + def expire( + self, + id: str, + params: "CreditGrantService.ExpireParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Expires a credit grant + """ + return cast( + CreditGrant, + self._request( + "post", + "/v1/billing/credit_grants/{id}/expire".format( + id=sanitize_id(id), + ), + base_address="api", + params=params, + options=options, + ), + ) + + async def expire_async( + self, + id: str, + params: "CreditGrantService.ExpireParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Expires a credit grant + """ + return cast( + CreditGrant, + await self._request_async( + "post", + "/v1/billing/credit_grants/{id}/expire".format( + id=sanitize_id(id), + ), + base_address="api", + params=params, + options=options, + ), + ) + + def void_grant( + self, + id: str, + params: "CreditGrantService.VoidGrantParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Voids a credit grant + """ + return cast( + CreditGrant, + self._request( + "post", + "/v1/billing/credit_grants/{id}/void".format( + id=sanitize_id(id), + ), + base_address="api", + params=params, + options=options, + ), + ) + + async def void_grant_async( + self, + id: str, + params: "CreditGrantService.VoidGrantParams" = {}, + options: RequestOptions = {}, + ) -> CreditGrant: + """ + Voids a credit grant + """ + return cast( + CreditGrant, + await self._request_async( + "post", + "/v1/billing/credit_grants/{id}/void".format( + id=sanitize_id(id), + ), + base_address="api", + params=params, + options=options, + ), + ) diff --git a/stripe/billing_portal/_configuration.py b/stripe/billing_portal/_configuration.py index 90bc5fbd2..41dd41f34 100644 --- a/stripe/billing_portal/_configuration.py +++ b/stripe/billing_portal/_configuration.py @@ -315,8 +315,8 @@ class CreateParamsFeaturesSubscriptionCancelCancellationReason(TypedDict): """ class CreateParamsFeaturesSubscriptionUpdate(TypedDict): - default_allowed_updates: Union[ - Literal[""], List[Literal["price", "promotion_code", "quantity"]] + default_allowed_updates: NotRequired[ + "Literal['']|List[Literal['price', 'promotion_code', 'quantity']]" ] """ The types of subscription updates that are supported. When empty, subscriptions are not updateable. @@ -325,11 +325,8 @@ class CreateParamsFeaturesSubscriptionUpdate(TypedDict): """ Whether the feature is enabled. """ - products: Union[ - Literal[""], - List[ - "Configuration.CreateParamsFeaturesSubscriptionUpdateProduct" - ], + products: NotRequired[ + "Literal['']|List[Configuration.CreateParamsFeaturesSubscriptionUpdateProduct]" ] """ The list of up to 10 products that support subscription updates. diff --git a/stripe/billing_portal/_configuration_service.py b/stripe/billing_portal/_configuration_service.py index 7cbc97444..9edf1db04 100644 --- a/stripe/billing_portal/_configuration_service.py +++ b/stripe/billing_portal/_configuration_service.py @@ -153,8 +153,8 @@ class CreateParamsFeaturesSubscriptionCancelCancellationReason(TypedDict): """ class CreateParamsFeaturesSubscriptionUpdate(TypedDict): - default_allowed_updates: Union[ - Literal[""], List[Literal["price", "promotion_code", "quantity"]] + default_allowed_updates: NotRequired[ + "Literal['']|List[Literal['price', 'promotion_code', 'quantity']]" ] """ The types of subscription updates that are supported. When empty, subscriptions are not updateable. @@ -163,11 +163,8 @@ class CreateParamsFeaturesSubscriptionUpdate(TypedDict): """ Whether the feature is enabled. """ - products: Union[ - Literal[""], - List[ - "ConfigurationService.CreateParamsFeaturesSubscriptionUpdateProduct" - ], + products: NotRequired[ + "Literal['']|List[ConfigurationService.CreateParamsFeaturesSubscriptionUpdateProduct]" ] """ The list of up to 10 products that support subscription updates. diff --git a/stripe/checkout/_session.py b/stripe/checkout/_session.py index e6f7ba017..66bbac645 100644 --- a/stripe/checkout/_session.py +++ b/stripe/checkout/_session.py @@ -2280,7 +2280,7 @@ class CreateParamsLineItem(TypedDict): class CreateParamsLineItemAdjustableQuantity(TypedDict): enabled: bool """ - Set to true if the quantity can be adjusted to any non-negative integer. By default customers will be able to remove the line item by setting the quantity to 0. + Set to true if the quantity can be adjusted to any non-negative integer. """ maximum: NotRequired[int] """ diff --git a/stripe/checkout/_session_service.py b/stripe/checkout/_session_service.py index e1010120d..82d78f1be 100644 --- a/stripe/checkout/_session_service.py +++ b/stripe/checkout/_session_service.py @@ -690,7 +690,7 @@ class CreateParamsLineItem(TypedDict): class CreateParamsLineItemAdjustableQuantity(TypedDict): enabled: bool """ - Set to true if the quantity can be adjusted to any non-negative integer. By default customers will be able to remove the line item by setting the quantity to 0. + Set to true if the quantity can be adjusted to any non-negative integer. """ maximum: NotRequired[int] """ diff --git a/stripe/tax/_settings.py b/stripe/tax/_settings.py index c8454342a..c8e64bdd4 100644 --- a/stripe/tax/_settings.py +++ b/stripe/tax/_settings.py @@ -155,7 +155,7 @@ class RetrieveParams(RequestOptions): """ status: Literal["active", "pending"] """ - The `active` status indicates you have all required settings to calculate tax. A status can transition out of `active` when new required settings are introduced. + The status of the Tax `Settings`. """ status_details: StatusDetails diff --git a/stripe/terminal/_reader.py b/stripe/terminal/_reader.py index 6d7553865..c8bcaf97a 100644 --- a/stripe/terminal/_reader.py +++ b/stripe/terminal/_reader.py @@ -376,6 +376,12 @@ class ProcessPaymentIntentParams(RequestOptions): """ class ProcessPaymentIntentParamsProcessConfig(TypedDict): + allow_redisplay: NotRequired[ + Literal["always", "limited", "unspecified"] + ] + """ + This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. + """ enable_customer_cancellation: NotRequired[bool] """ Enables cancel button on transaction screens. @@ -398,9 +404,9 @@ class ProcessPaymentIntentParamsProcessConfigTipping(TypedDict): """ class ProcessSetupIntentParams(RequestOptions): - customer_consent_collected: NotRequired[bool] + allow_redisplay: Literal["always", "limited", "unspecified"] """ - Customer Consent Collected + This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. """ expand: NotRequired[List[str]] """ diff --git a/stripe/terminal/_reader_service.py b/stripe/terminal/_reader_service.py index 362d89162..271a9701f 100644 --- a/stripe/terminal/_reader_service.py +++ b/stripe/terminal/_reader_service.py @@ -103,6 +103,12 @@ class ProcessPaymentIntentParams(TypedDict): """ class ProcessPaymentIntentParamsProcessConfig(TypedDict): + allow_redisplay: NotRequired[ + Literal["always", "limited", "unspecified"] + ] + """ + This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. + """ enable_customer_cancellation: NotRequired[bool] """ Enables cancel button on transaction screens. @@ -125,9 +131,9 @@ class ProcessPaymentIntentParamsProcessConfigTipping(TypedDict): """ class ProcessSetupIntentParams(TypedDict): - customer_consent_collected: NotRequired[bool] + allow_redisplay: Literal["always", "limited", "unspecified"] """ - Customer Consent Collected + This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. """ expand: NotRequired[List[str]] """ diff --git a/stripe/treasury/_received_credit.py b/stripe/treasury/_received_credit.py index 2e67c2832..702c42b91 100644 --- a/stripe/treasury/_received_credit.py +++ b/stripe/treasury/_received_credit.py @@ -317,7 +317,12 @@ class RetrieveParams(RequestOptions): An arbitrary string attached to the object. Often useful for displaying to users. """ failure_code: Optional[ - Literal["account_closed", "account_frozen", "other"] + Literal[ + "account_closed", + "account_frozen", + "international_transaction", + "other", + ] ] """ Reason for the failure. A ReceivedCredit might fail because the receiving FinancialAccount is closed or frozen. diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index 64b304971..826a79ff9 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -25845,92 +25845,6 @@ async def test_terminal_readers_process_payment_intent_post_service_async( post_data="payment_intent=pi_xxxxxxxxxxxxx", ) - def test_terminal_readers_process_setup_intent_post( - self, http_client_mock: HTTPClientMock - ) -> None: - stripe.terminal.Reader.process_setup_intent( - "tmr_xxxxxxxxxxxxx", - setup_intent="seti_xxxxxxxxxxxxx", - customer_consent_collected=True, - ) - http_client_mock.assert_requested( - "post", - path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent", - query_string="", - post_data="setup_intent=seti_xxxxxxxxxxxxx&customer_consent_collected=True", - ) - - def test_terminal_readers_process_setup_intent_post_service( - self, http_client_mock: HTTPClientMock - ) -> None: - http_client_mock.stub_request( - "post", - "/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent", - ) - client = StripeClient( - "sk_test_123", - http_client=http_client_mock.get_mock_http_client(), - ) - - client.terminal.readers.process_setup_intent( - "tmr_xxxxxxxxxxxxx", - { - "setup_intent": "seti_xxxxxxxxxxxxx", - "customer_consent_collected": True, - }, - ) - http_client_mock.assert_requested( - "post", - path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent", - query_string="", - api_base="https://api.stripe.com", - post_data="setup_intent=seti_xxxxxxxxxxxxx&customer_consent_collected=True", - ) - - @pytest.mark.anyio - async def test_terminal_readers_process_setup_intent_post_async( - self, http_client_mock: HTTPClientMock - ) -> None: - await stripe.terminal.Reader.process_setup_intent_async( - "tmr_xxxxxxxxxxxxx", - setup_intent="seti_xxxxxxxxxxxxx", - customer_consent_collected=True, - ) - http_client_mock.assert_requested( - "post", - path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent", - query_string="", - post_data="setup_intent=seti_xxxxxxxxxxxxx&customer_consent_collected=True", - ) - - @pytest.mark.anyio - async def test_terminal_readers_process_setup_intent_post_service_async( - self, http_client_mock: HTTPClientMock - ) -> None: - http_client_mock.stub_request( - "post", - "/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent", - ) - client = StripeClient( - "sk_test_123", - http_client=http_client_mock.get_mock_http_client(), - ) - - await client.terminal.readers.process_setup_intent_async( - "tmr_xxxxxxxxxxxxx", - { - "setup_intent": "seti_xxxxxxxxxxxxx", - "customer_consent_collected": True, - }, - ) - http_client_mock.assert_requested( - "post", - path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent", - query_string="", - api_base="https://api.stripe.com", - post_data="setup_intent=seti_xxxxxxxxxxxxx&customer_consent_collected=True", - ) - def test_test_helpers_customers_fund_cash_balance_post( self, http_client_mock: HTTPClientMock ) -> None: