Skip to content

Commit

Permalink
Merge pull request #1327 from stripe/latest-codegen-beta
Browse files Browse the repository at this point in the history
Update generated code for beta
  • Loading branch information
stripe-openapi[bot] committed May 16, 2024
2 parents 0bab95f + 1aebf6a commit 3fa3cc5
Show file tree
Hide file tree
Showing 35 changed files with 422 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ per-file-ignores =
*/__init__.py: IMP100, E402, F401
# we test various import patterns
tests/test_exports.py: IMP100, IMP101, IMP102
tests/*: IMP101, IMP102, BAN100
tests/*: IMP101, IMP102, BAN100, ASY100
# backcompat with outdated import patterns
stripe/api_resources/*: IMP100, E402, F401

Expand Down Expand Up @@ -40,4 +40,5 @@ extension =
SPY = flake8_stripe:TypingImportsChecker
IMP = flake8_stripe:StripeImportsChecker
BAN = flake8_stripe:BanPublicMethodsChecker
ASY = flake8_stripe:AsyncNamingConventions
paths=./flake8_stripe
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
* [#1321](https://github.com/stripe/stripe-python/pull/1321) Update generated code for beta
* No new beta features. Merging changes from the main branch.

## 9.6.0 - 2024-05-09
* [#1323](https://github.com/stripe/stripe-python/pull/1323) Update generated code
* Add support for `allow_redisplay` on resource class `stripe.ConfirmationToken.PaymentMethodPreview` and resource `stripe.PaymentMethod`
* Add support for `preview_mode` on parameter classes `stripe.Invoice.CreatePreviewParams`, `stripe.Invoice.UpcomingLinesParams`, and `stripe.Invoice.UpcomingParams`
* Add support for `_cls_update` on resources `stripe.treasury.OutboundPayment` and `stripe.treasury.OutboundTransfer`
* Add support for `tracking_details` on resources `stripe.treasury.OutboundPayment` and `stripe.treasury.OutboundTransfer`
* Add support for `update` on resources `stripe.treasury.OutboundPayment` and `stripe.treasury.OutboundTransfer`
* Add support for `treasury.outbound_payment.tracking_details_updated` on enums `stripe.Event.type`, `stripe.WebhookEndpoint.CreateParams.enabled_events`, and `stripe.WebhookEndpoint.ModifyParams.enabled_events`
* Add support for `treasury.outbound_transfer.tracking_details_updated` on enums `stripe.Event.type`, `stripe.WebhookEndpoint.CreateParams.enabled_events`, and `stripe.WebhookEndpoint.ModifyParams.enabled_events`

## 9.6.0b1 - 2024-05-02
* [#1318](https://github.com/stripe/stripe-python/pull/1318) Update generated code for beta
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1020
v1039
27 changes: 27 additions & 0 deletions flake8_stripe/flake8_stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,30 @@ def run(self) -> Iterator[Tuple[int, int, str, type]]:
msg,
type(self),
)


class AsyncNamingConventions:
name = __name__
version = "0.1.0"

def __init__(self, tree: ast.AST, filename: str):
self.tree = tree
self.filename = filename

def run(self) -> Iterator[Tuple[int, int, str, type]]:
for node in ast.walk(self.tree):
# ignore anything that isn't an async function declaration
if not isinstance(node, ast.AsyncFunctionDef):
continue

# dunders need specific names, so don't worry about them
if node.name.startswith("__") and node.name.endswith("__"):
continue

if not node.name.endswith("_async"):
yield (
node.lineno,
node.col_offset,
"ASY100 Async methods must be named X_async",
type(self),
)
8 changes: 7 additions & 1 deletion stripe/_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class Capabilities(StripeObject):
"""
twint_payments: Optional[Literal["active", "inactive", "pending"]]
"""
The status of the Twint capability of the account, or whether the account can directly process Twint charges.
The status of the TWINT capability of the account, or whether the account can directly process TWINT charges.
"""
us_bank_account_ach_payments: Optional[
Literal["active", "inactive", "pending"]
Expand Down Expand Up @@ -946,9 +946,15 @@ class Error(StripeObject):
class RiskControls(StripeObject):
class Charges(StripeObject):
pause_requested: bool
"""
Whether a pause of the risk control has been requested.
"""

class Payouts(StripeObject):
pause_requested: bool
"""
Whether a pause of the risk control has been requested.
"""

charges: Charges
payouts: Payouts
Expand Down
21 changes: 21 additions & 0 deletions stripe/_application_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from stripe._listable_api_resource import ListableAPIResource
from stripe._nested_resource_class_methods import nested_resource_class_methods
from stripe._request_options import RequestOptions
from stripe._stripe_object import StripeObject
from stripe._util import class_method_variant, sanitize_id
from typing import ClassVar, Dict, List, Optional, cast, overload
from typing_extensions import (
Expand All @@ -27,6 +28,20 @@
class ApplicationFee(ListableAPIResource["ApplicationFee"]):
OBJECT_NAME: ClassVar[Literal["application_fee"]] = "application_fee"

class FeeSource(StripeObject):
charge: Optional[str]
"""
Charge ID that created this application fee.
"""
payout: Optional[str]
"""
Payout ID that created this application fee.
"""
type: Literal["charge", "payout"]
"""
Type of object that created the application fee, either `charge` or `payout`.
"""

class CreateRefundParams(RequestOptions):
amount: NotRequired[int]
"""
Expand Down Expand Up @@ -171,6 +186,10 @@ class RetrieveRefundParams(RequestOptions):
"""
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).
"""
fee_source: Optional[FeeSource]
"""
Polymorphic source of the application fee. Includes the ID of the object the application fee was created from.
"""
id: str
"""
Unique identifier for the object.
Expand Down Expand Up @@ -595,3 +614,5 @@ async def list_refunds_async(
params=params,
),
)

_inner_class_types = {"fee_source": FeeSource}
35 changes: 34 additions & 1 deletion stripe/_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ class SourceTypes(StripeObject):
_inner_class_types = {"source_types": SourceTypes}

class InstantAvailable(StripeObject):
class NetAvailable(StripeObject):
class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Amount for bank account.
"""
card: Optional[int]
"""
Amount for card.
"""
fpx: Optional[int]
"""
Amount for FPX.
"""

amount: int
"""
Net balance amount, subtracting fees from platform-set pricing.
"""
destination: str
"""
ID of the external account for this net balance (not expandable).
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}

class SourceTypes(StripeObject):
bank_account: Optional[int]
"""
Expand All @@ -99,8 +125,15 @@ class SourceTypes(StripeObject):
"""
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).
"""
net_available: Optional[List[NetAvailable]]
"""
Breakdown of balance by destination.
"""
source_types: Optional[SourceTypes]
_inner_class_types = {"source_types": SourceTypes}
_inner_class_types = {
"net_available": NetAvailable,
"source_types": SourceTypes,
}

class Issuing(StripeObject):
class Available(StripeObject):
Expand Down
4 changes: 4 additions & 0 deletions stripe/_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,10 @@ class Receipt(StripeObject):
"""
Defines whether the authorized amount can be over-captured or not
"""
preferred_locales: Optional[List[str]]
"""
EMV tag 5F2D. Preferred languages specified by the integrated circuit chip.
"""
read_method: Optional[
Literal[
"contact_emv",
Expand Down
4 changes: 4 additions & 0 deletions stripe/_confirmation_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,10 @@ class Networks(StripeObject):
"""
Contains information about card networks that can be used to process the payment.
"""
preferred_locales: Optional[List[str]]
"""
EMV tag 5F2D. Preferred languages specified by the integrated circuit chip.
"""
read_method: Optional[
Literal[
"contact_emv",
Expand Down
12 changes: 10 additions & 2 deletions stripe/_customer_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ class PaymentElement(StripeObject):
class Features(StripeObject):
payment_method_remove: Literal["disabled", "enabled"]
"""
Controls whether the Payment Element displays the option to remove a saved payment method.
Controls whether the Payment Element displays the option to remove a saved payment method."
Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method. Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
"""
payment_method_save: Literal["disabled", "enabled"]
"""
Controls whether the Payment Element displays a checkbox offering to save a new payment method.
If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time. For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
"""
payment_method_set_as_default: Literal["disabled", "enabled"]
"""
Expand Down Expand Up @@ -140,11 +144,15 @@ class CreateParamsComponentsPaymentElement(TypedDict):
class CreateParamsComponentsPaymentElementFeatures(TypedDict):
payment_method_remove: NotRequired[Literal["disabled", "enabled"]]
"""
Controls whether the Payment Element displays the option to remove a saved payment method.
Controls whether the Payment Element displays the option to remove a saved payment method."
Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method. Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
"""
payment_method_save: NotRequired[Literal["disabled", "enabled"]]
"""
Controls whether the Payment Element displays a checkbox offering to save a new payment method.
If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time. For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
"""
payment_method_set_as_default: NotRequired[
Literal["disabled", "enabled"]
Expand Down
6 changes: 5 additions & 1 deletion stripe/_customer_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ class CreateParamsComponentsPaymentElement(TypedDict):
class CreateParamsComponentsPaymentElementFeatures(TypedDict):
payment_method_remove: NotRequired[Literal["disabled", "enabled"]]
"""
Controls whether the Payment Element displays the option to remove a saved payment method.
Controls whether the Payment Element displays the option to remove a saved payment method."
Allowing buyers to remove their saved payment methods impacts subscriptions that depend on that payment method. Removing the payment method detaches the [`customer` object](https://docs.stripe.com/api/payment_methods/object#payment_method_object-customer) from that [PaymentMethod](https://docs.stripe.com/api/payment_methods).
"""
payment_method_save: NotRequired[Literal["disabled", "enabled"]]
"""
Controls whether the Payment Element displays a checkbox offering to save a new payment method.
If a customer checks the box, the [`allow_redisplay`](https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay) value on the PaymentMethod is set to `'always'` at confirmation time. For PaymentIntents, the [`setup_future_usage`](https://docs.stripe.com/api/payment_intents/object#payment_intent_object-setup_future_usage) value is also set to the value defined in `payment_method_save_usage`.
"""
payment_method_set_as_default: NotRequired[
Literal["disabled", "enabled"]
Expand Down
11 changes: 9 additions & 2 deletions stripe/_dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,12 @@ class Card(StripeObject):
The card network's specific dispute reason code, which maps to one of Stripe's primary dispute categories to simplify response guidance. The [Network code map](https://stripe.com/docs/disputes/categories#network-code-map) lists all available dispute reason codes by network.
"""

class Klarna(StripeObject):
reason_code: Optional[str]
"""
The reason for the dispute as defined by Klarna
"""

class Paypal(StripeObject):
case_id: Optional[str]
"""
Expand All @@ -374,12 +380,13 @@ class Paypal(StripeObject):
"""

card: Optional[Card]
klarna: Optional[Klarna]
paypal: Optional[Paypal]
type: Literal["card", "paypal"]
type: Literal["card", "klarna", "paypal"]
"""
Payment method type.
"""
_inner_class_types = {"card": Card, "paypal": Paypal}
_inner_class_types = {"card": Card, "klarna": Klarna, "paypal": Paypal}

class CloseParams(RequestOptions):
expand: NotRequired[List[str]]
Expand Down
2 changes: 1 addition & 1 deletion stripe/_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9081,7 +9081,7 @@ class VoidInvoiceParams(RequestOptions):
"""
attempt_count: int
"""
Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule. If a failure is returned with a non-retryable return code, the invoice can no longer be retried unless a new payment method is obtained. Retries will continue to be scheduled, and attempt_count will continue to increment, but retries will only be executed if a new payment method is obtained.
"""
attempted: bool
"""
Expand Down
46 changes: 46 additions & 0 deletions stripe/_payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,14 @@ class Address(StripeObject):
}

class CardPresent(StripeObject):
class Routing(StripeObject):
requested_priority: Optional[
Literal["domestic", "international"]
]
"""
Requested routing priority
"""

request_extended_authorization: Optional[bool]
"""
Request ability to capture this payment beyond the standard [authorization validity window](https://stripe.com/docs/terminal/features/extended-authorizations#authorization-validity)
Expand All @@ -1663,6 +1671,8 @@ class CardPresent(StripeObject):
"""
Request ability to [increment](https://stripe.com/docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible. Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support.
"""
routing: Optional[Routing]
_inner_class_types = {"routing": Routing}

class Cashapp(StripeObject):
capture_method: Optional[Literal["manual"]]
Expand Down Expand Up @@ -5216,6 +5226,18 @@ class ConfirmParamsPaymentMethodOptionsCardPresent(TypedDict):
"""
Request ability to [increment](https://stripe.com/docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible. Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support.
"""
routing: NotRequired[
"PaymentIntent.ConfirmParamsPaymentMethodOptionsCardPresentRouting"
]
"""
Network routing priority on co-branded EMV cards supporting domestic debit and international card schemes.
"""

class ConfirmParamsPaymentMethodOptionsCardPresentRouting(TypedDict):
requested_priority: NotRequired[Literal["domestic", "international"]]
"""
Routing requested priority
"""

class ConfirmParamsPaymentMethodOptionsCardStatementDetails(TypedDict):
address: NotRequired[
Expand Down Expand Up @@ -8318,6 +8340,18 @@ class CreateParamsPaymentMethodOptionsCardPresent(TypedDict):
"""
Request ability to [increment](https://stripe.com/docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible. Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support.
"""
routing: NotRequired[
"PaymentIntent.CreateParamsPaymentMethodOptionsCardPresentRouting"
]
"""
Network routing priority on co-branded EMV cards supporting domestic debit and international card schemes.
"""

class CreateParamsPaymentMethodOptionsCardPresentRouting(TypedDict):
requested_priority: NotRequired[Literal["domestic", "international"]]
"""
Routing requested priority
"""

class CreateParamsPaymentMethodOptionsCardStatementDetails(TypedDict):
address: NotRequired[
Expand Down Expand Up @@ -11477,6 +11511,18 @@ class ModifyParamsPaymentMethodOptionsCardPresent(TypedDict):
"""
Request ability to [increment](https://stripe.com/docs/terminal/features/incremental-authorizations) this PaymentIntent if the combination of MCC and card brand is eligible. Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support.
"""
routing: NotRequired[
"PaymentIntent.ModifyParamsPaymentMethodOptionsCardPresentRouting"
]
"""
Network routing priority on co-branded EMV cards supporting domestic debit and international card schemes.
"""

class ModifyParamsPaymentMethodOptionsCardPresentRouting(TypedDict):
requested_priority: NotRequired[Literal["domestic", "international"]]
"""
Routing requested priority
"""

class ModifyParamsPaymentMethodOptionsCardStatementDetails(TypedDict):
address: NotRequired[
Expand Down

0 comments on commit 3fa3cc5

Please sign in to comment.