8000 Merge python-beta by jar-stripe · Pull Request #1467 · stripe/stripe-python · GitHub
[go: up one dir, main page]

Skip to content

Merge python-beta #1467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# All files should be reviewed by a member of the SDKs team
* @stripe/api-library-reviewers
52 changes: 51 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Changelog

## 11.6.0 - 2025-02-24
* [#1450](https://github.com/stripe/stripe-python/pull/1450) Update generated code
* Add support for `target_date` on parameter classes `stripe.PaymentIntent.ConfirmParamsPaymentMethodOptionsAcssDebit`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodOptionsAuBecsDebit`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodOptionsBacsDebit`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodOptionsSepaDebit`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodOptionsUsBankAccount`, `stripe.PaymentIntent.CreateParamsPaymentMethodOptionsAcssDebit`, `stripe.PaymentIntent.CreateParamsPaymentMethodOptionsAuBecsDebit`, `stripe.PaymentIntent.CreateParamsPaymentMethodOptionsBacsDebit`, `stripe.PaymentIntent.CreateParamsPaymentMethodOptionsSepaDebit`, `stripe.PaymentIntent.CreateParamsPaymentMethodOptionsUsBankAccount`, `stripe.PaymentIntent.ModifyParamsPaymentMethodOptionsAcssDebit`, `stripe.PaymentIntent.ModifyParamsPaymentMethodOptionsAuBecsDebit`, `stripe.PaymentIntent.ModifyParamsPaymentMethodOptionsBacsDebit`, `stripe.PaymentIntent.ModifyParamsPaymentMethodOptionsSepaDebit`, `stripe.PaymentIntent.ModifyParamsPaymentMethodOptionsUsBankAccount`, `stripe.checkout.Session.CreateParamsPaymentMethodOptionsAcssDebit`, `stripe.checkout.Session.CreateParamsPaymentMethodOptionsAuBecsDebit`, `stripe.checkout.Session.CreateParamsPaymentMethodOptionsBacsDebit`, `stripe.checkout.Session.CreateParamsPaymentMethodOptionsSepaDebit`, and `stripe.checkout.Session.CreateParamsPaymentMethodOptionsUsBankAccount` and resource classes `stripe.PaymentIntent.PaymentMethodOptions.AcssDebit`, `stripe.PaymentIntent.PaymentMethodOptions.AuBecsDebit`, `stripe.PaymentIntent.PaymentMethodOptions.BacsDebit`, `stripe.PaymentIntent.PaymentMethodOptions.SepaDebit`, `stripe.PaymentIntent.PaymentMethodOptions.UsBankAccount`, `stripe.checkout.Session.PaymentMethodOptions.AcssDebit`, `stripe.checkout.Session.PaymentMethodOptions.AuBecsDebit`, `stripe.checkout.Session.PaymentMethodOptions.BacsDebit`, `stripe.checkout.Session.PaymentMethodOptions.SepaDebit`, and `stripe.checkout.Session.PaymentMethodOptions.UsBankAccount`
* Add support for `metadata` on parameter class `stripe.Product.CreateParamsDefaultPriceData`
* Add support for `prices` on parameter classes `stripe.billing.CreditBalanceSummary.RetrieveParamsFilterApplicabilityScope` and `stripe.billing.CreditGrant.CreateParamsApplicabilityConfigScope` and resource class `stripe.billing.CreditGrant.ApplicabilityConfig.Scope`
* Add support for `priority` on parameter class `stripe.billing.CreditGrant.CreateParams` and resource `stripe.billing.CreditGrant`
* Add support for `restrictions` on parameter class `stripe.checkout.Session.CreateParamsPaymentMethodOptionsCard` and resource class `stripe.checkout.Session.PaymentMethodOptions.Card`
* Add support for `collected_information` on parameter class `stripe.checkout.Session.ModifyParams` and resource `stripe.checkout.Session`
* Change type of `price_type` on `stripe.billing.CreditBalanceSummary.RetrieveParamsFilterApplicabilityScope` and `stripe.billing.CreditGrant.CreateParamsApplicabilityConfigScope` from `Literal['metered']` to `NotRequired[Literal['metered']]`
* Change type of `price_type` on `stripe.billing.CreditGrant.ApplicabilityConfig.Scope` from `Literal['metered']` to `Optional[Literal['metered']]`
* Add support for `2025-02-24.acacia` on enum `stripe.WebhookEndpoint.CreateParams.api_version`
* [#1461](https://github.com/stripe/stripe-python/pull/1461) Remove incorrect changelog entry about parse_snapshot_event
* [#1457](https://github.com/stripe/stripe-python/pull/1457) add codeowners file
* [#1456](https://github.com/stripe/stripe-python/pull/1456) upgrade ruff version
* [#1452](https://github.com/stripe/stripe-python/pull/1452) Revert "Bump version to 11.5.0"
* [#1451](https://github.com/stripe/stripe-python/pull/1451) Upgrade to download-artifact@v4
* [#1443](https://github.com/stripe/stripe-python/pull/1443) Update generated code
* Add support for `pay_by_bank_payments` on resource class `stripe.Account.Capabilities` and parameter class `stripe.Account.CreateParamsCapabilities`
* Add support for `directorship_declaration` on resource class `stripe.Account.Company` and parameter classes `stripe.Account.CreateParamsCompany` and `stripe.Token.CreateParamsAccountCompany`
* Add support for `ownership_exemption_reason` on resource class `stripe.Account.Company` and parameter classes `stripe.Account.CreateParamsCompany` and `stripe.Token.CreateParamsAccountCompany`
* Add support for `proof_of_ultimate_beneficial_ownership` on parameter class `stripe.Account.CreateParamsDocuments`
* Add support for `financial_account` on resource classes `stripe.AccountSession.Components` and `stripe.treasury.OutboundTransfer.DestinationPaymentMethodDetails` and parameter class `stripe.AccountSession.CreateParamsComponents`
* Add support for `issuing_card` on resource class `stripe.AccountSession.Components` and parameter class `stripe.AccountSession.CreateParamsComponents`
* Add support for `advice_code` on resource classes `stripe.Charge.Outcome`, `stripe.Invoice.LastFinalizationError`, `stripe.PaymentIntent.LastPaymentError`, `stripe.SetupAttempt.SetupError`, and `stripe.SetupIntent.LastSetupError`
* Add support for `country` on resource classes `stripe.Charge.PaymentMethodDetails.Paypal`, `stripe.ConfirmationToken.PaymentMethodPreview.Paypal`, and `stripe.PaymentMethod.Paypal`
* Add support for `pay_by_bank` on resource classes `stripe.Charge.PaymentMethodDetails`, `stripe.ConfirmationToken.PaymentMethodPreview`, and `stripe.PaymentIntent.PaymentMethodOptions`, parameter classes `stripe.ConfirmationToken.CreateParamsPaymentMethodData`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodData`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodOptions`, `stripe.PaymentIntent.CreateParamsPaymentMethodData`, `stripe.PaymentIntent.CreateParamsPaymentMethodOptions`, `stripe.PaymentIntent.ModifyParamsPaymentMethodData`, `stripe.PaymentIntent.ModifyParamsPaymentMethodOptions`, `stripe.PaymentMethod.CreateParams`, `stripe.PaymentMethod.ModifyParams`, `stripe.PaymentMethodConfiguration.CreateParams`, `stripe.PaymentMethodConfiguration.ModifyParams`, `stripe.SetupIntent.ConfirmParamsPaymentMethodData`, `stripe.SetupIntent.CreateParamsPaymentMethodData`, `stripe.SetupIntent.ModifyParamsPaymentMethodData`, and `stripe.checkout.Session.CreateParamsPaymentMethodOptions`, and resources `stripe.PaymentMethod` and `stripe.PaymentMethodConfiguration`
* Add support for `phone_number_collection` on parameter class `stripe.PaymentLink.ModifyParams`
* Add support for `discounts` on resource `stripe.checkout.Session`
* Add support for `jpy` on parameter classes `stripe.terminal.Configuration.CreateParamsTipping` and `stripe.terminal.Configuration.ModifyParamsTipping` and resource class `stripe.terminal.Configuration.Tipping`
* Add support for `nickname` on parameter classes `stripe.treasury.FinancialAccount.CreateParams` and `stripe.treasury.FinancialAccount.ModifyParams` and resource `stripe.treasury.FinancialAccount`
* Add support for `forwarding_settings` on parameter class `stripe.treasury.FinancialAccount.ModifyParams`
* Add support for `_cls_close` on resource `stripe.treasury.FinancialAccount`
* Add support for `close` on resource `stripe.treasury.FinancialAccount`
* Add support for `is_default` on resource `stripe.treasury.FinancialAccount`
* Add support for `destination_payment_method_data` on parameter class `stripe.treasury.OutboundTransfer.CreateParams`
* Add support for `outbound_transfer` on resource class `stripe.treasury.ReceivedCredit.LinkedFlows.SourceFlowDetails`
* Add support for `SD` on enums `stripe.checkout.Session.ShippingAddressCollection.allowed_countries`, `stripe.checkout.Session.CreateParamsShippingAddressCollection.allowed_countries`, `stripe.PaymentLink.ShippingAddressCollection.allowed_countries`, `stripe.PaymentLink.CreateParamsShippingAddressCollection.allowed_countries`, and `stripe.PaymentLink.ModifyParamsShippingAddressCollection.allowed_countries`
* Add support for `pay_by_bank` on enums `stripe.checkout.Session.CreateParams.payment_method_types`, `stripe.ConfirmationToken.PaymentMethodPreview.type`, `stripe.ConfirmationToken.CreateParamsPaymentMethodData.type`, `stripe.Customer.ListPaymentMethodsParams.type`, `stripe.PaymentIntent.ConfirmParamsPaymentMethodData.type`, `stripe.PaymentIntent.CreateParamsPaymentMethodData.type`, `stripe.PaymentIntent.ModifyParamsPaymentMethodData.type`, `stripe.PaymentLink.payment_method_types`, `stripe.PaymentLink.CreateParams.payment_method_types`, `stripe.PaymentLink.ModifyParams.payment_method_types`, `stripe.PaymentMethod.type`, `stripe.PaymentMethod.CreateParams.type`, `stripe.PaymentMethod.ListParams.type`, `stripe.SetupIntent.ConfirmParamsPaymentMethodData.type`, `stripe.SetupIntent.CreateParamsPaymentMethodData.type`, and `stripe.SetupIntent.ModifyParamsPaymentMethodData.type`
* Add support for `financial_account` on enum `stripe.treasury.OutboundTransfer.DestinationPaymentMethodDetails.type`
* Add support for `outb 10000 ound_transfer` on enums `stripe.treasury.ReceivedCredit.LinkedFlows.SourceFlowDetails.type` and `stripe.treasury.ReceivedCredit.ListParamsLinkedFlows.source_flow_type`
* Add support for `2025-01-27.acacia` on enum `stripe.WebhookEndpoint.CreateParams.api_version`
* Change type of `pretax_credit_amounts` on `stripe.CreditNote` and `stripe.CreditNoteLineItem` from `Optional[List[PretaxCreditAmount]]` to `List[PretaxCreditAmount]`
* [#1448](https://github.com/stripe/stripe-python/pull/1448) Updated upload artifact ci action
* [#1446](https://github.com/stripe/stripe-python/pull/1446) add just to publish CI
* [#1444](https://github.com/stripe/stripe-python/pull/1444) Added CONTRIBUTING.md file
* [#1445](https://github.com/stripe/stripe-python/pull/1445) minor justfile fixes & pin CI version
* [#1440](https://github.com/stripe/stripe-python/pull/1440) add justfile, update readme, remove coveralls
* [#1442](https://github.com/stripe/stripe-python/pull/1442) Fix V2 ListObject.data type hint
- Change `stripe.v2.ListObject.data` type hint from `List[StripeObject]` to `List[T]` where T is the specific stripe object contained within the list

## 11.6.0b1 - 2025-02-07
* [#1449](https://github.com/stripe/stripe-python/pull/1449) Update generated code for beta
* Add support for `rejected_reason` on resource class `stripe.Account.RiskControls`
Expand Down Expand Up @@ -442,7 +492,6 @@
* Adjusted default values for HTTP requests. You can use the old defaults by setting them explicitly. New values are:
- max retries: `0` -> `2`
- max timeout (seconds): `2` -> `5`
* Add method `parse_thin_event()` on the `StripeClient` class to parse [thin events](https://docs.corp.stripe.com/event-destinations#events-overview). Rename `construct_event()` method on the same class to `parse_snapshot_event()` to clearly distinguish between the two kinds of events.

### Additions

Expand All @@ -453,6 +502,7 @@
* Add support for `2024-09-30.acacia` on enum `stripe.WebhookEndpoint.CreateParams.api_version`
* Add support for new Usage Billing APIs `stripe.v2.billing.MeterEvent`, `stripe.v2.billing.MeterEventAdjustments`, `stripe.v2.billing.MeterEventSession`, `stripe.v2.billing.MeterEventStream` and the new Events API `stripe.v2.core.Events` under the [v2 namespace ](https://docs.corp.stripe.com/api-v2-overview)
* Add method [rawRequest()](https://github.com/stripe/stripe-python/tree/master?tab=readme-ov-file#custom-requests) on the `StripeClient` class that takes a HTTP method type, url and relevant parameters to make requests to the Stripe API that are not yet supported in the SDK.
* Add method `parse_thin_event()` on the `StripeClient` class to parse [thin events](https://docs.corp.stripe.com/event-destinations#events-overview)

### Other changes
* Change type of `default_allowed_updates` on `stripe.billing_portal.Configuration.CreateParamsFeaturesSubscriptionUpdate` from `Union[Literal[''], List[Literal['price', 'promotion_code', 'quantity']]]` to `NotRequired[Literal['']|List[Literal['price', 'promotion_code', 'quantity']]]`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1472
v1472
5 changes: 4 additions & 1 deletion deps/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# version requirements: any modern python version (currently 3.10)

# typechecking for all versions
# can't use `>=1.1.339` since it flags override issues, e.g.:
# > Method "_cls_delete" overrides class "DeletableAPIResource" in an incompatible manner Parameter "**params" has no corresponding parameter Pylance(reportIncompatibleMethodOverride)
# can probably fix/ignore these issues and move forward, but we're stuck until then
pyright == 1.1.336
# general typechecking
mypy == 1.7.0
# formatting
ruff == 0.4.4
ruff == 0.9.6
# linting
flake8
4 changes: 2 additions & 2 deletions stripe/_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -3563,7 +3563,7 @@ class CreatePersonParams(RequestOptions):
"""
The person's phone number.
"""
political_exposure: NotRequired[Literal["existing", "none"]]
political_exposure: NotRequired[str]
"""
Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
"""
Expand Down Expand Up @@ -4152,7 +4152,7 @@ class ModifyPersonParams(RequestOptions):
"""
The person's phone number.
"""
political_exposure: NotRequired[Literal["existing", "none"]]
political_exposure: NotRequired[str]
"""
Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
"""
Expand Down
4 changes: 2 additions & 2 deletions stripe/_account_person_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class CreateParams(TypedDict):
"""
The person's phone number.
"""
political_exposure: NotRequired[Literal["existing", "none"]]
political_exposure: NotRequired[str]
"""
Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
"""
Expand Down Expand Up @@ -546,7 +546,7 @@ class UpdateParams(TypedDict):
"""
The person's phone number.
"""
political_exposure: NotRequired[Literal["existing", "none"]]
political_exposure: NotRequired[str]
"""
Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
"""
Expand Down
3 changes: 1 addition & 2 deletions stripe/_ephemeral_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ async def delete_async( # pyright: ignore[reportGeneralTypeIssues]
def create(cls, **params):
if params.get("stripe_version") is None:
raise ValueError(
"stripe_version must be specified to create an ephemeral "
"key"
"stripe_version must be specified to create an ephemeral key"
)

url = cls.class_url()
Expand Down
2 changes: 1 addition & 1 deletion stripe/_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ class CreateParamsPerson(TypedDict):
"""
The person's phone number.
"""
political_exposure: NotRequired[Literal["existing", "none"]]
political_exposure: NotRequired[str]
"""
Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
"""
Expand Down
2 changes: 1 addition & 1 deletion stripe/_token_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ class CreateParamsPerson(TypedDict):
"""
The person's phone number.
"""
political_exposure: NotRequired[Literal["existing", "none"]]
political_exposure: NotRequired[str]
"""
Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
"""
Expand Down
4 changes: 4 additions & 0 deletions stripe/v2/_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

# The beginning of the section generated from our OpenAPI spec
class Event(StripeObject):
"""
Events are generated to keep you informed of activity in your business account. APIs in the /v2 namespace generate [thin events](https://docs.stripe.com/event-destinations#benefits-of-thin-events) which have small, unversioned payloads that include a reference to the ID of the object that has changed. The Events v2 API returns these new thin events. [Retrieve the event object](https://docs.stripe.com/event-destinations#fetch-data) for additional data about the event. Use the related object ID in the event payload to [fetch the API resource](https://docs.stripe.com/event-destinations#retrieve-the-object-associated-with-thin-events) of the object associated with the event. Comparatively, events generated by most API v1 include a versioned snapshot of an API object in their payload.
"""

OBJECT_NAME: ClassVar[Literal["v2.core.event"]] = "v2.core.event"

class Reason(StripeObject):
Expand Down
4 changes: 4 additions & 0 deletions stripe/v2/_event_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@


class EventDestination(StripeObject):
"""
Set up an event destination to receive events from Stripe across multiple destination types, including [webhook endpoints](https://docs.stripe.com/webhooks) and [Amazon EventBridge](https://docs.stripe.com/event-destinations/eventbridge). Event destinations support receiving [thin events](https://docs.stripe.com/api/v2/events) and [snapshot events](https://docs.stripe.com/api/events).
"""

OBJECT_NAME: ClassVar[Literal["v2.core.event_destination"]] = (
"v2.core.event_destination"
)
Expand Down
30 changes: 27 additions & 3 deletions stripe/v2/core/_event_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,31 @@

class EventService(StripeService):
class ListParams(TypedDict):
created_gt: NotRequired[str]
"""
Filter for events created after the specified timestamp.
"""
created_gte: NotRequired[str]
"""
Filter for events created at or after the specified timestamp.
"""
created_lt: NotRequired[str]
"""
Filter for events created before the specified timestamp.
"""
created_lte: NotRequired[str]
"""
Filter for events created at or before the specified timestamp.
"""
delivery_success: NotRequired[bool]
"""
Filter events based on whether they were successfully delivered to all subscribed event destinations. If false, events which are still pending or have failed all delivery attempts to a event destination will be returned.
"""
limit: NotRequired[int]
"""
The page size.
"""
object_id: str
object_id: NotRequired[str]
"""
Primary object ID used to retrieve related events.
"""
Expand All @@ -28,7 +48,9 @@ class RetrieveParams(TypedDict):
pass

def list(
self, params: "EventService.ListParams", options: RequestOptions = {}
self,
params: "EventService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[Event]:
"""
List events, going back up to 30 days.
Expand All @@ -45,7 +67,9 @@ def list(
)

async def list_async(
self, params: "EventService.ListParams", options: RequestOptions = {}
self,
params: "EventService.ListParams" = {},
options: RequestOptions = {},
) -> ListObject[Event]:
"""
List events, going back up to 30 days.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ async def test_httpx_request_async_https(self):

client = _http_client.HTTPXClient(verify_ssl_certs=True)
# the public test secret key, as found on https://docs.stripe.com/keys#obtain-api-keys
test_api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
test_api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
basic_auth = base64.b64encode(
(test_api_key + ":").encode("utf-8")
).decode("utf-8")
Expand Down
Loading
0