diff --git a/stripe/_account.py b/stripe/_account.py index 8acb8e25b..fd05cab50 100644 --- a/stripe/_account.py +++ b/stripe/_account.py @@ -3789,6 +3789,27 @@ def create(cls, **params: Unpack["Account.CreateParams"]) -> "Account": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Account.CreateParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users. + To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings). + + If you've already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when + creating the account. Connect Onboarding won't ask for the prefilled information during account onboarding. + You can prefill any information on the account. + """ + return cast( + "Account", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Account.DeleteParams"] @@ -3852,6 +3873,71 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Account.DeleteParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. + + Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + + If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Account", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Account.DeleteParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. + + Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + + If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Account.DeleteParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. + + Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + + If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.DeleteParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. + + Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + + If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["Account.ListParams"] @@ -3873,6 +3959,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Account.ListParams"] + ) -> ListObject["Account"]: + """ + Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). If you're not a platform, the list is empty. + """ + 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 _cls_persons( cls, account: str, **params: Unpack["Account.PersonsParams"] @@ -3928,6 +4035,61 @@ def persons( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_persons_async( + cls, account: str, **params: Unpack["Account.PersonsParams"] + ) -> ListObject["Person"]: + """ + Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first. + """ + return cast( + ListObject["Person"], + await cls._static_request_async( + "get", + "/v1/accounts/{account}/persons".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def persons_async( + account: str, **params: Unpack["Account.PersonsParams"] + ) -> ListObject["Person"]: + """ + Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first. + """ + ... + + @overload + async def persons_async( + self, **params: Unpack["Account.PersonsParams"] + ) -> ListObject["Person"]: + """ + Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first. + """ + ... + + @class_method_variant("_cls_persons_async") + async def persons_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.PersonsParams"] + ) -> ListObject["Person"]: + """ + Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first. + """ + return cast( + ListObject["Person"], + await self._request_async( + "get", + "/v1/accounts/{account}/persons".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_reject( cls, account: str, **params: Unpack["Account.RejectParams"] @@ -3989,8 +4151,68 @@ def reject( # pyright: ignore[reportGeneralTypeIssues] ), ) - # We are not adding a helper for capabilities here as the Account object already has a - # capabilities property which is a hash and not the sub-list of capabilities. + @classmethod + async def _cls_reject_async( + cls, account: str, **params: Unpack["Account.RejectParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. + + Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. + """ + return cast( + "Account", + await cls._static_request_async( + "post", + "/v1/accounts/{account}/reject".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def reject_async( + account: str, **params: Unpack["Account.RejectParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. + + Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. + """ + ... + + @overload + async def reject_async( + self, **params: Unpack["Account.RejectParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. + + Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. + """ + ... + + @class_method_variant("_cls_reject_async") + async def reject_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.RejectParams"] + ) -> "Account": + """ + With [Connect](https://stripe.com/docs/connect), you may flag accounts as suspicious. + + Test-mode Custom and Express accounts can be rejected at any time. Accounts created using live-mode keys may only be rejected once all balances are zero. + """ + return cast( + "Account", + await self._request_async( + "post", + "/v1/accounts/{account}/reject".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) @classmethod def retrieve(cls, id=None, **params) -> "Account": @@ -3998,11 +4220,25 @@ def retrieve(cls, id=None, **params) -> "Account": instance.refresh() return instance + @classmethod + async def retrieve_async(cls, id=None, **params) -> "Account": + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def modify(cls, id=None, **params) -> "Account": url = cls._build_instance_url(id) return cast("Account", cls._static_request("post", url, params=params)) + @classmethod + async def modify_async(cls, id=None, **params) -> "Account": + url = cls._build_instance_url(id) + return cast( + "Account", + await cls._static_request_async("post", url, params=params), + ) + @classmethod def _build_instance_url(cls, sid): if not sid: @@ -4050,6 +4286,28 @@ def retrieve_capability( ), ) + @classmethod + async def retrieve_capability_async( + cls, + account: str, + capability: str, + **params: Unpack["Account.RetrieveCapabilityParams"] + ) -> "Capability": + """ + Retrieves information about the specified Account Capability. + """ + return cast( + "Capability", + await cls._static_request_async( + "get", + "/v1/accounts/{account}/capabilities/{capability}".format( + account=sanitize_id(account), + capability=sanitize_id(capability), + ), + params=params, + ), + ) + @classmethod def modify_capability( cls, @@ -4072,6 +4330,28 @@ def modify_capability( ), ) + @classmethod + async def modify_capability_async( + cls, + account: str, + capability: str, + **params: Unpack["Account.ModifyCapabilityParams"] + ) -> "Capability": + """ + Updates an existing Account Capability. Request or remove a capability by updating its requested parameter. + """ + return cast( + "Capability", + await cls._static_request_async( + "post", + "/v1/accounts/{account}/capabilities/{capability}".format( + account=sanitize_id(account), + capability=sanitize_id(capability), + ), + params=params, + ), + ) + @classmethod def list_capabilities( cls, account: str, **params: Unpack["Account.ListCapabilitiesParams"] @@ -4090,6 +4370,24 @@ def list_capabilities( ), ) + @classmethod + async def list_capabilities_async( + cls, account: str, **params: Unpack["Account.ListCapabilitiesParams"] + ) -> ListObject["Capability"]: + """ + Returns a list of capabilities associated with the account. The capabilities are returned sorted by creation date, with the most recent capability appearing first. + """ + return cast( + ListObject["Capability"], + await cls._static_request_async( + "get", + "/v1/accounts/{account}/capabilities".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + @classmethod def create_external_account( cls, @@ -4110,6 +4408,26 @@ def create_external_account( ), ) + @classmethod + async def create_external_account_async( + cls, + account: str, + **params: Unpack["Account.CreateExternalAccountParams"] + ) -> Union["BankAccount", "Card"]: + """ + Create an external account for a given account. + """ + return cast( + Union["BankAccount", "Card"], + await cls._static_request_async( + "post", + "/v1/accounts/{account}/external_accounts".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + @classmethod def retrieve_external_account( cls, @@ -4131,6 +4449,27 @@ def retrieve_external_account( ), ) + @classmethod + async def retrieve_external_account_async( + cls, + account: str, + id: str, + **params: Unpack["Account.RetrieveExternalAccountParams"] + ) -> Union["BankAccount", "Card"]: + """ + Retrieve a specified external account for a given account. + """ + return cast( + Union["BankAccount", "Card"], + await cls._static_request_async( + "get", + "/v1/accounts/{account}/external_accounts/{id}".format( + account=sanitize_id(account), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def modify_external_account( cls, @@ -4154,6 +4493,29 @@ def modify_external_account( ), ) + @classmethod + async def modify_external_account_async( + cls, + account: str, + id: str, + **params: Unpack["Account.ModifyExternalAccountParams"] + ) -> Union["BankAccount", "Card"]: + """ + Updates the metadata, account holder name, account holder type of a bank account belonging to a [Custom account](https://stripe.com/docs/connect/custom-accounts), and optionally sets it as the default for its currency. Other bank account details are not editable by design. + + You can re-enable a disabled bank account by performing an update call without providing any arguments or changes. + """ + return cast( + Union["BankAccount", "Card"], + await cls._static_request_async( + "post", + "/v1/accounts/{account}/external_accounts/{id}".format( + account=sanitize_id(account), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def delete_external_account( cls, @@ -4175,6 +4537,27 @@ def delete_external_account( ), ) + @classmethod + async def delete_external_account_async( + cls, + account: str, + id: str, + **params: Unpack["Account.DeleteExternalAccountParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + return cast( + Union["BankAccount", "Card"], + await cls._static_request_async( + "delete", + "/v1/accounts/{account}/external_accounts/{id}".format( + account=sanitize_id(account), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def list_external_accounts( cls, @@ -4195,6 +4578,26 @@ def list_external_accounts( ), ) + @classmethod + async def list_external_accounts_async( + cls, + account: str, + **params: Unpack["Account.ListExternalAccountsParams"] + ) -> ListObject[Union["BankAccount", "Card"]]: + """ + List external accounts for an account. + """ + return cast( + ListObject[Union["BankAccount", "Card"]], + await cls._static_request_async( + "get", + "/v1/accounts/{account}/external_accounts".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + @classmethod def create_login_link( cls, account: str, **params: Unpack["Account.CreateLoginLinkParams"] @@ -4215,6 +4618,26 @@ def create_login_link( ), ) + @classmethod + async def create_login_link_async( + cls, account: str, **params: Unpack["Account.CreateLoginLinkParams"] + ) -> "LoginLink": + """ + Creates a single-use login link for an Express account to access their Stripe dashboard. + + You may only create login links for [Express accounts](https://stripe.com/docs/connect/express-accounts) connected to your platform. + """ + return cast( + "LoginLink", + await cls._static_request_async( + "post", + "/v1/accounts/{account}/login_links".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + @classmethod def create_person( cls, account: str, **params: Unpack["Account.CreatePersonParams"] @@ -4233,6 +4656,24 @@ def create_person( ), ) + @classmethod + async def create_person_async( + cls, account: str, **params: Unpack["Account.CreatePersonParams"] + ) -> "Person": + """ + Creates a new person. + """ + return cast( + "Person", + await cls._static_request_async( + "post", + "/v1/accounts/{account}/persons".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + @classmethod def retrieve_person( cls, @@ -4254,6 +4695,27 @@ def retrieve_person( ), ) + @classmethod + async def retrieve_person_async( + cls, + account: str, + person: str, + **params: Unpack["Account.RetrievePersonParams"] + ) -> "Person": + """ + Retrieves an existing person. + """ + return cast( + "Person", + await cls._static_request_async( + "get", + "/v1/accounts/{account}/persons/{person}".format( + account=sanitize_id(account), person=sanitize_id(person) + ), + params=params, + ), + ) + @classmethod def modify_person( cls, @@ -4275,6 +4737,27 @@ def modify_person( ), ) + @classmethod + async def modify_person_async( + cls, + account: str, + person: str, + **params: Unpack["Account.ModifyPersonParams"] + ) -> "Person": + """ + Updates an existing person. + """ + return cast( + "Person", + await cls._static_request_async( + "post", + "/v1/accounts/{account}/persons/{person}".format( + account=sanitize_id(account), person=sanitize_id(person) + ), + params=params, + ), + ) + @classmethod def delete_person( cls, @@ -4296,6 +4779,27 @@ def delete_person( ), ) + @classmethod + async def delete_person_async( + cls, + account: str, + person: str, + **params: Unpack["Account.DeletePersonParams"] + ) -> "Person": + """ + Deletes an existing person's relationship to the account's legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file. + """ + return cast( + "Person", + await cls._static_request_async( + "delete", + "/v1/accounts/{account}/persons/{person}".format( + account=sanitize_id(account), person=sanitize_id(person) + ), + params=params, + ), + ) + @classmethod def list_persons( cls, account: str, **params: Unpack["Account.ListPersonsParams"] @@ -4314,6 +4818,24 @@ def list_persons( ), ) + @classmethod + async def list_persons_async( + cls, account: str, **params: Unpack["Account.ListPersonsParams"] + ) -> ListObject["Person"]: + """ + Returns a list of people associated with the account's legal entity. The people are returned sorted by creation date, with the most recent people appearing first. + """ + return cast( + ListObject["Person"], + await cls._static_request_async( + "get", + "/v1/accounts/{account}/persons".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + _inner_class_types = { "business_profile": BusinessProfile, "capabilities": Capabilities, diff --git a/stripe/_account_link.py b/stripe/_account_link.py index e16d6beb6..fe7b33bd6 100644 --- a/stripe/_account_link.py +++ b/stripe/_account_link.py @@ -95,3 +95,19 @@ def create( params=params, ), ) + + @classmethod + async def create_async( + cls, **params: Unpack["AccountLink.CreateParams"] + ) -> "AccountLink": + """ + Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow. + """ + return cast( + "AccountLink", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) diff --git a/stripe/_account_notice.py b/stripe/_account_notice.py index b429f3bc1..404124b8f 100644 --- a/stripe/_account_notice.py +++ b/stripe/_account_notice.py @@ -183,6 +183,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["AccountNotice.ListParams"] + ) -> ListObject["AccountNotice"]: + """ + Retrieves a list of AccountNotice objects. The objects are sorted in descending order by creation date, with the most-recently-created object appearing first. + """ + 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["AccountNotice.ModifyParams"] @@ -200,6 +221,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["AccountNotice.ModifyParams"] + ) -> "AccountNotice": + """ + Updates an AccountNotice object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "AccountNotice", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["AccountNotice.RetrieveParams"] @@ -211,4 +249,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["AccountNotice.RetrieveParams"] + ) -> "AccountNotice": + """ + Retrieves an AccountNotice object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"email": Email, "linked_objects": LinkedObjects} diff --git a/stripe/_account_session.py b/stripe/_account_session.py index a28d6657d..a1a5eb410 100644 --- a/stripe/_account_session.py +++ b/stripe/_account_session.py @@ -311,4 +311,20 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["AccountSession.CreateParams"] + ) -> "AccountSession": + """ + Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access. + """ + return cast( + "AccountSession", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + _inner_class_types = {"components": Components} diff --git a/stripe/_apple_pay_domain.py b/stripe/_apple_pay_domain.py index ac0370412..2d01cebc3 100644 --- a/stripe/_apple_pay_domain.py +++ b/stripe/_apple_pay_domain.py @@ -90,6 +90,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ApplePayDomain.CreateParams"] + ) -> "ApplePayDomain": + """ + Create an apple pay domain. + """ + return cast( + "ApplePayDomain", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["ApplePayDomain.DeleteParams"] @@ -139,6 +155,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["ApplePayDomain.DeleteParams"] + ) -> "ApplePayDomain": + """ + Delete an apple pay domain. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "ApplePayDomain", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["ApplePayDomain.DeleteParams"] + ) -> "ApplePayDomain": + """ + Delete an apple pay domain. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["ApplePayDomain.DeleteParams"] + ) -> "ApplePayDomain": + """ + Delete an apple pay domain. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["ApplePayDomain.DeleteParams"] + ) -> "ApplePayDomain": + """ + Delete an apple pay domain. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["ApplePayDomain.ListParams"] @@ -160,6 +225,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ApplePayDomain.ListParams"] + ) -> ListObject["ApplePayDomain"]: + """ + List apple pay domains. + """ + 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["ApplePayDomain.RetrieveParams"] @@ -171,6 +257,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ApplePayDomain.RetrieveParams"] + ) -> "ApplePayDomain": + """ + Retrieve an apple pay domain. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/apple_pay/domains" diff --git a/stripe/_application_fee.py b/stripe/_application_fee.py index 654b58c80..085826abe 100644 --- a/stripe/_application_fee.py +++ b/stripe/_application_fee.py @@ -214,6 +214,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ApplicationFee.ListParams"] + ) -> ListObject["ApplicationFee"]: + """ + Returns a list of application fees you've previously collected. The application fees are returned in sorted order, with the most recent fees appearing first. + """ + 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 _cls_refund( cls, id: str, **params: Unpack["ApplicationFee.RefundParams"] @@ -299,6 +320,91 @@ def refund( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_refund_async( + cls, id: str, **params: Unpack["ApplicationFee.RefundParams"] + ) -> "ApplicationFeeRefund": + """ + Refunds an application fee that has previously been collected but not yet refunded. + Funds will be refunded to the Stripe account from which the fee was originally collected. + + You can optionally refund only part of an application fee. + You can do so multiple times, until the entire fee has been refunded. + + Once entirely refunded, an application fee can't be refunded again. + This method will raise an error when called on an already-refunded application fee, + or when trying to refund more money than is left on an application fee. + """ + return cast( + "ApplicationFeeRefund", + await cls._static_request_async( + "post", + "/v1/application_fees/{id}/refunds".format(id=sanitize_id(id)), + params=params, + ), + ) + + @overload + @staticmethod + async def refund_async( + id: str, **params: Unpack["ApplicationFee.RefundParams"] + ) -> "ApplicationFeeRefund": + """ + Refunds an application fee that has previously been collected but not yet refunded. + Funds will be refunded to the Stripe account from which the fee was originally collected. + + You can optionally refund only part of an application fee. + You can do so multiple times, until the entire fee has been refunded. + + Once entirely refunded, an application fee can't be refunded again. + This method will raise an error when called on an already-refunded application fee, + or when trying to refund more money than is left on an application fee. + """ + ... + + @overload + async def refund_async( + self, **params: Unpack["ApplicationFee.RefundParams"] + ) -> "ApplicationFeeRefund": + """ + Refunds an application fee that has previously been collected but not yet refunded. + Funds will be refunded to the Stripe account from which the fee was originally collected. + + You can optionally refund only part of an application fee. + You can do so multiple times, until the entire fee has been refunded. + + Once entirely refunded, an application fee can't be refunded again. + This method will raise an error when called on an already-refunded application fee, + or when trying to refund more money than is left on an application fee. + """ + ... + + @class_method_variant("_cls_refund_async") + async def refund_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["ApplicationFee.RefundParams"] + ) -> "ApplicationFeeRefund": + """ + Refunds an application fee that has previously been collected but not yet refunded. + Funds will be refunded to the Stripe account from which the fee was originally collected. + + You can optionally refund only part of an application fee. + You can do so multiple times, until the entire fee has been refunded. + + Once entirely refunded, an application fee can't be refunded again. + This method will raise an error when called on an already-refunded application fee, + or when trying to refund more money than is left on an application fee. + """ + return cast( + "ApplicationFeeRefund", + await self._request_async( + "post", + "/v1/application_fees/{id}/refunds".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["ApplicationFee.RetrieveParams"] @@ -310,6 +416,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ApplicationFee.RetrieveParams"] + ) -> "ApplicationFee": + """ + Retrieves the details of an application fee that your account has collected. The same information is returned when refunding the application fee. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def create_refund( cls, id: str, **params: Unpack["ApplicationFee.CreateRefundParams"] @@ -334,6 +451,30 @@ def create_refund( ), ) + @classmethod + async def create_refund_async( + cls, id: str, **params: Unpack["ApplicationFee.CreateRefundParams"] + ) -> "ApplicationFeeRefund": + """ + Refunds an application fee that has previously been collected but not yet refunded. + Funds will be refunded to the Stripe account from which the fee was originally collected. + + You can optionally refund only part of an application fee. + You can do so multiple times, until the entire fee has been refunded. + + Once entirely refunded, an application fee can't be refunded again. + This method will raise an error when called on an already-refunded application fee, + or when trying to refund more money than is left on an application fee. + """ + return cast( + "ApplicationFeeRefund", + await cls._static_request_async( + "post", + "/v1/application_fees/{id}/refunds".format(id=sanitize_id(id)), + params=params, + ), + ) + @classmethod def retrieve_refund( cls, @@ -355,6 +496,27 @@ def retrieve_refund( ), ) + @classmethod + async def retrieve_refund_async( + cls, + fee: str, + id: str, + **params: Unpack["ApplicationFee.RetrieveRefundParams"] + ) -> "ApplicationFeeRefund": + """ + By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee. + """ + return cast( + "ApplicationFeeRefund", + await cls._static_request_async( + "get", + "/v1/application_fees/{fee}/refunds/{id}".format( + fee=sanitize_id(fee), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def modify_refund( cls, @@ -378,6 +540,29 @@ def modify_refund( ), ) + @classmethod + async def modify_refund_async( + cls, + fee: str, + id: str, + **params: Unpack["ApplicationFee.ModifyRefundParams"] + ) -> "ApplicationFeeRefund": + """ + Updates the specified application fee refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + + This request only accepts metadata as an argument. + """ + return cast( + "ApplicationFeeRefund", + await cls._static_request_async( + "post", + "/v1/application_fees/{fee}/refunds/{id}".format( + fee=sanitize_id(fee), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def list_refunds( cls, id: str, **params: Unpack["ApplicationFee.ListRefundsParams"] @@ -393,3 +578,19 @@ def list_refunds( params=params, ), ) + + @classmethod + async def list_refunds_async( + cls, id: str, **params: Unpack["ApplicationFee.ListRefundsParams"] + ) -> ListObject["ApplicationFeeRefund"]: + """ + You can see a list of the refunds belonging to a specific application fee. Note that the 10 most recent refunds are always available by default on the application fee object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional refunds. + """ + return cast( + ListObject["ApplicationFeeRefund"], + await cls._static_request_async( + "get", + "/v1/application_fees/{id}/refunds".format(id=sanitize_id(id)), + params=params, + ), + ) diff --git a/stripe/_balance.py b/stripe/_balance.py index f110d15d0..309ef756d 100644 --- a/stripe/_balance.py +++ b/stripe/_balance.py @@ -203,6 +203,18 @@ def retrieve(cls, **params: Unpack["Balance.RetrieveParams"]) -> "Balance": instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, **params: Unpack["Balance.RetrieveParams"] + ) -> "Balance": + """ + Retrieves the current account balance, based on the authentication that was used to make the request. + For a sample request, see [Accounting for negative balances](https://stripe.com/docs/connect/account-balances#accounting-for-negative-balances). + """ + instance = cls(None, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/balance" diff --git a/stripe/_balance_transaction.py b/stripe/_balance_transaction.py index cd2be2bef..ebcebd52f 100644 --- a/stripe/_balance_transaction.py +++ b/stripe/_balance_transaction.py @@ -280,6 +280,29 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["BalanceTransaction.ListParams"] + ) -> ListObject["BalanceTransaction"]: + """ + Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first. + + Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history. + """ + 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["BalanceTransaction.RetrieveParams"] @@ -293,4 +316,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["BalanceTransaction.RetrieveParams"] + ) -> "BalanceTransaction": + """ + Retrieves the balance transaction with the given ID. + + Note that this endpoint previously used the path /v1/balance/history/:id. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"fee_details": FeeDetail} diff --git a/stripe/_bank_account.py b/stripe/_bank_account.py index 6c5d6e236..6f915e40c 100644 --- a/stripe/_bank_account.py +++ b/stripe/_bank_account.py @@ -411,6 +411,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["BankAccount.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + Union["BankAccount", "Card"], + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["BankAccount.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["BankAccount.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["BankAccount.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + def instance_url(self): token = self.id extn = sanitize_id(token) diff --git a/stripe/_card.py b/stripe/_card.py index 47d00eafc..3bb0e428f 100644 --- a/stripe/_card.py +++ b/stripe/_card.py @@ -209,6 +209,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Card.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + Union["BankAccount", "Card"], + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Card.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Card.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Card.DeleteParams"] + ) -> Union["BankAccount", "Card"]: + """ + Delete a specified external account for a given account. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + def instance_url(self): token = self.id extn = sanitize_id(token) diff --git a/stripe/_charge.py b/stripe/_charge.py index eeaf41f27..d9702ee17 100644 --- a/stripe/_charge.py +++ b/stripe/_charge.py @@ -11,6 +11,7 @@ from stripe._updateable_api_resource import UpdateableAPIResource from stripe._util import class_method_variant, sanitize_id from typing import ( + AsyncIterator, ClassVar, Dict, Iterator, @@ -3641,6 +3642,77 @@ def capture( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_capture_async( + cls, charge: str, **params: Unpack["Charge.CaptureParams"] + ) -> "Charge": + """ + Capture the payment of an existing, uncaptured charge that was created with the capture option set to false. + + Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail. + + Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture). + """ + return cast( + "Charge", + await cls._static_request_async( + "post", + "/v1/charges/{charge}/capture".format( + charge=sanitize_id(charge) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def capture_async( + charge: str, **params: Unpack["Charge.CaptureParams"] + ) -> "Charge": + """ + Capture the payment of an existing, uncaptured charge that was created with the capture option set to false. + + Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail. + + Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture). + """ + ... + + @overload + async def capture_async( + self, **params: Unpack["Charge.CaptureParams"] + ) -> "Charge": + """ + Capture the payment of an existing, uncaptured charge that was created with the capture option set to false. + + Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail. + + Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture). + """ + ... + + @class_method_variant("_cls_capture_async") + async def capture_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Charge.CaptureParams"] + ) -> "Charge": + """ + Capture the payment of an existing, uncaptured charge that was created with the capture option set to false. + + Uncaptured payments expire a set number of days after they are created ([7 by default](https://stripe.com/docs/charges/placing-a-hold)), after which they are marked as refunded and capture attempts will fail. + + Don't use this method to capture a PaymentIntent-initiated charge. Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture). + """ + return cast( + "Charge", + await self._request_async( + "post", + "/v1/charges/{charge}/capture".format( + charge=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Charge.CreateParams"]) -> "Charge": """ @@ -3657,6 +3729,24 @@ def create(cls, **params: Unpack["Charge.CreateParams"]) -> "Charge": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Charge.CreateParams"] + ) -> "Charge": + """ + This method is no longer recommended—use the [Payment Intents API](https://stripe.com/docs/api/payment_intents) + to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge + object used to request payment. + """ + return cast( + "Charge", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Charge.ListParams"] @@ -3678,6 +3768,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Charge.ListParams"] + ) -> ListObject["Charge"]: + """ + Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges appearing first. + """ + 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["Charge.ModifyParams"] @@ -3695,6 +3806,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Charge.ModifyParams"] + ) -> "Charge": + """ + Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Charge", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Charge.RetrieveParams"] @@ -3706,6 +3834,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Charge.RetrieveParams"] + ) -> "Charge": + """ + Retrieves the details of a charge that has previously been created. Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. The same information is returned when creating or refunding the charge. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def search( cls, *args, **kwargs: Unpack["Charge.SearchParams"] @@ -3718,11 +3857,33 @@ def search( """ return cls._search(search_url="/v1/charges/search", *args, **kwargs) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["Charge.SearchParams"] + ) -> SearchResultObject["Charge"]: + """ + Search for charges you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/charges/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["Charge.SearchParams"] ) -> Iterator["Charge"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["Charge.SearchParams"] + ) -> AsyncIterator["Charge"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() def mark_as_fraudulent(self, idempotency_key=None) -> "Charge": params = { diff --git a/stripe/_confirmation_token.py b/stripe/_confirmation_token.py index 77383d358..7e2569874 100644 --- a/stripe/_confirmation_token.py +++ b/stripe/_confirmation_token.py @@ -1228,6 +1228,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ConfirmationToken.RetrieveParams"] + ) -> "ConfirmationToken": + """ + Retrieves an existing ConfirmationToken object + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "mandate_data": MandateData, "payment_method_preview": PaymentMethodPreview, diff --git a/stripe/_country_spec.py b/stripe/_country_spec.py index 6ca8a1433..95b8b386f 100644 --- a/stripe/_country_spec.py +++ b/stripe/_country_spec.py @@ -120,6 +120,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CountrySpec.ListParams"] + ) -> ListObject["CountrySpec"]: + """ + Lists all Country Spec objects available in the API. + """ + 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["CountrySpec.RetrieveParams"] @@ -131,4 +152,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["CountrySpec.RetrieveParams"] + ) -> "CountrySpec": + """ + Returns a Country Spec for a given Country code. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"verification_fields": VerificationFields} diff --git a/stripe/_coupon.py b/stripe/_coupon.py index be44ad1f7..3a970186a 100644 --- a/stripe/_coupon.py +++ b/stripe/_coupon.py @@ -269,6 +269,24 @@ def create(cls, **params: Unpack["Coupon.CreateParams"]) -> "Coupon": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Coupon.CreateParams"] + ) -> "Coupon": + """ + You can create coupons easily via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. Coupon creation is also accessible via the API if you need to create coupons on the fly. + + A coupon has either a percent_off or an amount_off and currency. If you set an amount_off, that amount will be subtracted from any invoice's subtotal. For example, an invoice with a subtotal of 100 will have a final total of 0 if a coupon with an amount_off of 200 is applied to it and an invoice with a subtotal of 300 will have a final total of 100 if a coupon with an amount_off of 200 is applied to it. + """ + return cast( + "Coupon", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Coupon.DeleteParams"] @@ -314,6 +332,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Coupon.DeleteParams"] + ) -> "Coupon": + """ + You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Coupon", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Coupon.DeleteParams"] + ) -> "Coupon": + """ + You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Coupon.DeleteParams"] + ) -> "Coupon": + """ + You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Coupon.DeleteParams"] + ) -> "Coupon": + """ + You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can't redeem the coupon. You can also delete coupons via the API. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["Coupon.ListParams"] @@ -335,6 +402,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Coupon.ListParams"] + ) -> ListObject["Coupon"]: + """ + Returns a list of your coupons. + """ + 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["Coupon.ModifyParams"] @@ -352,6 +440,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Coupon.ModifyParams"] + ) -> "Coupon": + """ + Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Coupon", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Coupon.RetrieveParams"] @@ -363,6 +468,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Coupon.RetrieveParams"] + ) -> "Coupon": + """ + Retrieves the coupon with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "applies_to": AppliesTo, "currency_options": CurrencyOptions, diff --git a/stripe/_credit_note.py b/stripe/_credit_note.py index bb1140084..a426d8147 100644 --- a/stripe/_credit_note.py +++ b/stripe/_credit_note.py @@ -798,6 +798,35 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["CreditNote.CreateParams"] + ) -> "CreditNote": + """ + Issue a credit note to adjust the amount of a finalized invoice. For a status=open invoice, a credit note reduces + its amount_due. For a status=paid invoice, a credit note does not affect its amount_due. Instead, it can result + in any combination of the following: + + + Refund: create a new refund (using refund_amount) or link an existing refund (using refund). + Customer balance credit: credit the customer's balance (using credit_amount) which will be automatically applied to their next invoice when it's finalized. + Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using out_of_band_amount). + + + For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. + + You may issue multiple credit notes for an invoice. Each credit note will increment the invoice's pre_payment_credit_notes_amount + or post_payment_credit_notes_amount depending on its status at the time of credit note creation. + """ + return cast( + "CreditNote", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["CreditNote.ListParams"] @@ -819,6 +848,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CreditNote.ListParams"] + ) -> ListObject["CreditNote"]: + """ + Returns a list of credit notes. + """ + 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["CreditNote.ModifyParams"] @@ -836,6 +886,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["CreditNote.ModifyParams"] + ) -> "CreditNote": + """ + Updates an existing credit note. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "CreditNote", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def preview( cls, **params: Unpack["CreditNote.PreviewParams"] @@ -852,6 +919,22 @@ def preview( ), ) + @classmethod + async def preview_async( + cls, **params: Unpack["CreditNote.PreviewParams"] + ) -> "CreditNote": + """ + Get a preview of a credit note without creating it. + """ + return cast( + "CreditNote", + await cls._static_request_async( + "get", + "/v1/credit_notes/preview", + params=params, + ), + ) + @classmethod def preview_lines( cls, **params: Unpack["CreditNote.PreviewLinesParams"] @@ -868,6 +951,22 @@ def preview_lines( ), ) + @classmethod + async def preview_lines_async( + cls, **params: Unpack["CreditNote.PreviewLinesParams"] + ) -> ListObject["CreditNoteLineItem"]: + """ + When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["CreditNoteLineItem"], + await cls._static_request_async( + "get", + "/v1/credit_notes/preview/lines", + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["CreditNote.RetrieveParams"] @@ -879,6 +978,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["CreditNote.RetrieveParams"] + ) -> "CreditNote": + """ + Retrieves the credit note object with the given identifier. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_void_credit_note( cls, id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"] @@ -932,6 +1042,59 @@ def void_credit_note( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_void_credit_note_async( + cls, id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"] + ) -> "CreditNote": + """ + Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + """ + return cast( + "CreditNote", + await cls._static_request_async( + "post", + "/v1/credit_notes/{id}/void".format(id=sanitize_id(id)), + params=params, + ), + ) + + @overload + @staticmethod + async def void_credit_note_async( + id: str, **params: Unpack["CreditNote.VoidCreditNoteParams"] + ) -> "CreditNote": + """ + Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + """ + ... + + @overload + async def void_credit_note_async( + self, **params: Unpack["CreditNote.VoidCreditNoteParams"] + ) -> "CreditNote": + """ + Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + """ + ... + + @class_method_variant("_cls_void_credit_note_async") + async def void_credit_note_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditNote.VoidCreditNoteParams"] + ) -> "CreditNote": + """ + Marks a credit note as void. Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + """ + return cast( + "CreditNote", + await self._request_async( + "post", + "/v1/credit_notes/{id}/void".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list_lines( cls, credit_note: str, **params: Unpack["CreditNote.ListLinesParams"] @@ -950,6 +1113,24 @@ def list_lines( ), ) + @classmethod + async def list_lines_async( + cls, credit_note: str, **params: Unpack["CreditNote.ListLinesParams"] + ) -> ListObject["CreditNoteLineItem"]: + """ + When retrieving a credit note, you'll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["CreditNoteLineItem"], + await cls._static_request_async( + "get", + "/v1/credit_notes/{credit_note}/lines".format( + credit_note=sanitize_id(credit_note) + ), + params=params, + ), + ) + _inner_class_types = { "discount_amounts": DiscountAmount, "refunds": Refund, diff --git a/stripe/_credit_note_line_item.py b/stripe/_credit_note_line_item.py index 160e8c6dc..513cf020a 100644 --- a/stripe/_credit_note_line_item.py +++ b/stripe/_credit_note_line_item.py @@ -176,6 +176,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CreditNoteLineItem.ListParams"] + ) -> ListObject["CreditNoteLineItem"]: + """ + When retrieving a credit note, you'll get a lines property containing the the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + 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 + _inner_class_types = { "discount_amounts": DiscountAmount, "tax_amounts": TaxAmount, diff --git a/stripe/_customer.py b/stripe/_customer.py index d56af8aea..849dbf0b1 100644 --- a/stripe/_customer.py +++ b/stripe/_customer.py @@ -14,6 +14,7 @@ from stripe._updateable_api_resource import UpdateableAPIResource from stripe._util import class_method_variant, sanitize_id from typing import ( + AsyncIterator, ClassVar, Dict, Iterator, @@ -1420,6 +1421,22 @@ def create(cls, **params: Unpack["Customer.CreateParams"]) -> "Customer": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Customer.CreateParams"] + ) -> "Customer": + """ + Creates a new customer object. + """ + return cast( + "Customer", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_create_funding_instructions( cls, @@ -1486,6 +1503,72 @@ def create_funding_instructions( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_create_funding_instructions_async( + cls, + customer: str, + **params: Unpack["Customer.CreateFundingInstructionsParams"] + ) -> "FundingInstructions": + """ + Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new + funding instructions will be created. If funding instructions have already been created for a given customer, the same + funding instructions will be retrieved. In other words, we will return the same funding instructions each time. + """ + return cast( + "FundingInstructions", + await cls._static_request_async( + "post", + "/v1/customers/{customer}/funding_instructions".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def create_funding_instructions_async( + customer: str, + **params: Unpack["Customer.CreateFundingInstructionsParams"] + ) -> "FundingInstructions": + """ + Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new + funding instructions will be created. If funding instructions have already been created for a given customer, the same + funding instructions will be retrieved. In other words, we will return the same funding instructions each time. + """ + ... + + @overload + async def create_funding_instructions_async( + self, **params: Unpack["Customer.CreateFundingInstructionsParams"] + ) -> "FundingInstructions": + """ + Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new + funding instructions will be created. If funding instructions have already been created for a given customer, the same + funding instructions will be retrieved. In other words, we will return the same funding instructions each time. + """ + ... + + @class_method_variant("_cls_create_funding_instructions_async") + async def create_funding_instructions_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Customer.CreateFundingInstructionsParams"] + ) -> "FundingInstructions": + """ + Retrieve funding instructions for a customer cash balance. If funding instructions do not yet exist for the customer, new + funding instructions will be created. If funding instructions have already been created for a given customer, the same + funding instructions will be retrieved. In other words, we will return the same funding instructions each time. + """ + return cast( + "FundingInstructions", + await self._request_async( + "post", + "/v1/customers/{customer}/funding_instructions".format( + customer=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Customer.DeleteParams"] @@ -1533,6 +1616,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Customer.DeleteParams"] + ) -> "Customer": + """ + Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Customer", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Customer.DeleteParams"] + ) -> "Customer": + """ + Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Customer.DeleteParams"] + ) -> "Customer": + """ + Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Customer.DeleteParams"] + ) -> "Customer": + """ + Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def _cls_delete_discount( cls, customer: str, **params: Unpack["Customer.DeleteDiscountParams"] @@ -1588,6 +1720,61 @@ def delete_discount( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_delete_discount_async( + cls, customer: str, **params: Unpack["Customer.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a customer. + """ + return cast( + "Discount", + await cls._static_request_async( + "delete", + "/v1/customers/{customer}/discount".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def delete_discount_async( + customer: str, **params: Unpack["Customer.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a customer. + """ + ... + + @overload + async def delete_discount_async( + self, **params: Unpack["Customer.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a customer. + """ + ... + + @class_method_variant("_cls_delete_discount_async") + async def delete_discount_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Customer.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a customer. + """ + return cast( + "Discount", + await self._request_async( + "delete", + "/v1/customers/{customer}/discount".format( + customer=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Customer.ListParams"] @@ -1609,6 +1796,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Customer.ListParams"] + ) -> ListObject["Customer"]: + """ + Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first. + """ + 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 _cls_list_payment_methods( cls, @@ -1666,6 +1874,63 @@ def list_payment_methods( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_payment_methods_async( + cls, + customer: str, + **params: Unpack["Customer.ListPaymentMethodsParams"] + ) -> ListObject["PaymentMethod"]: + """ + Returns a list of PaymentMethods for a given Customer + """ + return cast( + ListObject["PaymentMethod"], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/payment_methods".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_payment_methods_async( + customer: str, **params: Unpack["Customer.ListPaymentMethodsParams"] + ) -> ListObject["PaymentMethod"]: + """ + Returns a list of PaymentMethods for a given Customer + """ + ... + + @overload + async def list_payment_methods_async( + self, **params: Unpack["Customer.ListPaymentMethodsParams"] + ) -> ListObject["PaymentMethod"]: + """ + Returns a list of PaymentMethods for a given Customer + """ + ... + + @class_method_variant("_cls_list_payment_methods_async") + async def list_payment_methods_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Customer.ListPaymentMethodsParams"] + ) -> ListObject["PaymentMethod"]: + """ + Returns a list of PaymentMethods for a given Customer + """ + return cast( + ListObject["PaymentMethod"], + await self._request_async( + "get", + "/v1/customers/{customer}/payment_methods".format( + customer=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def modify( cls, id: str, **params: Unpack["Customer.ModifyParams"] @@ -1685,6 +1950,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Customer.ModifyParams"] + ) -> "Customer": + """ + Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. For example, if you pass the source parameter, that becomes the customer's active source (e.g., a card) to be used for all charges in the future. When you update a customer to a new valid card source by passing the source parameter: for each of the customer's current subscriptions, if the subscription bills automatically and is in the past_due state, then the latest open invoice for the subscription with automatic collection enabled will be retried. This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. Changing the default_source for a customer will not trigger this behavior. + + This request accepts mostly the same arguments as the customer creation call. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Customer", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Customer.RetrieveParams"] @@ -1696,6 +1980,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Customer.RetrieveParams"] + ) -> "Customer": + """ + Retrieves a Customer object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_retrieve_payment_method( cls, @@ -1762,6 +2057,72 @@ def retrieve_payment_method( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_retrieve_payment_method_async( + cls, + customer: str, + payment_method: str, + **params: Unpack["Customer.RetrievePaymentMethodParams"] + ) -> "PaymentMethod": + """ + Retrieves a PaymentMethod object for a given Customer. + """ + return cast( + "PaymentMethod", + await cls._static_request_async( + "get", + "/v1/customers/{customer}/payment_methods/{payment_method}".format( + customer=sanitize_id(customer), + payment_method=sanitize_id(payment_method), + ), + params=params, + ), + ) + + @overload + @staticmethod + async def retrieve_payment_method_async( + customer: str, + payment_method: str, + **params: Unpack["Customer.RetrievePaymentMethodParams"] + ) -> "PaymentMethod": + """ + Retrieves a PaymentMethod object for a given Customer. + """ + ... + + @overload + async def retrieve_payment_method_async( + self, + payment_method: str, + **params: Unpack["Customer.RetrievePaymentMethodParams"] + ) -> "PaymentMethod": + """ + Retrieves a PaymentMethod object for a given Customer. + """ + ... + + @class_method_variant("_cls_retrieve_payment_method_async") + async def retrieve_payment_method_async( # pyright: ignore[reportGeneralTypeIssues] + self, + payment_method: str, + **params: Unpack["Customer.RetrievePaymentMethodParams"] + ) -> "PaymentMethod": + """ + Retrieves a PaymentMethod object for a given Customer. + """ + return cast( + "PaymentMethod", + await self._request_async( + "get", + "/v1/customers/{customer}/payment_methods/{payment_method}".format( + customer=sanitize_id(self.get("id")), + payment_method=sanitize_id(payment_method), + ), + params=params, + ), + ) + @classmethod def search( cls, *args, **kwargs: Unpack["Customer.SearchParams"] @@ -1774,11 +2135,33 @@ def search( """ return cls._search(search_url="/v1/customers/search", *args, **kwargs) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["Customer.SearchParams"] + ) -> SearchResultObject["Customer"]: + """ + Search for customers you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/customers/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["Customer.SearchParams"] ) -> Iterator["Customer"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["Customer.SearchParams"] + ) -> AsyncIterator["Customer"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() @classmethod def create_balance_transaction( @@ -1800,6 +2183,26 @@ def create_balance_transaction( ), ) + @classmethod + async def create_balance_transaction_async( + cls, + customer: str, + **params: Unpack["Customer.CreateBalanceTransactionParams"] + ) -> "CustomerBalanceTransaction": + """ + Creates an immutable transaction that updates the customer's credit [balance](https://stripe.com/docs/billing/customer/balance). + """ + return cast( + "CustomerBalanceTransaction", + await cls._static_request_async( + "post", + "/v1/customers/{customer}/balance_transactions".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def retrieve_balance_transaction( cls, @@ -1822,6 +2225,28 @@ def retrieve_balance_transaction( ), ) + @classmethod + async def retrieve_balance_transaction_async( + cls, + customer: str, + transaction: str, + **params: Unpack["Customer.RetrieveBalanceTransactionParams"] + ) -> "CustomerBalanceTransaction": + """ + Retrieves a specific customer balance transaction that updated the customer's [balances](https://stripe.com/docs/billing/customer/balance). + """ + return cast( + "CustomerBalanceTransaction", + await cls._static_request_async( + "get", + "/v1/customers/{customer}/balance_transactions/{transaction}".format( + customer=sanitize_id(customer), + transaction=sanitize_id(transaction), + ), + params=params, + ), + ) + @classmethod def modify_balance_transaction( cls, @@ -1844,6 +2269,28 @@ def modify_balance_transaction( ), ) + @classmethod + async def modify_balance_transaction_async( + cls, + customer: str, + transaction: str, + **params: Unpack["Customer.ModifyBalanceTransactionParams"] + ) -> "CustomerBalanceTransaction": + """ + Most credit balance transaction fields are immutable, but you may update its description and metadata. + """ + return cast( + "CustomerBalanceTransaction", + await cls._static_request_async( + "post", + "/v1/customers/{customer}/balance_transactions/{transaction}".format( + customer=sanitize_id(customer), + transaction=sanitize_id(transaction), + ), + params=params, + ), + ) + @classmethod def list_balance_transactions( cls, @@ -1864,6 +2311,26 @@ def list_balance_transactions( ), ) + @classmethod + async def list_balance_transactions_async( + cls, + customer: str, + **params: Unpack["Customer.ListBalanceTransactionsParams"] + ) -> ListObject["CustomerBalanceTransaction"]: + """ + Returns a list of transactions that updated the customer's [balances](https://stripe.com/docs/billing/customer/balance). + """ + return cast( + ListObject["CustomerBalanceTransaction"], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/balance_transactions".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def retrieve_cash_balance_transaction( cls, @@ -1886,6 +2353,28 @@ def retrieve_cash_balance_transaction( ), ) + @classmethod + async def retrieve_cash_balance_transaction_async( + cls, + customer: str, + transaction: str, + **params: Unpack["Customer.RetrieveCashBalanceTransactionParams"] + ) -> "CustomerCashBalanceTransaction": + """ + Retrieves a specific cash balance transaction, which updated the customer's [cash balance](https://stripe.com/docs/payments/customer-balance). + """ + return cast( + "CustomerCashBalanceTransaction", + await cls._static_request_async( + "get", + "/v1/customers/{customer}/cash_balance_transactions/{transaction}".format( + customer=sanitize_id(customer), + transaction=sanitize_id(transaction), + ), + params=params, + ), + ) + @classmethod def list_cash_balance_transactions( cls, @@ -1906,6 +2395,26 @@ def list_cash_balance_transactions( ), ) + @classmethod + async def list_cash_balance_transactions_async( + cls, + customer: str, + **params: Unpack["Customer.ListCashBalanceTransactionsParams"] + ) -> ListObject["CustomerCashBalanceTransaction"]: + """ + Returns a list of transactions that modified the customer's [cash balance](https://stripe.com/docs/payments/customer-balance). + """ + return cast( + ListObject["CustomerCashBalanceTransaction"], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/cash_balance_transactions".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def list_entitlements( cls, customer: str, **params: Unpack["Customer.ListEntitlementsParams"] @@ -1914,10 +2423,50 @@ def list_entitlements( Retrieve a list of entitlements for a customer """ return cast( - ListObject["CustomerEntitlement"], + ListObject["CustomerEntitlement"], + cls._static_request( + "get", + "/v1/customers/{customer}/entitlements".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + + @classmethod + async def list_entitlements_async( + cls, customer: str, **params: Unpack["Customer.ListEntitlementsParams"] + ) -> ListObject["CustomerEntitlement"]: + """ + Retrieve a list of entitlements for a customer + """ + return cast( + ListObject["CustomerEntitlement"], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/entitlements".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + + @classmethod + def create_source( + cls, customer: str, **params: Unpack["Customer.CreateSourceParams"] + ) -> Union["Account", "BankAccount", "Card", "Source"]: + """ + When you create a new credit card, you must specify a customer or recipient on which to create it. + + If the card's owner has no default card, then the new card will become the default. + However, if the owner already has a default, then it will not change. + To change the default, you should [update the customer](https://stripe.com/docs/api#update_customer) to have a new default_source. + """ + return cast( + Union["Account", "BankAccount", "Card", "Source"], cls._static_request( - "get", - "/v1/customers/{customer}/entitlements".format( + "post", + "/v1/customers/{customer}/sources".format( customer=sanitize_id(customer) ), params=params, @@ -1925,7 +2474,7 @@ def list_entitlements( ) @classmethod - def create_source( + async def create_source_async( cls, customer: str, **params: Unpack["Customer.CreateSourceParams"] ) -> Union["Account", "BankAccount", "Card", "Source"]: """ @@ -1937,7 +2486,7 @@ def create_source( """ return cast( Union["Account", "BankAccount", "Card", "Source"], - cls._static_request( + await cls._static_request_async( "post", "/v1/customers/{customer}/sources".format( customer=sanitize_id(customer) @@ -1967,6 +2516,27 @@ def retrieve_source( ), ) + @classmethod + async def retrieve_source_async( + cls, + customer: str, + id: str, + **params: Unpack["Customer.RetrieveSourceParams"] + ) -> Union["Account", "BankAccount", "Card", "Source"]: + """ + Retrieve a specified source for a given customer. + """ + return cast( + Union["Account", "BankAccount", "Card", "Source"], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/sources/{id}".format( + customer=sanitize_id(customer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def modify_source( cls, @@ -1988,6 +2558,27 @@ def modify_source( ), ) + @classmethod + async def modify_source_async( + cls, + customer: str, + id: str, + **params: Unpack["Customer.ModifySourceParams"] + ) -> Union["Account", "BankAccount", "Card", "Source"]: + """ + Update a specified source for a given customer. + """ + return cast( + Union["Account", "BankAccount", "Card", "Source"], + await cls._static_request_async( + "post", + "/v1/customers/{customer}/sources/{id}".format( + customer=sanitize_id(customer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def delete_source( cls, @@ -2009,6 +2600,27 @@ def delete_source( ), ) + @classmethod + async def delete_source_async( + cls, + customer: str, + id: str, + **params: Unpack["Customer.DeleteSourceParams"] + ) -> Union["Account", "BankAccount", "Card", "Source"]: + """ + Delete a specified source for a given customer. + """ + return cast( + Union["Account", "BankAccount", "Card", "Source"], + await cls._static_request_async( + "delete", + "/v1/customers/{customer}/sources/{id}".format( + customer=sanitize_id(customer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def list_sources( cls, customer: str, **params: Unpack["Customer.ListSourcesParams"] @@ -2027,6 +2639,24 @@ def list_sources( ), ) + @classmethod + async def list_sources_async( + cls, customer: str, **params: Unpack["Customer.ListSourcesParams"] + ) -> ListObject[Union["Account", "BankAccount", "Card", "Source"]]: + """ + List sources for a specified customer. + """ + return cast( + ListObject[Union["Account", "BankAccount", "Card", "Source"]], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/sources".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def create_tax_id( cls, customer: str, **params: Unpack["Customer.CreateTaxIdParams"] @@ -2045,6 +2675,24 @@ def create_tax_id( ), ) + @classmethod + async def create_tax_id_async( + cls, customer: str, **params: Unpack["Customer.CreateTaxIdParams"] + ) -> "TaxId": + """ + Creates a new tax_id object for a customer. + """ + return cast( + "TaxId", + await cls._static_request_async( + "post", + "/v1/customers/{customer}/tax_ids".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def retrieve_tax_id( cls, @@ -2066,6 +2714,27 @@ def retrieve_tax_id( ), ) + @classmethod + async def retrieve_tax_id_async( + cls, + customer: str, + id: str, + **params: Unpack["Customer.RetrieveTaxIdParams"] + ) -> "TaxId": + """ + Retrieves the tax_id object with the given identifier. + """ + return cast( + "TaxId", + await cls._static_request_async( + "get", + "/v1/customers/{customer}/tax_ids/{id}".format( + customer=sanitize_id(customer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def delete_tax_id( cls, @@ -2087,6 +2756,27 @@ def delete_tax_id( ), ) + @classmethod + async def delete_tax_id_async( + cls, + customer: str, + id: str, + **params: Unpack["Customer.DeleteTaxIdParams"] + ) -> "TaxId": + """ + Deletes an existing tax_id object. + """ + return cast( + "TaxId", + await cls._static_request_async( + "delete", + "/v1/customers/{customer}/tax_ids/{id}".format( + customer=sanitize_id(customer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def list_tax_ids( cls, customer: str, **params: Unpack["Customer.ListTaxIdsParams"] @@ -2105,6 +2795,24 @@ def list_tax_ids( ), ) + @classmethod + async def list_tax_ids_async( + cls, customer: str, **params: Unpack["Customer.ListTaxIdsParams"] + ) -> ListObject["TaxId"]: + """ + Returns a list of tax IDs for a customer. + """ + return cast( + ListObject["TaxId"], + await cls._static_request_async( + "get", + "/v1/customers/{customer}/tax_ids".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def modify_cash_balance( cls, @@ -2125,6 +2833,26 @@ def modify_cash_balance( ), ) + @classmethod + async def modify_cash_balance_async( + cls, + customer: str, + **params: Unpack["Customer.ModifyCashBalanceParams"] + ) -> "CashBalance": + """ + Changes the settings on a customer's cash balance. + """ + return cast( + "CashBalance", + await cls._static_request_async( + "post", + "/v1/customers/{customer}/cash_balance".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def retrieve_cash_balance( cls, @@ -2145,6 +2873,26 @@ def retrieve_cash_balance( ), ) + @classmethod + async def retrieve_cash_balance_async( + cls, + customer: str, + **params: Unpack["Customer.RetrieveCashBalanceParams"] + ) -> "CashBalance": + """ + Retrieves a customer's cash balance. + """ + return cast( + "CashBalance", + await cls._static_request_async( + "get", + "/v1/customers/{customer}/cash_balance".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + @classmethod def retrieve_entitlement_summary( cls, @@ -2165,6 +2913,26 @@ def retrieve_entitlement_summary( ), ) + @classmethod + async def retrieve_entitlement_summary_async( + cls, + customer: str, + **params: Unpack["Customer.RetrieveEntitlementSummaryParams"] + ) -> "CustomerEntitlementSummary": + """ + Retrieve the entitlement summary for a customer + """ + return cast( + "CustomerEntitlementSummary", + await cls._static_request_async( + "get", + "/v1/customers/{customer}/entitlement_summary".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + class TestHelpers(APIResourceTestHelpers["Customer"]): _resource_cls: Type["Customer"] @@ -2225,6 +2993,63 @@ def fund_cash_balance( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_fund_cash_balance_async( + cls, + customer: str, + **params: Unpack["Customer.FundCashBalanceParams"] + ) -> "CustomerCashBalanceTransaction": + """ + Create an incoming testmode bank transfer + """ + return cast( + "CustomerCashBalanceTransaction", + await cls._static_request_async( + "post", + "/v1/test_helpers/customers/{customer}/fund_cash_balance".format( + customer=sanitize_id(customer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def fund_cash_balance_async( + customer: str, **params: Unpack["Customer.FundCashBalanceParams"] + ) -> "CustomerCashBalanceTransaction": + """ + Create an incoming testmode bank transfer + """ + ... + + @overload + async def fund_cash_balance_async( + self, **params: Unpack["Customer.FundCashBalanceParams"] + ) -> "CustomerCashBalanceTransaction": + """ + Create an incoming testmode bank transfer + """ + ... + + @class_method_variant("_cls_fund_cash_balance_async") + async def fund_cash_balance_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Customer.FundCashBalanceParams"] + ) -> "CustomerCashBalanceTransaction": + """ + Create an incoming testmode bank transfer + """ + return cast( + "CustomerCashBalanceTransaction", + await self.resource._request_async( + "post", + "/v1/test_helpers/customers/{customer}/fund_cash_balance".format( + customer=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/_customer_cash_balance_transaction.py b/stripe/_customer_cash_balance_transaction.py index 32cce2e4e..56a8e83c7 100644 --- a/stripe/_customer_cash_balance_transaction.py +++ b/stripe/_customer_cash_balance_transaction.py @@ -243,6 +243,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CustomerCashBalanceTransaction.ListParams"] + ) -> ListObject["CustomerCashBalanceTransaction"]: + """ + Returns a list of transactions that modified the customer's [cash balance](https://stripe.com/docs/payments/customer-balance). + """ + 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, @@ -256,6 +277,19 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, + id: str, + **params: Unpack["CustomerCashBalanceTransaction.RetrieveParams"] + ) -> "CustomerCashBalanceTransaction": + """ + Retrieves a specific cash balance transaction, which updated the customer's [cash balance](https://stripe.com/docs/payments/customer-balance). + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "adjusted_for_overdraft": AdjustedForOverdraft, "applied_to_payment": AppliedToPayment, diff --git a/stripe/_customer_entitlement.py b/stripe/_customer_entitlement.py index 7f8b2635a..586c5bd17 100644 --- a/stripe/_customer_entitlement.py +++ b/stripe/_customer_entitlement.py @@ -91,4 +91,25 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CustomerEntitlement.ListParams"] + ) -> ListObject["CustomerEntitlement"]: + """ + Retrieve a list of entitlements for a customer + """ + 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 + _inner_class_types = {"quantity": Quantity} diff --git a/stripe/_customer_entitlement_summary.py b/stripe/_customer_entitlement_summary.py index c87e9a004..ff4bf991a 100644 --- a/stripe/_customer_entitlement_summary.py +++ b/stripe/_customer_entitlement_summary.py @@ -54,3 +54,16 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, + id: str, + **params: Unpack["CustomerEntitlementSummary.RetrieveParams"] + ) -> "CustomerEntitlementSummary": + """ + Retrieve the entitlement summary for a customer + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_customer_session.py b/stripe/_customer_session.py index 7e7eb26d4..9f98297b5 100644 --- a/stripe/_customer_session.py +++ b/stripe/_customer_session.py @@ -210,4 +210,20 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["CustomerSession.CreateParams"] + ) -> "CustomerSession": + """ + Creates a customer session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources. + """ + return cast( + "CustomerSession", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + _inner_class_types = {"components": Components} diff --git a/stripe/_dispute.py b/stripe/_dispute.py index 0e90b210d..e1e93a129 100644 --- a/stripe/_dispute.py +++ b/stripe/_dispute.py @@ -857,6 +857,69 @@ def close( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_close_async( + cls, dispute: str, **params: Unpack["Dispute.CloseParams"] + ) -> "Dispute": + """ + Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost. + + The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible. + """ + return cast( + "Dispute", + await cls._static_request_async( + "post", + "/v1/disputes/{dispute}/close".format( + dispute=sanitize_id(dispute) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def close_async( + dispute: str, **params: Unpack["Dispute.CloseParams"] + ) -> "Dispute": + """ + Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost. + + The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible. + """ + ... + + @overload + async def close_async( + self, **params: Unpack["Dispute.CloseParams"] + ) -> "Dispute": + """ + Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost. + + The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible. + """ + ... + + @class_method_variant("_cls_close_async") + async def close_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Dispute.CloseParams"] + ) -> "Dispute": + """ + Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute, acknowledging it as lost. + + The status of the dispute will change from needs_response to lost. Closing a dispute is irreversible. + """ + return cast( + "Dispute", + await self._request_async( + "post", + "/v1/disputes/{dispute}/close".format( + dispute=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Dispute.ListParams"] @@ -878,6 +941,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Dispute.ListParams"] + ) -> ListObject["Dispute"]: + """ + Returns a list of your disputes. + """ + 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["Dispute.ModifyParams"] @@ -897,6 +981,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Dispute.ModifyParams"] + ) -> "Dispute": + """ + When you get a dispute, contacting your customer is always the best first step. If that doesn't work, you can submit evidence to help us resolve the dispute in your favor. You can do this in your [dashboard](https://dashboard.stripe.com/disputes), but if you prefer, you can use the API to submit evidence programmatically. + + Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. To figure out which evidence fields to provide, see our [guide to dispute types](https://stripe.com/docs/disputes/categories). + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Dispute", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Dispute.RetrieveParams"] @@ -908,6 +1011,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Dispute.RetrieveParams"] + ) -> "Dispute": + """ + Retrieves the dispute with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "evidence": Evidence, "evidence_details": EvidenceDetails, diff --git a/stripe/_ephemeral_key.py b/stripe/_ephemeral_key.py index 8717ce371..09ae3f3b2 100644 --- a/stripe/_ephemeral_key.py +++ b/stripe/_ephemeral_key.py @@ -90,6 +90,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["EphemeralKey.DeleteParams"] + ) -> "EphemeralKey": + """ + Invalidates a short-lived API key for a given resource. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "EphemeralKey", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["EphemeralKey.DeleteParams"] + ) -> "EphemeralKey": + """ + Invalidates a short-lived API key for a given resource. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["EphemeralKey.DeleteParams"] + ) -> "EphemeralKey": + """ + Invalidates a short-lived API key for a given resource. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["EphemeralKey.DeleteParams"] + ) -> "EphemeralKey": + """ + Invalidates a short-lived API key for a given resource. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def create(cls, **params): if params.get("stripe_version") is None: diff --git a/stripe/_event.py b/stripe/_event.py index 46662ea7f..1cf3be3c6 100644 --- a/stripe/_event.py +++ b/stripe/_event.py @@ -490,6 +490,27 @@ def list(cls, **params: Unpack["Event.ListParams"]) -> ListObject["Event"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Event.ListParams"] + ) -> ListObject["Event"]: + """ + List events, going back up to 30 days. Each event data is rendered according to Stripe API version at its creation time, specified in [event object](https://stripe.com/docs/api/events/object) api_version attribute (not according to your current Stripe API version or Stripe-Version header). + """ + 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["Event.RetrieveParams"] @@ -501,4 +522,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Event.RetrieveParams"] + ) -> "Event": + """ + Retrieves the details of an event. Supply the unique identifier of the event, which you might have received in a webhook. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"data": Data, "reason": Reason, "request": Request} diff --git a/stripe/_exchange_rate.py b/stripe/_exchange_rate.py index 2d00d42d0..80bece0ef 100644 --- a/stripe/_exchange_rate.py +++ b/stripe/_exchange_rate.py @@ -97,6 +97,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ExchangeRate.ListParams"] + ) -> ListObject["ExchangeRate"]: + """ + Returns a list of objects that contain the rates at which foreign currencies are converted to one another. Only shows the currencies for which Stripe supports. + """ + 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["ExchangeRate.RetrieveParams"] @@ -107,3 +128,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ExchangeRate.RetrieveParams"] + ) -> "ExchangeRate": + """ + Retrieves the exchange rates from the given currency to every supported currency. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_file.py b/stripe/_file.py index 37af1bbcd..381e71716 100644 --- a/stripe/_file.py +++ b/stripe/_file.py @@ -201,6 +201,26 @@ def create(cls, **params: Unpack["File.CreateParams"]) -> "File": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["File.CreateParams"] + ) -> "File": + """ + To upload a file to Stripe, you need to send a request of type multipart/form-data. Include the file you want to upload in the request, and the parameters for creating a file. + + All of Stripe's officially supported Client libraries support sending multipart/form-data. + """ + return cast( + "File", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + base_address="files", + api_mode="V1FILES", + ), + ) + @classmethod def list(cls, **params: Unpack["File.ListParams"]) -> ListObject["File"]: """ @@ -220,6 +240,27 @@ def list(cls, **params: Unpack["File.ListParams"]) -> ListObject["File"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["File.ListParams"] + ) -> ListObject["File"]: + """ + Returns a list of the files that your account has access to. Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top. + """ + 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["File.RetrieveParams"] @@ -231,6 +272,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["File.RetrieveParams"] + ) -> "File": + """ + Retrieves the details of an existing file object. After you supply a unique file ID, Stripe returns the corresponding file object. Learn how to [access file contents](https://stripe.com/docs/file-upload#download-file-contents). + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + # This resource can have two different object names. In latter API # versions, only `file` is used, but since stripe-python may be used with # any API version, we need to support deserializing the older diff --git a/stripe/_file_link.py b/stripe/_file_link.py index d4bb91f91..e90229a09 100644 --- a/stripe/_file_link.py +++ b/stripe/_file_link.py @@ -167,6 +167,22 @@ def create(cls, **params: Unpack["FileLink.CreateParams"]) -> "FileLink": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["FileLink.CreateParams"] + ) -> "FileLink": + """ + Creates a new file link object. + """ + return cast( + "FileLink", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["FileLink.ListParams"] @@ -188,6 +204,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["FileLink.ListParams"] + ) -> ListObject["FileLink"]: + """ + Returns a list of file links. + """ + 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["FileLink.ModifyParams"] @@ -205,6 +242,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["FileLink.ModifyParams"] + ) -> "FileLink": + """ + Updates an existing file link object. Expired links can no longer be updated. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "FileLink", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["FileLink.RetrieveParams"] @@ -215,3 +269,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["FileLink.RetrieveParams"] + ) -> "FileLink": + """ + Retrieves the file link with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_invoice.py b/stripe/_invoice.py index b58d1c369..02f293081 100644 --- a/stripe/_invoice.py +++ b/stripe/_invoice.py @@ -13,6 +13,7 @@ from stripe._updateable_api_resource import UpdateableAPIResource from stripe._util import class_method_variant, sanitize_id from typing import ( + AsyncIterator, ClassVar, Dict, Iterator, @@ -9059,6 +9060,95 @@ def attach_payment_intent( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_attach_payment_intent_async( + cls, + invoice: str, + **params: Unpack["Invoice.AttachPaymentIntentParams"] + ) -> "Invoice": + """ + Attaches a PaymentIntent to the invoice, adding it to the list of payments. + When the PaymentIntent's status changes to succeeded, the payment is credited + to the invoice, increasing its amount_paid. When the invoice is fully paid, the + invoice's status becomes paid. + + If the PaymentIntent's status is already succeeded when it is attached, it is + credited to the invoice immediately. + + Related guide: [Create an invoice payment](https://stripe.com/docs/invoicing/payments/create) + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + "/v1/invoices/{invoice}/attach_payment_intent".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def attach_payment_intent_async( + invoice: str, **params: Unpack["Invoice.AttachPaymentIntentParams"] + ) -> "Invoice": + """ + Attaches a PaymentIntent to the invoice, adding it to the list of payments. + When the PaymentIntent's status changes to succeeded, the payment is credited + to the invoice, increasing its amount_paid. When the invoice is fully paid, the + invoice's status becomes paid. + + If the PaymentIntent's status is already succeeded when it is attached, it is + credited to the invoice immediately. + + Related guide: [Create an invoice payment](https://stripe.com/docs/invoicing/payments/create) + """ + ... + + @overload + async def attach_payment_intent_async( + self, **params: Unpack["Invoice.AttachPaymentIntentParams"] + ) -> "Invoice": + """ + Attaches a PaymentIntent to the invoice, adding it to the list of payments. + When the PaymentIntent's status changes to succeeded, the payment is credited + to the invoice, increasing its amount_paid. When the invoice is fully paid, the + invoice's status becomes paid. + + If the PaymentIntent's status is already succeeded when it is attached, it is + credited to the invoice immediately. + + Related guide: [Create an invoice payment](https://stripe.com/docs/invoicing/payments/create) + """ + ... + + @class_method_variant("_cls_attach_payment_intent_async") + async def attach_payment_intent_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.AttachPaymentIntentParams"] + ) -> "Invoice": + """ + Attaches a PaymentIntent to the invoice, adding it to the list of payments. + When the PaymentIntent's status changes to succeeded, the payment is credited + to the invoice, increasing its amount_paid. When the invoice is fully paid, the + invoice's status becomes paid. + + If the PaymentIntent's status is already succeeded when it is attached, it is + credited to the invoice immediately. + + Related guide: [Create an invoice payment](https://stripe.com/docs/invoicing/payments/create) + """ + return cast( + "Invoice", + await self._request_async( + "post", + "/v1/invoices/{invoice}/attach_payment_intent".format( + invoice=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Invoice.CreateParams"]) -> "Invoice": """ @@ -9073,6 +9163,22 @@ def create(cls, **params: Unpack["Invoice.CreateParams"]) -> "Invoice": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Invoice.CreateParams"] + ) -> "Invoice": + """ + This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers. + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def create_preview( cls, **params: Unpack["Invoice.CreatePreviewParams"] @@ -9093,6 +9199,26 @@ def create_preview( ), ) + @classmethod + async def create_preview_async( + cls, **params: Unpack["Invoice.CreatePreviewParams"] + ) -> "Invoice": + """ + At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. + + Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount. + + You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource. + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + "/v1/invoices/create_preview", + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Invoice.DeleteParams"] @@ -9140,6 +9266,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Invoice.DeleteParams"] + ) -> "Invoice": + """ + Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Invoice", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Invoice.DeleteParams"] + ) -> "Invoice": + """ + Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Invoice.DeleteParams"] + ) -> "Invoice": + """ + Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.DeleteParams"] + ) -> "Invoice": + """ + Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def _cls_finalize_invoice( cls, invoice: str, **params: Unpack["Invoice.FinalizeInvoiceParams"] @@ -9195,6 +9370,61 @@ def finalize_invoice( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_finalize_invoice_async( + cls, invoice: str, **params: Unpack["Invoice.FinalizeInvoiceParams"] + ) -> "Invoice": + """ + Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + "/v1/invoices/{invoice}/finalize".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def finalize_invoice_async( + invoice: str, **params: Unpack["Invoice.FinalizeInvoiceParams"] + ) -> "Invoice": + """ + Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + """ + ... + + @overload + async def finalize_invoice_async( + self, **params: Unpack["Invoice.FinalizeInvoiceParams"] + ) -> "Invoice": + """ + Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + """ + ... + + @class_method_variant("_cls_finalize_invoice_async") + async def finalize_invoice_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.FinalizeInvoiceParams"] + ) -> "Invoice": + """ + Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + """ + return cast( + "Invoice", + await self._request_async( + "post", + "/v1/invoices/{invoice}/finalize".format( + invoice=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Invoice.ListParams"] @@ -9217,17 +9447,192 @@ def list( return result @classmethod - def _cls_mark_uncollectible( - cls, invoice: str, **params: Unpack["Invoice.MarkUncollectibleParams"] + async def list_async( + cls, **params: Unpack["Invoice.ListParams"] + ) -> ListObject["Invoice"]: + """ + You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first. + """ + 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 _cls_mark_uncollectible( + cls, invoice: str, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + return cast( + "Invoice", + cls._static_request( + "post", + "/v1/invoices/{invoice}/mark_uncollectible".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + + @overload + @staticmethod + def mark_uncollectible( + invoice: str, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + ... + + @overload + def mark_uncollectible( + self, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + ... + + @class_method_variant("_cls_mark_uncollectible") + def mark_uncollectible( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + return cast( + "Invoice", + self._request( + "post", + "/v1/invoices/{invoice}/mark_uncollectible".format( + invoice=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + async def _cls_mark_uncollectible_async( + cls, invoice: str, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + "/v1/invoices/{invoice}/mark_uncollectible".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def mark_uncollectible_async( + invoice: str, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + ... + + @overload + async def mark_uncollectible_async( + self, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + ... + + @class_method_variant("_cls_mark_uncollectible_async") + async def mark_uncollectible_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.MarkUncollectibleParams"] + ) -> "Invoice": + """ + Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + """ + return cast( + "Invoice", + await self._request_async( + "post", + "/v1/invoices/{invoice}/mark_uncollectible".format( + invoice=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + def modify( + cls, id: str, **params: Unpack["Invoice.ModifyParams"] + ) -> "Invoice": + """ + Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), + monetary values, as well as collection_method, become uneditable. + + If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, + sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass + auto_advance=false. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Invoice", + cls._static_request( + "post", + url, + params=params, + ), + ) + + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Invoice.ModifyParams"] + ) -> "Invoice": + """ + Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), + monetary values, as well as collection_method, become uneditable. + + If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, + sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass + auto_advance=false. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Invoice", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + + @classmethod + def _cls_pay( + cls, invoice: str, **params: Unpack["Invoice.PayParams"] ) -> "Invoice": """ - Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. """ return cast( "Invoice", cls._static_request( "post", - "/v1/invoices/{invoice}/mark_uncollectible".format( + "/v1/invoices/{invoice}/pay".format( invoice=sanitize_id(invoice) ), params=params, @@ -9236,35 +9641,31 @@ def _cls_mark_uncollectible( @overload @staticmethod - def mark_uncollectible( - invoice: str, **params: Unpack["Invoice.MarkUncollectibleParams"] - ) -> "Invoice": + def pay(invoice: str, **params: Unpack["Invoice.PayParams"]) -> "Invoice": """ - Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. """ ... @overload - def mark_uncollectible( - self, **params: Unpack["Invoice.MarkUncollectibleParams"] - ) -> "Invoice": + def pay(self, **params: Unpack["Invoice.PayParams"]) -> "Invoice": """ - Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. """ ... - @class_method_variant("_cls_mark_uncollectible") - def mark_uncollectible( # pyright: ignore[reportGeneralTypeIssues] - self, **params: Unpack["Invoice.MarkUncollectibleParams"] + @class_method_variant("_cls_pay") + def pay( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.PayParams"] ) -> "Invoice": """ - Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. """ return cast( "Invoice", self._request( "post", - "/v1/invoices/{invoice}/mark_uncollectible".format( + "/v1/invoices/{invoice}/pay".format( invoice=sanitize_id(self.get("id")) ), params=params, @@ -9272,29 +9673,7 @@ def mark_uncollectible( # pyright: ignore[reportGeneralTypeIssues] ) @classmethod - def modify( - cls, id: str, **params: Unpack["Invoice.ModifyParams"] - ) -> "Invoice": - """ - Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), - monetary values, as well as collection_method, become uneditable. - - If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, - sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass - auto_advance=false. - """ - url = "%s/%s" % (cls.class_url(), sanitize_id(id)) - return cast( - "Invoice", - cls._static_request( - "post", - url, - params=params, - ), - ) - - @classmethod - def _cls_pay( + async def _cls_pay_async( cls, invoice: str, **params: Unpack["Invoice.PayParams"] ) -> "Invoice": """ @@ -9302,7 +9681,7 @@ def _cls_pay( """ return cast( "Invoice", - cls._static_request( + await cls._static_request_async( "post", "/v1/invoices/{invoice}/pay".format( invoice=sanitize_id(invoice) @@ -9313,21 +9692,25 @@ def _cls_pay( @overload @staticmethod - def pay(invoice: str, **params: Unpack["Invoice.PayParams"]) -> "Invoice": + async def pay_async( + invoice: str, **params: Unpack["Invoice.PayParams"] + ) -> "Invoice": """ Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. """ ... @overload - def pay(self, **params: Unpack["Invoice.PayParams"]) -> "Invoice": + async def pay_async( + self, **params: Unpack["Invoice.PayParams"] + ) -> "Invoice": """ Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. """ ... - @class_method_variant("_cls_pay") - def pay( # pyright: ignore[reportGeneralTypeIssues] + @class_method_variant("_cls_pay_async") + async def pay_async( # pyright: ignore[reportGeneralTypeIssues] self, **params: Unpack["Invoice.PayParams"] ) -> "Invoice": """ @@ -9335,7 +9718,7 @@ def pay( # pyright: ignore[reportGeneralTypeIssues] """ return cast( "Invoice", - self._request( + await self._request_async( "post", "/v1/invoices/{invoice}/pay".format( invoice=sanitize_id(self.get("id")) @@ -9355,6 +9738,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Invoice.RetrieveParams"] + ) -> "Invoice": + """ + Retrieves the invoice with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_send_invoice( cls, invoice: str, **params: Unpack["Invoice.SendInvoiceParams"] @@ -9418,6 +9812,69 @@ def send_invoice( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_send_invoice_async( + cls, invoice: str, **params: Unpack["Invoice.SendInvoiceParams"] + ) -> "Invoice": + """ + Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. + + Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + "/v1/invoices/{invoice}/send".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def send_invoice_async( + invoice: str, **params: Unpack["Invoice.SendInvoiceParams"] + ) -> "Invoice": + """ + Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. + + Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + """ + ... + + @overload + async def send_invoice_async( + self, **params: Unpack["Invoice.SendInvoiceParams"] + ) -> "Invoice": + """ + Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. + + Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + """ + ... + + @class_method_variant("_cls_send_invoice_async") + async def send_invoice_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.SendInvoiceParams"] + ) -> "Invoice": + """ + Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. + + Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + """ + return cast( + "Invoice", + await self._request_async( + "post", + "/v1/invoices/{invoice}/send".format( + invoice=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def upcoming(cls, **params: Unpack["Invoice.UpcomingParams"]) -> "Invoice": """ @@ -9436,6 +9893,26 @@ def upcoming(cls, **params: Unpack["Invoice.UpcomingParams"]) -> "Invoice": ), ) + @classmethod + async def upcoming_async( + cls, **params: Unpack["Invoice.UpcomingParams"] + ) -> "Invoice": + """ + At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. + + Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount. + + You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource. + """ + return cast( + "Invoice", + await cls._static_request_async( + "get", + "/v1/invoices/upcoming", + params=params, + ), + ) + @classmethod def upcoming_lines( cls, **params: Unpack["Invoice.UpcomingLinesParams"] @@ -9452,6 +9929,22 @@ def upcoming_lines( ), ) + @classmethod + async def upcoming_lines_async( + cls, **params: Unpack["Invoice.UpcomingLinesParams"] + ) -> ListObject["InvoiceLineItem"]: + """ + When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["InvoiceLineItem"], + await cls._static_request_async( + "get", + "/v1/invoices/upcoming/lines", + params=params, + ), + ) + @classmethod def _cls_void_invoice( cls, invoice: str, **params: Unpack["Invoice.VoidInvoiceParams"] @@ -9507,6 +10000,61 @@ def void_invoice( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_void_invoice_async( + cls, invoice: str, **params: Unpack["Invoice.VoidInvoiceParams"] + ) -> "Invoice": + """ + Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + """ + return cast( + "Invoice", + await cls._static_request_async( + "post", + "/v1/invoices/{invoice}/void".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def void_invoice_async( + invoice: str, **params: Unpack["Invoice.VoidInvoiceParams"] + ) -> "Invoice": + """ + Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + """ + ... + + @overload + async def void_invoice_async( + self, **params: Unpack["Invoice.VoidInvoiceParams"] + ) -> "Invoice": + """ + Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + """ + ... + + @class_method_variant("_cls_void_invoice_async") + async def void_invoice_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Invoice.VoidInvoiceParams"] + ) -> "Invoice": + """ + Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + """ + return cast( + "Invoice", + await self._request_async( + "post", + "/v1/invoices/{invoice}/void".format( + invoice=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def search( cls, *args, **kwargs: Unpack["Invoice.SearchParams"] @@ -9519,11 +10067,33 @@ def search( """ return cls._search(search_url="/v1/invoices/search", *args, **kwargs) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["Invoice.SearchParams"] + ) -> SearchResultObject["Invoice"]: + """ + Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/invoices/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["Invoice.SearchParams"] ) -> Iterator["Invoice"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["Invoice.SearchParams"] + ) -> AsyncIterator["Invoice"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() @classmethod def retrieve_payment( @@ -9547,6 +10117,28 @@ def retrieve_payment( ), ) + @classmethod + async def retrieve_payment_async( + cls, + invoice: str, + invoice_payment: str, + **params: Unpack["Invoice.RetrievePaymentParams"] + ) -> "InvoicePayment": + """ + Retrieves the invoice payment with the given ID. + """ + return cast( + "InvoicePayment", + await cls._static_request_async( + "get", + "/v1/invoices/{invoice}/payments/{invoice_payment}".format( + invoice=sanitize_id(invoice), + invoice_payment=sanitize_id(invoice_payment), + ), + params=params, + ), + ) + @classmethod def list_payments( cls, invoice: str, **params: Unpack["Invoice.ListPaymentsParams"] @@ -9565,6 +10157,24 @@ def list_payments( ), ) + @classmethod + async def list_payments_async( + cls, invoice: str, **params: Unpack["Invoice.ListPaymentsParams"] + ) -> ListObject["InvoicePayment"]: + """ + When retrieving an invoice, there is an includable payments property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of payments. + """ + return cast( + ListObject["InvoicePayment"], + await cls._static_request_async( + "get", + "/v1/invoices/{invoice}/payments".format( + invoice=sanitize_id(invoice) + ), + params=params, + ), + ) + _inner_class_types = { "amounts_due": AmountsDue, "automatic_tax": AutomaticTax, diff --git a/stripe/_invoice_item.py b/stripe/_invoice_item.py index 51b28ae50..6c4221853 100644 --- a/stripe/_invoice_item.py +++ b/stripe/_invoice_item.py @@ -542,6 +542,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["InvoiceItem.CreateParams"] + ) -> "InvoiceItem": + """ + Creates an item to be added to a draft invoice (up to 250 items per invoice). If no invoice is specified, the item will be on the next invoice created for the customer specified. + """ + return cast( + "InvoiceItem", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["InvoiceItem.DeleteParams"] @@ -591,6 +607,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["InvoiceItem.DeleteParams"] + ) -> "InvoiceItem": + """ + Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "InvoiceItem", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["InvoiceItem.DeleteParams"] + ) -> "InvoiceItem": + """ + Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["InvoiceItem.DeleteParams"] + ) -> "InvoiceItem": + """ + Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["InvoiceItem.DeleteParams"] + ) -> "InvoiceItem": + """ + Deletes an invoice item, removing it from an invoice. Deleting invoice items is only possible when they're not attached to invoices, or if it's attached to a draft invoice. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["InvoiceItem.ListParams"] @@ -612,6 +677,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["InvoiceItem.ListParams"] + ) -> ListObject["InvoiceItem"]: + """ + Returns a list of your invoice items. Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first. + """ + 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["InvoiceItem.ModifyParams"] @@ -629,6 +715,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["InvoiceItem.ModifyParams"] + ) -> "InvoiceItem": + """ + Updates the amount or description of an invoice item on an upcoming invoice. Updating an invoice item is only possible before the invoice it's attached to is closed. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "InvoiceItem", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["InvoiceItem.RetrieveParams"] @@ -640,4 +743,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["InvoiceItem.RetrieveParams"] + ) -> "InvoiceItem": + """ + Retrieves the invoice item with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"period": Period} diff --git a/stripe/_invoice_payment.py b/stripe/_invoice_payment.py index 9b0f4e4f1..e467fb31f 100644 --- a/stripe/_invoice_payment.py +++ b/stripe/_invoice_payment.py @@ -130,6 +130,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["InvoicePayment.ListParams"] + ) -> ListObject["InvoicePayment"]: + """ + When retrieving an invoice, there is an includable payments property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of payments. + """ + 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["InvoicePayment.RetrieveParams"] @@ -141,4 +162,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["InvoicePayment.RetrieveParams"] + ) -> "InvoicePayment": + """ + Retrieves the invoice payment with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"status_transitions": StatusTransitions} diff --git a/stripe/_mandate.py b/stripe/_mandate.py index a3ea85b2c..3c65094e3 100644 --- a/stripe/_mandate.py +++ b/stripe/_mandate.py @@ -229,6 +229,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Mandate.RetrieveParams"] + ) -> "Mandate": + """ + Retrieves a Mandate object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "customer_acceptance": CustomerAcceptance, "multi_use": MultiUse, diff --git a/stripe/_margin.py b/stripe/_margin.py index 001569fd9..1b1008ec8 100644 --- a/stripe/_margin.py +++ b/stripe/_margin.py @@ -141,6 +141,22 @@ def create(cls, **params: Unpack["Margin.CreateParams"]) -> "Margin": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Margin.CreateParams"] + ) -> "Margin": + """ + Create a margin object to be used with invoices, invoice items, and invoice line items for a customer to represent a partner discount.A margin has a percent_off which is the percent that will be taken off the subtotal after all items and other discounts and promotions) of any invoices for a customer. Calculation of prorations do not include any partner margins applied on the original invoice item. + """ + return cast( + "Margin", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Margin.ListParams"] @@ -162,6 +178,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Margin.ListParams"] + ) -> ListObject["Margin"]: + """ + Retrieve a list of your margins. + """ + 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["Margin.ModifyParams"] @@ -179,6 +216,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Margin.ModifyParams"] + ) -> "Margin": + """ + Update the specified margin object. Certain fields of the margin object are not editable. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Margin", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Margin.RetrieveParams"] @@ -190,6 +244,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Margin.RetrieveParams"] + ) -> "Margin": + """ + Retrieve a margin object with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/billing/margins" diff --git a/stripe/_order.py b/stripe/_order.py index 3d3937ca0..39391f330 100644 --- a/stripe/_order.py +++ b/stripe/_order.py @@ -3214,6 +3214,59 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, id: str, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels the order as well as the payment intent if one is attached. + """ + return cast( + "Order", + await cls._static_request_async( + "post", + "/v1/orders/{id}/cancel".format(id=sanitize_id(id)), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + id: str, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels the order as well as the payment intent if one is attached. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels the order as well as the payment intent if one is attached. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels the order as well as the payment intent if one is attached. + """ + return cast( + "Order", + await self._request_async( + "post", + "/v1/orders/{id}/cancel".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Order.CreateParams"]) -> "Order": """ @@ -3228,6 +3281,22 @@ def create(cls, **params: Unpack["Order.CreateParams"]) -> "Order": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Order.CreateParams"] + ) -> "Order": + """ + Creates a new open order object. + """ + return cast( + "Order", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Order.ListParams"]) -> ListObject["Order"]: """ @@ -3247,6 +3316,27 @@ def list(cls, **params: Unpack["Order.ListParams"]) -> ListObject["Order"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Order.ListParams"] + ) -> ListObject["Order"]: + """ + Returns a list of your orders. The orders are returned sorted by creation date, with the most recently created orders appearing first. + """ + 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 _cls_list_line_items( cls, id: str, **params: Unpack["Order.ListLineItemsParams"] @@ -3300,6 +3390,59 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, id: str, **params: Unpack["Order.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving an order, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await cls._static_request_async( + "get", + "/v1/orders/{id}/line_items".format(id=sanitize_id(id)), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + id: str, **params: Unpack["Order.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving an order, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["Order.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving an order, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Order.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving an order, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await self._request_async( + "get", + "/v1/orders/{id}/line_items".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def modify( cls, id: str, **params: Unpack["Order.ModifyParams"] @@ -3317,6 +3460,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Order.ModifyParams"] + ) -> "Order": + """ + Updates the specific order by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Order", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def _cls_reopen( cls, id: str, **params: Unpack["Order.ReopenParams"] @@ -3366,6 +3526,59 @@ def reopen( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_reopen_async( + cls, id: str, **params: Unpack["Order.ReopenParams"] + ) -> "Order": + """ + Reopens a submitted order. + """ + return cast( + "Order", + await cls._static_request_async( + "post", + "/v1/orders/{id}/reopen".format(id=sanitize_id(id)), + params=params, + ), + ) + + @overload + @staticmethod + async def reopen_async( + id: str, **params: Unpack["Order.ReopenParams"] + ) -> "Order": + """ + Reopens a submitted order. + """ + ... + + @overload + async def reopen_async( + self, **params: Unpack["Order.ReopenParams"] + ) -> "Order": + """ + Reopens a submitted order. + """ + ... + + @class_method_variant("_cls_reopen_async") + async def reopen_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Order.ReopenParams"] + ) -> "Order": + """ + Reopens a submitted order. + """ + return cast( + "Order", + await self._request_async( + "post", + "/v1/orders/{id}/reopen".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Order.RetrieveParams"] @@ -3377,6 +3590,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Order.RetrieveParams"] + ) -> "Order": + """ + Retrieves the details of an existing order. Supply the unique order ID from either an order creation request or the order list, and Stripe will return the corresponding order information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_submit( cls, id: str, **params: Unpack["Order.SubmitParams"] @@ -3426,6 +3650,59 @@ def submit( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_submit_async( + cls, id: str, **params: Unpack["Order.SubmitParams"] + ) -> "Order": + """ + Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](https://stripe.com/docs/api#reopen_order) method is called. + """ + return cast( + "Order", + await cls._static_request_async( + "post", + "/v1/orders/{id}/submit".format(id=sanitize_id(id)), + params=params, + ), + ) + + @overload + @staticmethod + async def submit_async( + id: str, **params: Unpack["Order.SubmitParams"] + ) -> "Order": + """ + Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](https://stripe.com/docs/api#reopen_order) method is called. + """ + ... + + @overload + async def submit_async( + self, **params: Unpack["Order.SubmitParams"] + ) -> "Order": + """ + Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](https://stripe.com/docs/api#reopen_order) method is called. + """ + ... + + @class_method_variant("_cls_submit_async") + async def submit_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Order.SubmitParams"] + ) -> "Order": + """ + Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](https://stripe.com/docs/api#reopen_order) method is called. + """ + return cast( + "Order", + await self._request_async( + "post", + "/v1/orders/{id}/submit".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + _inner_class_types = { "automatic_tax": AutomaticTax, "billing_details": BillingDetails, diff --git a/stripe/_payment_intent.py b/stripe/_payment_intent.py index 6b2b8b822..61676c184 100644 --- a/stripe/_payment_intent.py +++ b/stripe/_payment_intent.py @@ -12,6 +12,7 @@ from stripe._util import class_method_variant, sanitize_id from typing import ( Any, + AsyncIterator, ClassVar, Dict, Iterator, @@ -11073,6 +11074,64 @@ def apply_customer_balance( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_apply_customer_balance_async( + cls, + intent: str, + **params: Unpack["PaymentIntent.ApplyCustomerBalanceParams"] + ) -> "PaymentIntent": + """ + Manually reconcile the remaining amount for a customer_balance PaymentIntent. + """ + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + "/v1/payment_intents/{intent}/apply_customer_balance".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def apply_customer_balance_async( + intent: str, + **params: Unpack["PaymentIntent.ApplyCustomerBalanceParams"] + ) -> "PaymentIntent": + """ + Manually reconcile the remaining amount for a customer_balance PaymentIntent. + """ + ... + + @overload + async def apply_customer_balance_async( + self, **params: Unpack["PaymentIntent.ApplyCustomerBalanceParams"] + ) -> "PaymentIntent": + """ + Manually reconcile the remaining amount for a customer_balance PaymentIntent. + """ + ... + + @class_method_variant("_cls_apply_customer_balance_async") + async def apply_customer_balance_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentIntent.ApplyCustomerBalanceParams"] + ) -> "PaymentIntent": + """ + Manually reconcile the remaining amount for a customer_balance PaymentIntent. + """ + return cast( + "PaymentIntent", + await self._request_async( + "post", + "/v1/payment_intents/{intent}/apply_customer_balance".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_cancel( cls, intent: str, **params: Unpack["PaymentIntent.CancelParams"] @@ -11144,6 +11203,77 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, intent: str, **params: Unpack["PaymentIntent.CancelParams"] + ) -> "PaymentIntent": + """ + You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. + + After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. + + You can't cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. + """ + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + "/v1/payment_intents/{intent}/cancel".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + intent: str, **params: Unpack["PaymentIntent.CancelParams"] + ) -> "PaymentIntent": + """ + You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. + + After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. + + You can't cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["PaymentIntent.CancelParams"] + ) -> "PaymentIntent": + """ + You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. + + After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. + + You can't cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentIntent.CancelParams"] + ) -> "PaymentIntent": + """ + You can cancel a PaymentIntent object when it's in one of these statuses: requires_payment_method, requires_capture, requires_confirmation, requires_action or, [in rare cases](https://stripe.com/docs/payments/intents), processing. + + After it's canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. For PaymentIntents with a status of requires_capture, the remaining amount_capturable is automatically refunded. + + You can't cancel the PaymentIntent for a Checkout Session. [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. + """ + return cast( + "PaymentIntent", + await self._request_async( + "post", + "/v1/payment_intents/{intent}/cancel".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_capture( cls, intent: str, **params: Unpack["PaymentIntent.CaptureParams"] @@ -11215,6 +11345,77 @@ def capture( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_capture_async( + cls, intent: str, **params: Unpack["PaymentIntent.CaptureParams"] + ) -> "PaymentIntent": + """ + Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. + + Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. + + Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). + """ + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + "/v1/payment_intents/{intent}/capture".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def capture_async( + intent: str, **params: Unpack["PaymentIntent.CaptureParams"] + ) -> "PaymentIntent": + """ + Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. + + Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. + + Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). + """ + ... + + @overload + async def capture_async( + self, **params: Unpack["PaymentIntent.CaptureParams"] + ) -> "PaymentIntent": + """ + Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. + + Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. + + Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). + """ + ... + + @class_method_variant("_cls_capture_async") + async def capture_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentIntent.CaptureParams"] + ) -> "PaymentIntent": + """ + Capture the funds of an existing uncaptured PaymentIntent when its status is requires_capture. + + Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. + + Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). + """ + return cast( + "PaymentIntent", + await self._request_async( + "post", + "/v1/payment_intents/{intent}/capture".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_confirm( cls, intent: str, **params: Unpack["PaymentIntent.ConfirmParams"] @@ -11349,42 +11550,360 @@ def confirm( # pyright: ignore[reportGeneralTypeIssues] """ return cast( "PaymentIntent", - self._request( + self._request( + "post", + "/v1/payment_intents/{intent}/confirm".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + async def _cls_confirm_async( + cls, intent: str, **params: Unpack["PaymentIntent.ConfirmParams"] + ) -> "PaymentIntent": + """ + Confirm that your customer intends to pay with current or provided + payment method. Upon confirmation, the PaymentIntent will attempt to initiate + a payment. + If the selected payment method requires additional authentication steps, the + PaymentIntent will transition to the requires_action status and + suggest additional actions via next_action. If payment fails, + the PaymentIntent transitions to the requires_payment_method status or the + canceled status if the confirmation limit is reached. If + payment succeeds, the PaymentIntent will transition to the succeeded + status (or requires_capture, if capture_method is set to manual). + If the confirmation_method is automatic, payment may be attempted + using our [client SDKs](https://stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) + and the PaymentIntent's [client_secret](https://stripe.com/docs/api#payment_intent_object-client_secret). + After next_actions are handled by the client, no additional + confirmation is required to complete the payment. + If the confirmation_method is manual, all payment attempts must be + initiated using a secret key. + If any actions are required for the payment, the PaymentIntent will + return to the requires_confirmation state + after those actions are completed. Your server needs to then + explicitly re-confirm the PaymentIntent to initiate the next payment + attempt. Read the [expanded documentation](https://stripe.com/docs/payments/payment-intents/web-manual) + to learn more about manual confirmation. + """ + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + "/v1/payment_intents/{intent}/confirm".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def confirm_async( + intent: str, **params: Unpack["PaymentIntent.ConfirmParams"] + ) -> "PaymentIntent": + """ + Confirm that your customer intends to pay with current or provided + payment method. Upon confirmation, the PaymentIntent will attempt to initiate + a payment. + If the selected payment method requires additional authentication steps, the + PaymentIntent will transition to the requires_action status and + suggest additional actions via next_action. If payment fails, + the PaymentIntent transitions to the requires_payment_method status or the + canceled status if the confirmation limit is reached. If + payment succeeds, the PaymentIntent will transition to the succeeded + status (or requires_capture, if capture_method is set to manual). + If the confirmation_method is automatic, payment may be attempted + using our [client SDKs](https://stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) + and the PaymentIntent's [client_secret](https://stripe.com/docs/api#payment_intent_object-client_secret). + After next_actions are handled by the client, no additional + confirmation is required to complete the payment. + If the confirmation_method is manual, all payment attempts must be + initiated using a secret key. + If any actions are required for the payment, the PaymentIntent will + return to the requires_confirmation state + after those actions are completed. Your server needs to then + explicitly re-confirm the PaymentIntent to initiate the next payment + attempt. Read the [expanded documentation](https://stripe.com/docs/payments/payment-intents/web-manual) + to learn more about manual confirmation. + """ + ... + + @overload + async def confirm_async( + self, **params: Unpack["PaymentIntent.ConfirmParams"] + ) -> "PaymentIntent": + """ + Confirm that your customer intends to pay with current or provided + payment method. Upon confirmation, the PaymentIntent will attempt to initiate + a payment. + If the selected payment method requires additional authentication steps, the + PaymentIntent will transition to the requires_action status and + suggest additional actions via next_action. If payment fails, + the PaymentIntent transitions to the requires_payment_method status or the + canceled status if the confirmation limit is reached. If + payment succeeds, the PaymentIntent will transition to the succeeded + status (or requires_capture, if capture_method is set to manual). + If the confirmation_method is automatic, payment may be attempted + using our [client SDKs](https://stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) + and the PaymentIntent's [client_secret](https://stripe.com/docs/api#payment_intent_object-client_secret). + After next_actions are handled by the client, no additional + confirmation is required to complete the payment. + If the confirmation_method is manual, all payment attempts must be + initiated using a secret key. + If any actions are required for the payment, the PaymentIntent will + return to the requires_confirmation state + after those actions are completed. Your server needs to then + explicitly re-confirm the PaymentIntent to initiate the next payment + attempt. Read the [expanded documentation](https://stripe.com/docs/payments/payment-intents/web-manual) + to learn more about manual confirmation. + """ + ... + + @class_method_variant("_cls_confirm_async") + async def confirm_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentIntent.ConfirmParams"] + ) -> "PaymentIntent": + """ + Confirm that your customer intends to pay with current or provided + payment method. Upon confirmation, the PaymentIntent will attempt to initiate + a payment. + If the selected payment method requires additional authentication steps, the + PaymentIntent will transition to the requires_action status and + suggest additional actions via next_action. If payment fails, + the PaymentIntent transitions to the requires_payment_method status or the + canceled status if the confirmation limit is reached. If + payment succeeds, the PaymentIntent will transition to the succeeded + status (or requires_capture, if capture_method is set to manual). + If the confirmation_method is automatic, payment may be attempted + using our [client SDKs](https://stripe.com/docs/stripe-js/reference#stripe-handle-card-payment) + and the PaymentIntent's [client_secret](https://stripe.com/docs/api#payment_intent_object-client_secret). + After next_actions are handled by the client, no additional + confirmation is required to complete the payment. + If the confirmation_method is manual, all payment attempts must be + initiated using a secret key. + If any actions are required for the payment, the PaymentIntent will + return to the requires_confirmation state + after those actions are completed. Your server needs to then + explicitly re-confirm the PaymentIntent to initiate the next payment + attempt. Read the [expanded documentation](https://stripe.com/docs/payments/payment-intents/web-manual) + to learn more about manual confirmation. + """ + return cast( + "PaymentIntent", + await self._request_async( + "post", + "/v1/payment_intents/{intent}/confirm".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + def create( + cls, **params: Unpack["PaymentIntent.CreateParams"] + ) -> "PaymentIntent": + """ + Creates a PaymentIntent object. + + After the PaymentIntent is created, attach a payment method and [confirm](https://stripe.com/docs/api/payment_intents/confirm) + to continue the payment. Learn more about the available payment flows + with the Payment Intents API. + + When you use confirm=true during creation, it's equivalent to creating + and confirming the PaymentIntent in the same call. You can use any parameters + available in the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) when you supply + confirm=true. + """ + return cast( + "PaymentIntent", + cls._static_request( + "post", + cls.class_url(), + params=params, + ), + ) + + @classmethod + async def create_async( + cls, **params: Unpack["PaymentIntent.CreateParams"] + ) -> "PaymentIntent": + """ + Creates a PaymentIntent object. + + After the PaymentIntent is created, attach a payment method and [confirm](https://stripe.com/docs/api/payment_intents/confirm) + to continue the payment. Learn more about the available payment flows + with the Payment Intents API. + + When you use confirm=true during creation, it's equivalent to creating + and confirming the PaymentIntent in the same call. You can use any parameters + available in the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) when you supply + confirm=true. + """ + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + + @classmethod + def _cls_increment_authorization( + cls, + intent: str, + **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] + ) -> "PaymentIntent": + """ + Perform an incremental authorization on an eligible + [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the + PaymentIntent's status must be requires_capture and + [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) + must be true. + + Incremental authorizations attempt to increase the authorized amount on + your customer's card to the new, higher amount provided. Similar to the + initial authorization, incremental authorizations can be declined. A + single PaymentIntent can call this endpoint multiple times to further + increase the authorized amount. + + If the incremental authorization succeeds, the PaymentIntent object + returns with the updated + [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + If the incremental authorization fails, a + [card_declined](https://stripe.com/docs/error-codes#card-declined) error returns, and no other + fields on the PaymentIntent or Charge update. The PaymentIntent + object remains capturable for the previously authorized amount. + + Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. + After it's captured, a PaymentIntent can no longer be incremented. + + Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). + """ + return cast( + "PaymentIntent", + cls._static_request( "post", - "/v1/payment_intents/{intent}/confirm".format( - intent=sanitize_id(self.get("id")) + "/v1/payment_intents/{intent}/increment_authorization".format( + intent=sanitize_id(intent) ), params=params, ), ) - @classmethod - def create( - cls, **params: Unpack["PaymentIntent.CreateParams"] + @overload + @staticmethod + def increment_authorization( + intent: str, + **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] ) -> "PaymentIntent": """ - Creates a PaymentIntent object. + Perform an incremental authorization on an eligible + [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the + PaymentIntent's status must be requires_capture and + [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) + must be true. - After the PaymentIntent is created, attach a payment method and [confirm](https://stripe.com/docs/api/payment_intents/confirm) - to continue the payment. Learn more about the available payment flows - with the Payment Intents API. + Incremental authorizations attempt to increase the authorized amount on + your customer's card to the new, higher amount provided. Similar to the + initial authorization, incremental authorizations can be declined. A + single PaymentIntent can call this endpoint multiple times to further + increase the authorized amount. - When you use confirm=true during creation, it's equivalent to creating - and confirming the PaymentIntent in the same call. You can use any parameters - available in the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) when you supply - confirm=true. + If the incremental authorization succeeds, the PaymentIntent object + returns with the updated + [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + If the incremental authorization fails, a + [card_declined](https://stripe.com/docs/error-codes#card-declined) error returns, and no other + fields on the PaymentIntent or Charge update. The PaymentIntent + object remains capturable for the previously authorized amount. + + Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. + After it's captured, a PaymentIntent can no longer be incremented. + + Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). + """ + ... + + @overload + def increment_authorization( + self, **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] + ) -> "PaymentIntent": + """ + Perform an incremental authorization on an eligible + [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the + PaymentIntent's status must be requires_capture and + [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) + must be true. + + Incremental authorizations attempt to increase the authorized amount on + your customer's card to the new, higher amount provided. Similar to the + initial authorization, incremental authorizations can be declined. A + single PaymentIntent can call this endpoint multiple times to further + increase the authorized amount. + + If the incremental authorization succeeds, the PaymentIntent object + returns with the updated + [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + If the incremental authorization fails, a + [card_declined](https://stripe.com/docs/error-codes#card-declined) error returns, and no other + fields on the PaymentIntent or Charge update. The PaymentIntent + object remains capturable for the previously authorized amount. + + Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. + After it's captured, a PaymentIntent can no longer be incremented. + + Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). + """ + ... + + @class_method_variant("_cls_increment_authorization") + def increment_authorization( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] + ) -> "PaymentIntent": + """ + Perform an incremental authorization on an eligible + [PaymentIntent](https://stripe.com/docs/api/payment_intents/object). To be eligible, the + PaymentIntent's status must be requires_capture and + [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) + must be true. + + Incremental authorizations attempt to increase the authorized amount on + your customer's card to the new, higher amount provided. Similar to the + initial authorization, incremental authorizations can be declined. A + single PaymentIntent can call this endpoint multiple times to further + increase the authorized amount. + + If the incremental authorization succeeds, the PaymentIntent object + returns with the updated + [amount](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-amount). + If the incremental authorization fails, a + [card_declined](https://stripe.com/docs/error-codes#card-declined) error returns, and no other + fields on the PaymentIntent or Charge update. The PaymentIntent + object remains capturable for the previously authorized amount. + + Each PaymentIntent can have a maximum of 10 incremental authorization attempts, including declines. + After it's captured, a PaymentIntent can no longer be incremented. + + Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). """ return cast( "PaymentIntent", - cls._static_request( + self._request( "post", - cls.class_url(), + "/v1/payment_intents/{intent}/increment_authorization".format( + intent=sanitize_id(self.get("id")) + ), params=params, ), ) @classmethod - def _cls_increment_authorization( + async def _cls_increment_authorization_async( cls, intent: str, **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] @@ -11417,7 +11936,7 @@ def _cls_increment_authorization( """ return cast( "PaymentIntent", - cls._static_request( + await cls._static_request_async( "post", "/v1/payment_intents/{intent}/increment_authorization".format( intent=sanitize_id(intent) @@ -11428,7 +11947,7 @@ def _cls_increment_authorization( @overload @staticmethod - def increment_authorization( + async def increment_authorization_async( intent: str, **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] ) -> "PaymentIntent": @@ -11461,7 +11980,7 @@ def increment_authorization( ... @overload - def increment_authorization( + async def increment_authorization_async( self, **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] ) -> "PaymentIntent": """ @@ -11492,8 +12011,8 @@ def increment_authorization( """ ... - @class_method_variant("_cls_increment_authorization") - def increment_authorization( # pyright: ignore[reportGeneralTypeIssues] + @class_method_variant("_cls_increment_authorization_async") + async def increment_authorization_async( # pyright: ignore[reportGeneralTypeIssues] self, **params: Unpack["PaymentIntent.IncrementAuthorizationParams"] ) -> "PaymentIntent": """ @@ -11524,7 +12043,7 @@ def increment_authorization( # pyright: ignore[reportGeneralTypeIssues] """ return cast( "PaymentIntent", - self._request( + await self._request_async( "post", "/v1/payment_intents/{intent}/increment_authorization".format( intent=sanitize_id(self.get("id")) @@ -11554,6 +12073,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PaymentIntent.ListParams"] + ) -> ListObject["PaymentIntent"]: + """ + Returns a list of PaymentIntents. + """ + 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["PaymentIntent.ModifyParams"] @@ -11577,6 +12117,29 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["PaymentIntent.ModifyParams"] + ) -> "PaymentIntent": + """ + Updates properties on a PaymentIntent object without confirming. + + Depending on which properties you update, you might need to confirm the + PaymentIntent again. For example, updating the payment_method + always requires you to confirm the PaymentIntent again. If you prefer to + update and confirm at the same time, we recommend updating properties through + the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) instead. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["PaymentIntent.RetrieveParams"] @@ -11592,6 +12155,21 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PaymentIntent.RetrieveParams"] + ) -> "PaymentIntent": + """ + Retrieves the details of a PaymentIntent that has previously been created. + + You can retrieve a PaymentIntent client-side using a publishable key when the client_secret is in the query string. + + If you retrieve a PaymentIntent with a publishable key, it only returns a subset of properties. Refer to the [payment intent](https://stripe.com/docs/api#payment_intent_object) object reference for more details. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_verify_microdeposits( cls, @@ -11650,6 +12228,64 @@ def verify_microdeposits( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_verify_microdeposits_async( + cls, + intent: str, + **params: Unpack["PaymentIntent.VerifyMicrodepositsParams"] + ) -> "PaymentIntent": + """ + Verifies microdeposits on a PaymentIntent object. + """ + return cast( + "PaymentIntent", + await cls._static_request_async( + "post", + "/v1/payment_intents/{intent}/verify_microdeposits".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def verify_microdeposits_async( + intent: str, + **params: Unpack["PaymentIntent.VerifyMicrodepositsParams"] + ) -> "PaymentIntent": + """ + Verifies microdeposits on a PaymentIntent object. + """ + ... + + @overload + async def verify_microdeposits_async( + self, **params: Unpack["PaymentIntent.VerifyMicrodepositsParams"] + ) -> "PaymentIntent": + """ + Verifies microdeposits on a PaymentIntent object. + """ + ... + + @class_method_variant("_cls_verify_microdeposits_async") + async def verify_microdeposits_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentIntent.VerifyMicrodepositsParams"] + ) -> "PaymentIntent": + """ + Verifies microdeposits on a PaymentIntent object. + """ + return cast( + "PaymentIntent", + await self._request_async( + "post", + "/v1/payment_intents/{intent}/verify_microdeposits".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def search( cls, *args, **kwargs: Unpack["PaymentIntent.SearchParams"] @@ -11664,11 +12300,33 @@ def search( search_url="/v1/payment_intents/search", *args, **kwargs ) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["PaymentIntent.SearchParams"] + ) -> SearchResultObject["PaymentIntent"]: + """ + Search for PaymentIntents you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/payment_intents/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["PaymentIntent.SearchParams"] ) -> Iterator["PaymentIntent"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["PaymentIntent.SearchParams"] + ) -> AsyncIterator["PaymentIntent"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() _inner_class_types = { "amount_details": AmountDetails, diff --git a/stripe/_payment_link.py b/stripe/_payment_link.py index 7cfb0d096..fdbc6b9ca 100644 --- a/stripe/_payment_link.py +++ b/stripe/_payment_link.py @@ -2440,6 +2440,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["PaymentLink.CreateParams"] + ) -> "PaymentLink": + """ + Creates a payment link. + """ + return cast( + "PaymentLink", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["PaymentLink.ListParams"] @@ -2461,6 +2477,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PaymentLink.ListParams"] + ) -> ListObject["PaymentLink"]: + """ + Returns a list of your payment links. + """ + 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 _cls_list_line_items( cls, @@ -2518,6 +2555,63 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, + payment_link: str, + **params: Unpack["PaymentLink.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await cls._static_request_async( + "get", + "/v1/payment_links/{payment_link}/line_items".format( + payment_link=sanitize_id(payment_link) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + payment_link: str, **params: Unpack["PaymentLink.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["PaymentLink.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentLink.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a payment link, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await self._request_async( + "get", + "/v1/payment_links/{payment_link}/line_items".format( + payment_link=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def modify( cls, id: str, **params: Unpack["PaymentLink.ModifyParams"] @@ -2535,6 +2629,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["PaymentLink.ModifyParams"] + ) -> "PaymentLink": + """ + Updates a payment link. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PaymentLink", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["PaymentLink.RetrieveParams"] @@ -2546,6 +2657,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PaymentLink.RetrieveParams"] + ) -> "PaymentLink": + """ + Retrieve a payment link. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "after_completion": AfterCompletion, "automatic_tax": AutomaticTax, diff --git a/stripe/_payment_method.py b/stripe/_payment_method.py index e0732d3f6..676cf6fcd 100644 --- a/stripe/_payment_method.py +++ b/stripe/_payment_method.py @@ -1815,6 +1815,111 @@ def attach( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_attach_async( + cls, + payment_method: str, + **params: Unpack["PaymentMethod.AttachParams"] + ) -> "PaymentMethod": + """ + Attaches a PaymentMethod object to a Customer. + + To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](https://stripe.com/docs/api/setup_intents) + or a PaymentIntent with [setup_future_usage](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage). + These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach + endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for + future use, which makes later declines and payment friction more likely. + See [Optimizing cards for future payments](https://stripe.com/docs/payments/payment-intents#future-usage) for more information about setting up + future payments. + + To use this PaymentMethod as the default for invoice or subscription payments, + set [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method), + on the Customer to the PaymentMethod's ID. + """ + return cast( + "PaymentMethod", + await cls._static_request_async( + "post", + "/v1/payment_methods/{payment_method}/attach".format( + payment_method=sanitize_id(payment_method) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def attach_async( + payment_method: str, **params: Unpack["PaymentMethod.AttachParams"] + ) -> "PaymentMethod": + """ + Attaches a PaymentMethod object to a Customer. + + To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](https://stripe.com/docs/api/setup_intents) + or a PaymentIntent with [setup_future_usage](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage). + These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach + endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for + future use, which makes later declines and payment friction more likely. + See [Optimizing cards for future payments](https://stripe.com/docs/payments/payment-intents#future-usage) for more information about setting up + future payments. + + To use this PaymentMethod as the default for invoice or subscription payments, + set [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method), + on the Customer to the PaymentMethod's ID. + """ + ... + + @overload + async def attach_async( + self, **params: Unpack["PaymentMethod.AttachParams"] + ) -> "PaymentMethod": + """ + Attaches a PaymentMethod object to a Customer. + + To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](https://stripe.com/docs/api/setup_intents) + or a PaymentIntent with [setup_future_usage](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage). + These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach + endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for + future use, which makes later declines and payment friction more likely. + See [Optimizing cards for future payments](https://stripe.com/docs/payments/payment-intents#future-usage) for more information about setting up + future payments. + + To use this PaymentMethod as the default for invoice or subscription payments, + set [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method), + on the Customer to the PaymentMethod's ID. + """ + ... + + @class_method_variant("_cls_attach_async") + async def attach_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentMethod.AttachParams"] + ) -> "PaymentMethod": + """ + Attaches a PaymentMethod object to a Customer. + + To attach a new PaymentMethod to a customer for future payments, we recommend you use a [SetupIntent](https://stripe.com/docs/api/setup_intents) + or a PaymentIntent with [setup_future_usage](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage). + These approaches will perform any necessary steps to set up the PaymentMethod for future payments. Using the /v1/payment_methods/:id/attach + endpoint without first using a SetupIntent or PaymentIntent with setup_future_usage does not optimize the PaymentMethod for + future use, which makes later declines and payment friction more likely. + See [Optimizing cards for future payments](https://stripe.com/docs/payments/payment-intents#future-usage) for more information about setting up + future payments. + + To use this PaymentMethod as the default for invoice or subscription payments, + set [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method), + on the Customer to the PaymentMethod's ID. + """ + return cast( + "PaymentMethod", + await self._request_async( + "post", + "/v1/payment_methods/{payment_method}/attach".format( + payment_method=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["PaymentMethod.CreateParams"] @@ -1833,6 +1938,24 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["PaymentMethod.CreateParams"] + ) -> "PaymentMethod": + """ + Creates a PaymentMethod object. Read the [Stripe.js reference](https://stripe.com/docs/stripe-js/reference#stripe-create-payment-method) to learn how to create PaymentMethods via Stripe.js. + + Instead of creating a PaymentMethod directly, we recommend using the [PaymentIntents API to accept a payment immediately or the SetupIntent](https://stripe.com/docs/payments/accept-a-payment) API to collect payment method details ahead of a future payment. + """ + return cast( + "PaymentMethod", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_detach( cls, @@ -1890,6 +2013,63 @@ def detach( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_detach_async( + cls, + payment_method: str, + **params: Unpack["PaymentMethod.DetachParams"] + ) -> "PaymentMethod": + """ + Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. + """ + return cast( + "PaymentMethod", + await cls._static_request_async( + "post", + "/v1/payment_methods/{payment_method}/detach".format( + payment_method=sanitize_id(payment_method) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def detach_async( + payment_method: str, **params: Unpack["PaymentMethod.DetachParams"] + ) -> "PaymentMethod": + """ + Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. + """ + ... + + @overload + async def detach_async( + self, **params: Unpack["PaymentMethod.DetachParams"] + ) -> "PaymentMethod": + """ + Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. + """ + ... + + @class_method_variant("_cls_detach_async") + async def detach_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentMethod.DetachParams"] + ) -> "PaymentMethod": + """ + Detaches a PaymentMethod object from a Customer. After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. + """ + return cast( + "PaymentMethod", + await self._request_async( + "post", + "/v1/payment_methods/{payment_method}/detach".format( + payment_method=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["PaymentMethod.ListParams"] @@ -1911,6 +2091,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PaymentMethod.ListParams"] + ) -> ListObject["PaymentMethod"]: + """ + Returns a list of PaymentMethods for Treasury flows. If you want to list the PaymentMethods attached to a Customer for payments, you should use the [List a Customer's PaymentMethods](https://stripe.com/docs/api/payment_methods/customer_list) API instead. + """ + 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["PaymentMethod.ModifyParams"] @@ -1928,6 +2129,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["PaymentMethod.ModifyParams"] + ) -> "PaymentMethod": + """ + Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PaymentMethod", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["PaymentMethod.RetrieveParams"] @@ -1939,6 +2157,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PaymentMethod.RetrieveParams"] + ) -> "PaymentMethod": + """ + Retrieves a PaymentMethod object attached to the StripeAccount. To retrieve a payment method attached to a Customer, you should use [Retrieve a Customer's PaymentMethods](https://stripe.com/docs/api/payment_methods/customer) + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "acss_debit": AcssDebit, "affirm": Affirm, diff --git a/stripe/_payment_method_configuration.py b/stripe/_payment_method_configuration.py index 97f6ac5ee..970d40f38 100644 --- a/stripe/_payment_method_configuration.py +++ b/stripe/_payment_method_configuration.py @@ -2347,6 +2347,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["PaymentMethodConfiguration.CreateParams"] + ) -> "PaymentMethodConfiguration": + """ + Creates a payment method configuration + """ + return cast( + "PaymentMethodConfiguration", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["PaymentMethodConfiguration.ListParams"] @@ -2368,6 +2384,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PaymentMethodConfiguration.ListParams"] + ) -> ListObject["PaymentMethodConfiguration"]: + """ + List payment method configurations + """ + 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, @@ -2387,6 +2424,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, + id: str, + **params: Unpack["PaymentMethodConfiguration.ModifyParams"] + ) -> "PaymentMethodConfiguration": + """ + Update payment method configuration + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PaymentMethodConfiguration", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, @@ -2400,6 +2456,19 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, + id: str, + **params: Unpack["PaymentMethodConfiguration.RetrieveParams"] + ) -> "PaymentMethodConfiguration": + """ + Retrieve payment method configuration + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "acss_debit": AcssDebit, "affirm": Affirm, diff --git a/stripe/_payment_method_domain.py b/stripe/_payment_method_domain.py index bce5ac13b..4ecf7d01c 100644 --- a/stripe/_payment_method_domain.py +++ b/stripe/_payment_method_domain.py @@ -214,6 +214,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["PaymentMethodDomain.CreateParams"] + ) -> "PaymentMethodDomain": + """ + Creates a payment method domain. + """ + return cast( + "PaymentMethodDomain", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["PaymentMethodDomain.ListParams"] @@ -235,6 +251,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PaymentMethodDomain.ListParams"] + ) -> ListObject["PaymentMethodDomain"]: + """ + Lists the details of existing payment method domains. + """ + 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["PaymentMethodDomain.ModifyParams"] @@ -252,6 +289,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["PaymentMethodDomain.ModifyParams"] + ) -> "PaymentMethodDomain": + """ + Updates an existing payment method domain. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PaymentMethodDomain", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["PaymentMethodDomain.RetrieveParams"] @@ -263,6 +317,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PaymentMethodDomain.RetrieveParams"] + ) -> "PaymentMethodDomain": + """ + Retrieves the details of an existing payment method domain. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_validate( cls, @@ -341,6 +406,84 @@ def validate( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_validate_async( + cls, + payment_method_domain: str, + **params: Unpack["PaymentMethodDomain.ValidateParams"] + ) -> "PaymentMethodDomain": + """ + Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. + The payment method doesn't appear in Elements for this domain until it is active. + + To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. + + Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). + """ + return cast( + "PaymentMethodDomain", + await cls._static_request_async( + "post", + "/v1/payment_method_domains/{payment_method_domain}/validate".format( + payment_method_domain=sanitize_id(payment_method_domain) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def validate_async( + payment_method_domain: str, + **params: Unpack["PaymentMethodDomain.ValidateParams"] + ) -> "PaymentMethodDomain": + """ + Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. + The payment method doesn't appear in Elements for this domain until it is active. + + To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. + + Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). + """ + ... + + @overload + async def validate_async( + self, **params: Unpack["PaymentMethodDomain.ValidateParams"] + ) -> "PaymentMethodDomain": + """ + Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. + The payment method doesn't appear in Elements for this domain until it is active. + + To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. + + Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). + """ + ... + + @class_method_variant("_cls_validate_async") + async def validate_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PaymentMethodDomain.ValidateParams"] + ) -> "PaymentMethodDomain": + """ + Some payment methods such as Apple Pay require additional steps to verify a domain. If the requirements weren't satisfied when the domain was created, the payment method will be inactive on the domain. + The payment method doesn't appear in Elements for this domain until it is active. + + To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. + + Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). + """ + return cast( + "PaymentMethodDomain", + await self._request_async( + "post", + "/v1/payment_method_domains/{payment_method_domain}/validate".format( + payment_method_domain=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + _inner_class_types = { "apple_pay": ApplePay, "google_pay": GooglePay, diff --git a/stripe/_payout.py b/stripe/_payout.py index 5aa5ec72d..4d0297bbd 100644 --- a/stripe/_payout.py +++ b/stripe/_payout.py @@ -324,6 +324,61 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, payout: str, **params: Unpack["Payout.CancelParams"] + ) -> "Payout": + """ + You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts. + """ + return cast( + "Payout", + await cls._static_request_async( + "post", + "/v1/payouts/{payout}/cancel".format( + payout=sanitize_id(payout) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + payout: str, **params: Unpack["Payout.CancelParams"] + ) -> "Payout": + """ + You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Payout.CancelParams"] + ) -> "Payout": + """ + You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Payout.CancelParams"] + ) -> "Payout": + """ + You can cancel a previously created payout if its status is pending. Stripe refunds the funds to your available balance. You can't cancel automatic Stripe payouts. + """ + return cast( + "Payout", + await self._request_async( + "post", + "/v1/payouts/{payout}/cancel".format( + payout=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Payout.CreateParams"]) -> "Payout": """ @@ -342,6 +397,26 @@ def create(cls, **params: Unpack["Payout.CreateParams"]) -> "Payout": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Payout.CreateParams"] + ) -> "Payout": + """ + To send funds to your own bank account, create a new payout object. Your [Stripe balance](https://stripe.com/docs/api#balance) must cover the payout amount. If it doesn't, you receive an “Insufficient Funds” error. + + If your API key is in test mode, money won't actually be sent, though every other action occurs as if you're in live mode. + + If you create a manual payout on a Stripe account that uses multiple payment source types, you need to specify the source type balance that the payout draws from. The [balance object](https://stripe.com/docs/api#balance_object) details available and pending amounts by source type. + """ + return cast( + "Payout", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Payout.ListParams"] @@ -363,6 +438,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Payout.ListParams"] + ) -> ListObject["Payout"]: + """ + Returns a list of existing payouts sent to third-party bank accounts or payouts that Stripe sent to you. The payouts return in sorted order, with the most recently created payouts appearing first. + """ + 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["Payout.ModifyParams"] @@ -380,6 +476,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Payout.ModifyParams"] + ) -> "Payout": + """ + Updates the specified payout by setting the values of the parameters you pass. We don't change parameters that you don't provide. This request only accepts the metadata as arguments. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Payout", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Payout.RetrieveParams"] @@ -391,6 +504,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Payout.RetrieveParams"] + ) -> "Payout": + """ + Retrieves the details of an existing payout. Supply the unique payout ID from either a payout creation request or the payout list. Stripe returns the corresponding payout information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_reverse( cls, payout: str, **params: Unpack["Payout.ReverseParams"] @@ -451,3 +575,66 @@ def reverse( # pyright: ignore[reportGeneralTypeIssues] params=params, ), ) + + @classmethod + async def _cls_reverse_async( + cls, payout: str, **params: Unpack["Payout.ReverseParams"] + ) -> "Payout": + """ + Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. + + By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. + """ + return cast( + "Payout", + await cls._static_request_async( + "post", + "/v1/payouts/{payout}/reverse".format( + payout=sanitize_id(payout) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def reverse_async( + payout: str, **params: Unpack["Payout.ReverseParams"] + ) -> "Payout": + """ + Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. + + By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. + """ + ... + + @overload + async def reverse_async( + self, **params: Unpack["Payout.ReverseParams"] + ) -> "Payout": + """ + Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. + + By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. + """ + ... + + @class_method_variant("_cls_reverse_async") + async def reverse_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Payout.ReverseParams"] + ) -> "Payout": + """ + Reverses a payout by debiting the destination bank account. At this time, you can only reverse payouts for connected accounts to US bank accounts. If the payout is manual and in the pending status, use /v1/payouts/:id/cancel instead. + + By requesting a reversal through /v1/payouts/:id/reverse, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. + """ + return cast( + "Payout", + await self._request_async( + "post", + "/v1/payouts/{payout}/reverse".format( + payout=sanitize_id(self.get("id")) + ), + params=params, + ), + ) diff --git a/stripe/_plan.py b/stripe/_plan.py index 0fcfd06c0..d051cdf37 100644 --- a/stripe/_plan.py +++ b/stripe/_plan.py @@ -394,6 +394,22 @@ def create(cls, **params: Unpack["Plan.CreateParams"]) -> "Plan": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Plan.CreateParams"] + ) -> "Plan": + """ + You can now model subscriptions more flexibly using the [Prices API](https://stripe.com/docs/api#prices). It replaces the Plans API and is backwards compatible to simplify your migration. + """ + return cast( + "Plan", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Plan.DeleteParams"] @@ -439,6 +455,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Plan.DeleteParams"] + ) -> "Plan": + """ + Deleting plans means new subscribers can't be added. Existing subscribers aren't affected. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Plan", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Plan.DeleteParams"] + ) -> "Plan": + """ + Deleting plans means new subscribers can't be added. Existing subscribers aren't affected. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Plan.DeleteParams"] + ) -> "Plan": + """ + Deleting plans means new subscribers can't be added. Existing subscribers aren't affected. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Plan.DeleteParams"] + ) -> "Plan": + """ + Deleting plans means new subscribers can't be added. Existing subscribers aren't affected. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list(cls, **params: Unpack["Plan.ListParams"]) -> ListObject["Plan"]: """ @@ -458,6 +523,27 @@ def list(cls, **params: Unpack["Plan.ListParams"]) -> ListObject["Plan"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Plan.ListParams"] + ) -> ListObject["Plan"]: + """ + Returns a list of your plans. + """ + 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["Plan.ModifyParams"]) -> "Plan": """ @@ -473,6 +559,23 @@ def modify(cls, id: str, **params: Unpack["Plan.ModifyParams"]) -> "Plan": ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Plan.ModifyParams"] + ) -> "Plan": + """ + Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan's ID, amount, currency, or billing cycle. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Plan", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Plan.RetrieveParams"] @@ -484,4 +587,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Plan.RetrieveParams"] + ) -> "Plan": + """ + Retrieves the plan with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"tiers": Tier, "transform_usage": TransformUsage} diff --git a/stripe/_price.py b/stripe/_price.py index 437b14d57..3b5d9c79d 100644 --- a/stripe/_price.py +++ b/stripe/_price.py @@ -10,7 +10,16 @@ from stripe._stripe_object import StripeObject from stripe._updateable_api_resource import UpdateableAPIResource from stripe._util import sanitize_id -from typing import ClassVar, Dict, Iterator, List, Optional, Union, cast +from typing import ( + AsyncIterator, + ClassVar, + Dict, + Iterator, + List, + Optional, + Union, + cast, +) from typing_extensions import ( Literal, NotRequired, @@ -769,6 +778,22 @@ def create(cls, **params: Unpack["Price.CreateParams"]) -> "Price": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Price.CreateParams"] + ) -> "Price": + """ + Creates a new price for an existing product. The price can be recurring or one-time. + """ + return cast( + "Price", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Price.ListParams"]) -> ListObject["Price"]: """ @@ -788,6 +813,27 @@ def list(cls, **params: Unpack["Price.ListParams"]) -> ListObject["Price"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Price.ListParams"] + ) -> ListObject["Price"]: + """ + Returns a list of your active prices, excluding [inline prices](https://stripe.com/docs/products-prices/pricing-models#inline-pricing). For the list of inactive prices, set active to false. + """ + 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["Price.ModifyParams"] @@ -805,6 +851,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Price.ModifyParams"] + ) -> "Price": + """ + Updates the specified price by setting the values of the parameters passed. Any parameters not provided are left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Price", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Price.RetrieveParams"] @@ -816,6 +879,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Price.RetrieveParams"] + ) -> "Price": + """ + Retrieves the price with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def search( cls, *args, **kwargs: Unpack["Price.SearchParams"] @@ -828,11 +902,33 @@ def search( """ return cls._search(search_url="/v1/prices/search", *args, **kwargs) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["Price.SearchParams"] + ) -> SearchResultObject["Price"]: + """ + Search for prices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/prices/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["Price.SearchParams"] ) -> Iterator["Price"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["Price.SearchParams"] + ) -> AsyncIterator["Price"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() _inner_class_types = { "currency_options": CurrencyOptions, diff --git a/stripe/_product.py b/stripe/_product.py index 9fd8a22cf..55bbb07ab 100644 --- a/stripe/_product.py +++ b/stripe/_product.py @@ -12,6 +12,7 @@ from stripe._updateable_api_resource import UpdateableAPIResource from stripe._util import class_method_variant, sanitize_id from typing import ( + AsyncIterator, ClassVar, Dict, Iterator, @@ -624,6 +625,22 @@ def create(cls, **params: Unpack["Product.CreateParams"]) -> "Product": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Product.CreateParams"] + ) -> "Product": + """ + Creates a new product object. + """ + return cast( + "Product", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Product.DeleteParams"] @@ -671,6 +688,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Product.DeleteParams"] + ) -> "Product": + """ + Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Product", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Product.DeleteParams"] + ) -> "Product": + """ + Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Product.DeleteParams"] + ) -> "Product": + """ + Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Product.DeleteParams"] + ) -> "Product": + """ + Delete a product. Deleting a product is only possible if it has no prices associated with it. Additionally, deleting a product with type=good is only possible if it has no SKUs associated with it. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["Product.ListParams"] @@ -692,6 +758,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Product.ListParams"] + ) -> ListObject["Product"]: + """ + Returns a list of your products. The products are returned sorted by creation date, with the most recently created products appearing first. + """ + 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["Product.ModifyParams"] @@ -709,6 +796,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Product.ModifyParams"] + ) -> "Product": + """ + Updates the specific product by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Product", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Product.RetrieveParams"] @@ -720,6 +824,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Product.RetrieveParams"] + ) -> "Product": + """ + Retrieves the details of an existing product. Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def search( cls, *args, **kwargs: Unpack["Product.SearchParams"] @@ -732,11 +847,33 @@ def search( """ return cls._search(search_url="/v1/products/search", *args, **kwargs) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["Product.SearchParams"] + ) -> SearchResultObject["Product"]: + """ + Search for products you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/products/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["Product.SearchParams"] ) -> Iterator["Product"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["Product.SearchParams"] + ) -> AsyncIterator["Product"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() _inner_class_types = { "features": Feature, diff --git a/stripe/_promotion_code.py b/stripe/_promotion_code.py index 0bc39564e..d96ad6988 100644 --- a/stripe/_promotion_code.py +++ b/stripe/_promotion_code.py @@ -286,6 +286,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["PromotionCode.CreateParams"] + ) -> "PromotionCode": + """ + A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date. + """ + return cast( + "PromotionCode", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["PromotionCode.ListParams"] @@ -307,6 +323,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PromotionCode.ListParams"] + ) -> ListObject["PromotionCode"]: + """ + Returns a list of your promotion codes. + """ + 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["PromotionCode.ModifyParams"] @@ -324,6 +361,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["PromotionCode.ModifyParams"] + ) -> "PromotionCode": + """ + Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PromotionCode", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["PromotionCode.RetrieveParams"] @@ -335,4 +389,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PromotionCode.RetrieveParams"] + ) -> "PromotionCode": + """ + Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use [list](https://stripe.com/docs/api/promotion_codes/list) with the desired code. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"restrictions": Restrictions} diff --git a/stripe/_quote.py b/stripe/_quote.py index 2d8f21d44..2e3ea1b7d 100644 --- a/stripe/_quote.py +++ b/stripe/_quote.py @@ -3878,6 +3878,59 @@ def accept( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_accept_async( + cls, quote: str, **params: Unpack["Quote.AcceptParams"] + ) -> "Quote": + """ + Accepts the specified quote. + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + "/v1/quotes/{quote}/accept".format(quote=sanitize_id(quote)), + params=params, + ), + ) + + @overload + @staticmethod + async def accept_async( + quote: str, **params: Unpack["Quote.AcceptParams"] + ) -> "Quote": + """ + Accepts the specified quote. + """ + ... + + @overload + async def accept_async( + self, **params: Unpack["Quote.AcceptParams"] + ) -> "Quote": + """ + Accepts the specified quote. + """ + ... + + @class_method_variant("_cls_accept_async") + async def accept_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.AcceptParams"] + ) -> "Quote": + """ + Accepts the specified quote. + """ + return cast( + "Quote", + await self._request_async( + "post", + "/v1/quotes/{quote}/accept".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_cancel( cls, quote: str, **params: Unpack["Quote.CancelParams"] @@ -3927,6 +3980,59 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, quote: str, **params: Unpack["Quote.CancelParams"] + ) -> "Quote": + """ + Cancels the quote. + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + "/v1/quotes/{quote}/cancel".format(quote=sanitize_id(quote)), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + quote: str, **params: Unpack["Quote.CancelParams"] + ) -> "Quote": + """ + Cancels the quote. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Quote.CancelParams"] + ) -> "Quote": + """ + Cancels the quote. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.CancelParams"] + ) -> "Quote": + """ + Cancels the quote. + """ + return cast( + "Quote", + await self._request_async( + "post", + "/v1/quotes/{quote}/cancel".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Quote.CreateParams"]) -> "Quote": """ @@ -3941,6 +4047,22 @@ def create(cls, **params: Unpack["Quote.CreateParams"]) -> "Quote": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Quote.CreateParams"] + ) -> "Quote": + """ + A quote models prices and services for a customer. Default options for header, description, footer, and expires_at can be set in the dashboard via the [quote template](https://dashboard.stripe.com/settings/billing/quote). + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_finalize_quote( cls, quote: str, **params: Unpack["Quote.FinalizeQuoteParams"] @@ -3994,6 +4116,59 @@ def finalize_quote( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_finalize_quote_async( + cls, quote: str, **params: Unpack["Quote.FinalizeQuoteParams"] + ) -> "Quote": + """ + Finalizes the quote. + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + "/v1/quotes/{quote}/finalize".format(quote=sanitize_id(quote)), + params=params, + ), + ) + + @overload + @staticmethod + async def finalize_quote_async( + quote: str, **params: Unpack["Quote.FinalizeQuoteParams"] + ) -> "Quote": + """ + Finalizes the quote. + """ + ... + + @overload + async def finalize_quote_async( + self, **params: Unpack["Quote.FinalizeQuoteParams"] + ) -> "Quote": + """ + Finalizes the quote. + """ + ... + + @class_method_variant("_cls_finalize_quote_async") + async def finalize_quote_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.FinalizeQuoteParams"] + ) -> "Quote": + """ + Finalizes the quote. + """ + return cast( + "Quote", + await self._request_async( + "post", + "/v1/quotes/{quote}/finalize".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Quote.ListParams"]) -> ListObject["Quote"]: """ @@ -4013,6 +4188,27 @@ def list(cls, **params: Unpack["Quote.ListParams"]) -> ListObject["Quote"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Quote.ListParams"] + ) -> ListObject["Quote"]: + """ + Returns a list of your quotes. + """ + 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 _cls_list_computed_upfront_line_items( cls, @@ -4071,6 +4267,64 @@ def list_computed_upfront_line_items( # pyright: ignore[reportGeneralTypeIssues ), ) + @classmethod + async def _cls_list_computed_upfront_line_items_async( + cls, + quote: str, + **params: Unpack["Quote.ListComputedUpfrontLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. + """ + return cast( + ListObject["LineItem"], + await cls._static_request_async( + "get", + "/v1/quotes/{quote}/computed_upfront_line_items".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_computed_upfront_line_items_async( + quote: str, + **params: Unpack["Quote.ListComputedUpfrontLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. + """ + ... + + @overload + async def list_computed_upfront_line_items_async( + self, **params: Unpack["Quote.ListComputedUpfrontLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. + """ + ... + + @class_method_variant("_cls_list_computed_upfront_line_items_async") + async def list_computed_upfront_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.ListComputedUpfrontLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable [computed.upfront.line_items](https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items) property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. + """ + return cast( + ListObject["LineItem"], + await self._request_async( + "get", + "/v1/quotes/{quote}/computed_upfront_line_items".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_list_line_items( cls, quote: str, **params: Unpack["Quote.ListLineItemsParams"] @@ -4126,6 +4380,61 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, quote: str, **params: Unpack["Quote.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await cls._static_request_async( + "get", + "/v1/quotes/{quote}/line_items".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + quote: str, **params: Unpack["Quote.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["Quote.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await self._request_async( + "get", + "/v1/quotes/{quote}/line_items".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_list_lines( cls, quote: str, **params: Unpack["Quote.ListLinesParams"] @@ -4180,7 +4489,126 @@ def list_lines( # pyright: ignore[reportGeneralTypeIssues] ) @classmethod - def _cls_list_preview_invoice_lines( + async def _cls_list_lines_async( + cls, quote: str, **params: Unpack["Quote.ListLinesParams"] + ) -> ListObject["QuoteLine"]: + """ + Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. + """ + return cast( + ListObject["QuoteLine"], + await cls._static_request_async( + "get", + "/v1/quotes/{quote}/lines".format(quote=sanitize_id(quote)), + params=params, + ), + ) + + @overload + @staticmethod + async def list_lines_async( + quote: str, **params: Unpack["Quote.ListLinesParams"] + ) -> ListObject["QuoteLine"]: + """ + Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. + """ + ... + + @overload + async def list_lines_async( + self, **params: Unpack["Quote.ListLinesParams"] + ) -> ListObject["QuoteLine"]: + """ + Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. + """ + ... + + @class_method_variant("_cls_list_lines_async") + async def list_lines_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.ListLinesParams"] + ) -> ListObject["QuoteLine"]: + """ + Retrieves a paginated list of lines for a quote. These lines describe changes that will be used to create new subscription schedules or update existing subscription schedules when the quote is accepted. + """ + return cast( + ListObject["QuoteLine"], + await self._request_async( + "get", + "/v1/quotes/{quote}/lines".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + + @classmethod + def _cls_list_preview_invoice_lines( + cls, + quote: str, + preview_invoice: str, + **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] + ) -> ListObject["InvoiceLineItem"]: + """ + Preview the invoice line items that would be generated by accepting the quote. + """ + return cast( + ListObject["InvoiceLineItem"], + cls._static_request( + "get", + "/v1/quotes/{quote}/preview_invoices/{preview_invoice}/lines".format( + quote=sanitize_id(quote), + preview_invoice=sanitize_id(preview_invoice), + ), + params=params, + ), + ) + + @overload + @staticmethod + def list_preview_invoice_lines( + quote: str, + preview_invoice: str, + **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] + ) -> ListObject["InvoiceLineItem"]: + """ + Preview the invoice line items that would be generated by accepting the quote. + """ + ... + + @overload + def list_preview_invoice_lines( + self, + preview_invoice: str, + **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] + ) -> ListObject["InvoiceLineItem"]: + """ + Preview the invoice line items that would be generated by accepting the quote. + """ + ... + + @class_method_variant("_cls_list_preview_invoice_lines") + def list_preview_invoice_lines( # pyright: ignore[reportGeneralTypeIssues] + self, + preview_invoice: str, + **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] + ) -> ListObject["InvoiceLineItem"]: + """ + Preview the invoice line items that would be generated by accepting the quote. + """ + return cast( + ListObject["InvoiceLineItem"], + self._request( + "get", + "/v1/quotes/{quote}/preview_invoices/{preview_invoice}/lines".format( + quote=sanitize_id(self.get("id")), + preview_invoice=sanitize_id(preview_invoice), + ), + params=params, + ), + ) + + @classmethod + async def _cls_list_preview_invoice_lines_async( cls, quote: str, preview_invoice: str, @@ -4191,7 +4619,7 @@ def _cls_list_preview_invoice_lines( """ return cast( ListObject["InvoiceLineItem"], - cls._static_request( + await cls._static_request_async( "get", "/v1/quotes/{quote}/preview_invoices/{preview_invoice}/lines".format( quote=sanitize_id(quote), @@ -4203,7 +4631,7 @@ def _cls_list_preview_invoice_lines( @overload @staticmethod - def list_preview_invoice_lines( + async def list_preview_invoice_lines_async( quote: str, preview_invoice: str, **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] @@ -4214,7 +4642,7 @@ def list_preview_invoice_lines( ... @overload - def list_preview_invoice_lines( + async def list_preview_invoice_lines_async( self, preview_invoice: str, **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] @@ -4224,8 +4652,8 @@ def list_preview_invoice_lines( """ ... - @class_method_variant("_cls_list_preview_invoice_lines") - def list_preview_invoice_lines( # pyright: ignore[reportGeneralTypeIssues] + @class_method_variant("_cls_list_preview_invoice_lines_async") + async def list_preview_invoice_lines_async( # pyright: ignore[reportGeneralTypeIssues] self, preview_invoice: str, **params: Unpack["Quote.ListPreviewInvoiceLinesParams"] @@ -4235,7 +4663,7 @@ def list_preview_invoice_lines( # pyright: ignore[reportGeneralTypeIssues] """ return cast( ListObject["InvoiceLineItem"], - self._request( + await self._request_async( "get", "/v1/quotes/{quote}/preview_invoices/{preview_invoice}/lines".format( quote=sanitize_id(self.get("id")), @@ -4298,6 +4726,61 @@ def mark_draft( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_mark_draft_async( + cls, quote: str, **params: Unpack["Quote.MarkDraftParams"] + ) -> "Quote": + """ + Converts a stale quote to draft. + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + "/v1/quotes/{quote}/mark_draft".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def mark_draft_async( + quote: str, **params: Unpack["Quote.MarkDraftParams"] + ) -> "Quote": + """ + Converts a stale quote to draft. + """ + ... + + @overload + async def mark_draft_async( + self, **params: Unpack["Quote.MarkDraftParams"] + ) -> "Quote": + """ + Converts a stale quote to draft. + """ + ... + + @class_method_variant("_cls_mark_draft_async") + async def mark_draft_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.MarkDraftParams"] + ) -> "Quote": + """ + Converts a stale quote to draft. + """ + return cast( + "Quote", + await self._request_async( + "post", + "/v1/quotes/{quote}/mark_draft".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_mark_stale( cls, quote: str, **params: Unpack["Quote.MarkStaleParams"] @@ -4351,6 +4834,61 @@ def mark_stale( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_mark_stale_async( + cls, quote: str, **params: Unpack["Quote.MarkStaleParams"] + ) -> "Quote": + """ + Converts a draft or open quote to stale. + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + "/v1/quotes/{quote}/mark_stale".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def mark_stale_async( + quote: str, **params: Unpack["Quote.MarkStaleParams"] + ) -> "Quote": + """ + Converts a draft or open quote to stale. + """ + ... + + @overload + async def mark_stale_async( + self, **params: Unpack["Quote.MarkStaleParams"] + ) -> "Quote": + """ + Converts a draft or open quote to stale. + """ + ... + + @class_method_variant("_cls_mark_stale_async") + async def mark_stale_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.MarkStaleParams"] + ) -> "Quote": + """ + Converts a draft or open quote to stale. + """ + return cast( + "Quote", + await self._request_async( + "post", + "/v1/quotes/{quote}/mark_stale".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def modify( cls, id: str, **params: Unpack["Quote.ModifyParams"] @@ -4368,6 +4906,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Quote.ModifyParams"] + ) -> "Quote": + """ + A quote models prices and services for a customer. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Quote", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def _cls_pdf(cls, quote: str, **params: Unpack["Quote.PdfParams"]) -> Any: """ @@ -4416,6 +4971,58 @@ def pdf( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_pdf_async( + cls, quote: str, **params: Unpack["Quote.PdfParams"] + ) -> Any: + """ + Download the PDF for a finalized quote + """ + return cast( + Any, + await cls._static_request_stream_async( + "get", + "/v1/quotes/{quote}/pdf".format(quote=sanitize_id(quote)), + params=params, + base_address="files", + ), + ) + + @overload + @staticmethod + async def pdf_async( + quote: str, **params: Unpack["Quote.PdfParams"] + ) -> Any: + """ + Download the PDF for a finalized quote + """ + ... + + @overload + async def pdf_async(self, **params: Unpack["Quote.PdfParams"]) -> Any: + """ + Download the PDF for a finalized quote + """ + ... + + @class_method_variant("_cls_pdf_async") + async def pdf_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.PdfParams"] + ) -> Any: + """ + Download the PDF for a finalized quote + """ + return cast( + Any, + await self._request_stream_async( + "get", + "/v1/quotes/{quote}/pdf".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_reestimate( cls, quote: str, **params: Unpack["Quote.ReestimateParams"] @@ -4471,6 +5078,61 @@ def reestimate( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_reestimate_async( + cls, quote: str, **params: Unpack["Quote.ReestimateParams"] + ) -> "Quote": + """ + Recompute the upcoming invoice estimate for the quote. + """ + return cast( + "Quote", + await cls._static_request_async( + "post", + "/v1/quotes/{quote}/reestimate".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def reestimate_async( + quote: str, **params: Unpack["Quote.ReestimateParams"] + ) -> "Quote": + """ + Recompute the upcoming invoice estimate for the quote. + """ + ... + + @overload + async def reestimate_async( + self, **params: Unpack["Quote.ReestimateParams"] + ) -> "Quote": + """ + Recompute the upcoming invoice estimate for the quote. + """ + ... + + @class_method_variant("_cls_reestimate_async") + async def reestimate_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Quote.ReestimateParams"] + ) -> "Quote": + """ + Recompute the upcoming invoice estimate for the quote. + """ + return cast( + "Quote", + await self._request_async( + "post", + "/v1/quotes/{quote}/reestimate".format( + quote=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Quote.RetrieveParams"] @@ -4482,6 +5144,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Quote.RetrieveParams"] + ) -> "Quote": + """ + Retrieves the quote with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def list_preview_invoices( cls, quote: str, **params: Unpack["Quote.ListPreviewInvoicesParams"] @@ -4500,6 +5173,24 @@ def list_preview_invoices( ), ) + @classmethod + async def list_preview_invoices_async( + cls, quote: str, **params: Unpack["Quote.ListPreviewInvoicesParams"] + ) -> ListObject["QuotePreviewInvoice"]: + """ + Preview the invoices that would be generated by accepting the quote. + """ + return cast( + ListObject["QuotePreviewInvoice"], + await cls._static_request_async( + "get", + "/v1/quotes/{quote}/preview_invoices".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + @classmethod def list_preview_subscription_schedules( cls, @@ -4520,6 +5211,26 @@ def list_preview_subscription_schedules( ), ) + @classmethod + async def list_preview_subscription_schedules_async( + cls, + quote: str, + **params: Unpack["Quote.ListPreviewSubscriptionSchedulesParams"] + ) -> ListObject["QuotePreviewSubscriptionSchedule"]: + """ + Preview the schedules that would be generated by accepting the quote + """ + return cast( + ListObject["QuotePreviewSubscriptionSchedule"], + await cls._static_request_async( + "get", + "/v1/quotes/{quote}/preview_subscription_schedules".format( + quote=sanitize_id(quote) + ), + params=params, + ), + ) + _inner_class_types = { "automatic_tax": AutomaticTax, "computed": Computed, diff --git a/stripe/_quote_phase.py b/stripe/_quote_phase.py index 2dc69d189..e033ac7e6 100644 --- a/stripe/_quote_phase.py +++ b/stripe/_quote_phase.py @@ -241,6 +241,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["QuotePhase.ListParams"] + ) -> ListObject["QuotePhase"]: + """ + Returns a list of quote phases. + """ + 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 _cls_list_line_items( cls, @@ -298,6 +319,63 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, + quote_phase: str, + **params: Unpack["QuotePhase.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote phase, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await cls._static_request_async( + "get", + "/v1/quote_phases/{quote_phase}/line_items".format( + quote_phase=sanitize_id(quote_phase) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + quote_phase: str, **params: Unpack["QuotePhase.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote phase, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["QuotePhase.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote phase, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["QuotePhase.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a quote phase, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await self._request_async( + "get", + "/v1/quote_phases/{quote_phase}/line_items".format( + quote_phase=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["QuotePhase.RetrieveParams"] @@ -309,6 +387,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["QuotePhase.RetrieveParams"] + ) -> "QuotePhase": + """ + Retrieves the quote phase with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "invoice_settings": InvoiceSettings, "total_details": TotalDetails, diff --git a/stripe/_quote_preview_invoice.py b/stripe/_quote_preview_invoice.py index 76dab1773..76de62e54 100644 --- a/stripe/_quote_preview_invoice.py +++ b/stripe/_quote_preview_invoice.py @@ -1409,6 +1409,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["QuotePreviewInvoice.ListParams"] + ) -> ListObject["QuotePreviewInvoice"]: + """ + Preview the invoices that would be generated by accepting the quote. + """ + 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 + _inner_class_types = { "amounts_due": AmountsDue, "applies_to": AppliesTo, diff --git a/stripe/_quote_preview_subscription_schedule.py b/stripe/_quote_preview_subscription_schedule.py index 4265c5371..5c5e4d446 100644 --- a/stripe/_quote_preview_subscription_schedule.py +++ b/stripe/_quote_preview_subscription_schedule.py @@ -659,6 +659,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["QuotePreviewSubscriptionSchedule.ListParams"] + ) -> ListObject["QuotePreviewSubscriptionSchedule"]: + """ + Preview the schedules that would be generated by accepting the quote + """ + 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 + _inner_class_types = { "applies_to": AppliesTo, "current_phase": CurrentPhase, diff --git a/stripe/_refund.py b/stripe/_refund.py index f06a4df91..1599dcbad 100644 --- a/stripe/_refund.py +++ b/stripe/_refund.py @@ -538,6 +538,69 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, refund: str, **params: Unpack["Refund.CancelParams"] + ) -> "Refund": + """ + Cancels a refund with a status of requires_action. + + You can't cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state. + """ + return cast( + "Refund", + await cls._static_request_async( + "post", + "/v1/refunds/{refund}/cancel".format( + refund=sanitize_id(refund) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + refund: str, **params: Unpack["Refund.CancelParams"] + ) -> "Refund": + """ + Cancels a refund with a status of requires_action. + + You can't cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Refund.CancelParams"] + ) -> "Refund": + """ + Cancels a refund with a status of requires_action. + + You can't cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Refund.CancelParams"] + ) -> "Refund": + """ + Cancels a refund with a status of requires_action. + + You can't cancel refunds in other states. Only refunds for payment methods that require customer action can enter the requires_action state. + """ + return cast( + "Refund", + await self._request_async( + "post", + "/v1/refunds/{refund}/cancel".format( + refund=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Refund.CreateParams"]) -> "Refund": """ @@ -562,6 +625,32 @@ def create(cls, **params: Unpack["Refund.CreateParams"]) -> "Refund": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Refund.CreateParams"] + ) -> "Refund": + """ + When you create a new refund, you must specify a Charge or a PaymentIntent object on which to create it. + + Creating a new refund will refund a charge that has previously been created but not yet refunded. + Funds will be refunded to the credit or debit card that was originally charged. + + You can optionally refund only part of a charge. + You can do so multiple times, until the entire charge has been refunded. + + Once entirely refunded, a charge can't be refunded again. + This method will raise an error when called on an already-refunded charge, + or when trying to refund more money than is left on a charge. + """ + return cast( + "Refund", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Refund.ListParams"] @@ -583,6 +672,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Refund.ListParams"] + ) -> ListObject["Refund"]: + """ + You can see a list of the refunds belonging to a specific charge. Note that the 10 most recent refunds are always available by default on the charge object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional refunds. + """ + 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["Refund.ModifyParams"] @@ -602,6 +712,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Refund.ModifyParams"] + ) -> "Refund": + """ + Updates the refund that you specify by setting the values of the passed parameters. Any parameters that you don't provide remain unchanged. + + This request only accepts metadata as an argument. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Refund", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Refund.RetrieveParams"] @@ -613,6 +742,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Refund.RetrieveParams"] + ) -> "Refund": + """ + Retrieves the details of an existing refund. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["Refund"]): _resource_cls: Type["Refund"] @@ -669,6 +809,61 @@ def expire( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_expire_async( + cls, refund: str, **params: Unpack["Refund.ExpireParams"] + ) -> "Refund": + """ + Expire a refund with a status of requires_action. + """ + return cast( + "Refund", + await cls._static_request_async( + "post", + "/v1/test_helpers/refunds/{refund}/expire".format( + refund=sanitize_id(refund) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def expire_async( + refund: str, **params: Unpack["Refund.ExpireParams"] + ) -> "Refund": + """ + Expire a refund with a status of requires_action. + """ + ... + + @overload + async def expire_async( + self, **params: Unpack["Refund.ExpireParams"] + ) -> "Refund": + """ + Expire a refund with a status of requires_action. + """ + ... + + @class_method_variant("_cls_expire_async") + async def expire_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Refund.ExpireParams"] + ) -> "Refund": + """ + Expire a refund with a status of requires_action. + """ + return cast( + "Refund", + await self.resource._request_async( + "post", + "/v1/test_helpers/refunds/{refund}/expire".format( + refund=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/_review.py b/stripe/_review.py index 3a55c51a5..25dace65f 100644 --- a/stripe/_review.py +++ b/stripe/_review.py @@ -233,6 +233,61 @@ def approve( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_approve_async( + cls, review: str, **params: Unpack["Review.ApproveParams"] + ) -> "Review": + """ + Approves a Review object, closing it and removing it from the list of reviews. + """ + return cast( + "Review", + await cls._static_request_async( + "post", + "/v1/reviews/{review}/approve".format( + review=sanitize_id(review) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def approve_async( + review: str, **params: Unpack["Review.ApproveParams"] + ) -> "Review": + """ + Approves a Review object, closing it and removing it from the list of reviews. + """ + ... + + @overload + async def approve_async( + self, **params: Unpack["Review.ApproveParams"] + ) -> "Review": + """ + Approves a Review object, closing it and removing it from the list of reviews. + """ + ... + + @class_method_variant("_cls_approve_async") + async def approve_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Review.ApproveParams"] + ) -> "Review": + """ + Approves a Review object, closing it and removing it from the list of reviews. + """ + return cast( + "Review", + await self._request_async( + "post", + "/v1/reviews/{review}/approve".format( + review=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Review.ListParams"] @@ -254,6 +309,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Review.ListParams"] + ) -> ListObject["Review"]: + """ + Returns a list of Review objects that have open set to true. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["Review.RetrieveParams"] @@ -265,6 +341,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Review.RetrieveParams"] + ) -> "Review": + """ + Retrieves a Review object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "ip_address_location": IpAddressLocation, "session": Session, diff --git a/stripe/_setup_attempt.py b/stripe/_setup_attempt.py index 06f5f0d7c..4dda2d00d 100644 --- a/stripe/_setup_attempt.py +++ b/stripe/_setup_attempt.py @@ -792,6 +792,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["SetupAttempt.ListParams"] + ) -> ListObject["SetupAttempt"]: + """ + Returns a list of SetupAttempts that associate with a provided SetupIntent. + """ + 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 + _inner_class_types = { "payment_method_details": PaymentMethodDetails, "setup_error": SetupError, diff --git a/stripe/_setup_intent.py b/stripe/_setup_intent.py index ce9238aaf..7adf4fc04 100644 --- a/stripe/_setup_intent.py +++ b/stripe/_setup_intent.py @@ -3657,6 +3657,69 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, intent: str, **params: Unpack["SetupIntent.CancelParams"] + ) -> "SetupIntent": + """ + You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. + + After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. + """ + return cast( + "SetupIntent", + await cls._static_request_async( + "post", + "/v1/setup_intents/{intent}/cancel".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + intent: str, **params: Unpack["SetupIntent.CancelParams"] + ) -> "SetupIntent": + """ + You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. + + After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["SetupIntent.CancelParams"] + ) -> "SetupIntent": + """ + You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. + + After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SetupIntent.CancelParams"] + ) -> "SetupIntent": + """ + You can cancel a SetupIntent object when it's in one of these statuses: requires_payment_method, requires_confirmation, or requires_action. + + After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. + """ + return cast( + "SetupIntent", + await self._request_async( + "post", + "/v1/setup_intents/{intent}/cancel".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_confirm( cls, intent: str, **params: Unpack["SetupIntent.ConfirmParams"] @@ -3764,6 +3827,113 @@ def confirm( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_confirm_async( + cls, intent: str, **params: Unpack["SetupIntent.ConfirmParams"] + ) -> "SetupIntent": + """ + Confirm that your customer intends to set up the current or + provided payment method. For example, you would confirm a SetupIntent + when a customer hits the “Save” button on a payment method management + page on your website. + + If the selected payment method does not require any additional + steps from the customer, the SetupIntent will transition to the + succeeded status. + + Otherwise, it will transition to the requires_action status and + suggest additional actions via next_action. If setup fails, + the SetupIntent will transition to the + requires_payment_method status or the canceled status if the + confirmation limit is reached. + """ + return cast( + "SetupIntent", + await cls._static_request_async( + "post", + "/v1/setup_intents/{intent}/confirm".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def confirm_async( + intent: str, **params: Unpack["SetupIntent.ConfirmParams"] + ) -> "SetupIntent": + """ + Confirm that your customer intends to set up the current or + provided payment method. For example, you would confirm a SetupIntent + when a customer hits the “Save” button on a payment method management + page on your website. + + If the selected payment method does not require any additional + steps from the customer, the SetupIntent will transition to the + succeeded status. + + Otherwise, it will transition to the requires_action status and + suggest additional actions via next_action. If setup fails, + the SetupIntent will transition to the + requires_payment_method status or the canceled status if the + confirmation limit is reached. + """ + ... + + @overload + async def confirm_async( + self, **params: Unpack["SetupIntent.ConfirmParams"] + ) -> "SetupIntent": + """ + Confirm that your customer intends to set up the current or + provided payment method. For example, you would confirm a SetupIntent + when a customer hits the “Save” button on a payment method management + page on your website. + + If the selected payment method does not require any additional + steps from the customer, the SetupIntent will transition to the + succeeded status. + + Otherwise, it will transition to the requires_action status and + suggest additional actions via next_action. If setup fails, + the SetupIntent will transition to the + requires_payment_method status or the canceled status if the + confirmation limit is reached. + """ + ... + + @class_method_variant("_cls_confirm_async") + async def confirm_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SetupIntent.ConfirmParams"] + ) -> "SetupIntent": + """ + Confirm that your customer intends to set up the current or + provided payment method. For example, you would confirm a SetupIntent + when a customer hits the “Save” button on a payment method management + page on your website. + + If the selected payment method does not require any additional + steps from the customer, the SetupIntent will transition to the + succeeded status. + + Otherwise, it will transition to the requires_action status and + suggest additional actions via next_action. If setup fails, + the SetupIntent will transition to the + requires_payment_method status or the canceled status if the + confirmation limit is reached. + """ + return cast( + "SetupIntent", + await self._request_async( + "post", + "/v1/setup_intents/{intent}/confirm".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["SetupIntent.CreateParams"] @@ -3783,6 +3953,25 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["SetupIntent.CreateParams"] + ) -> "SetupIntent": + """ + Creates a SetupIntent object. + + After you create the SetupIntent, attach a payment method and [confirm](https://stripe.com/docs/api/setup_intents/confirm) + it to collect any required permissions to charge the payment method later. + """ + return cast( + "SetupIntent", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["SetupIntent.ListParams"] @@ -3804,6 +3993,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["SetupIntent.ListParams"] + ) -> ListObject["SetupIntent"]: + """ + Returns a list of SetupIntents. + """ + 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["SetupIntent.ModifyParams"] @@ -3821,6 +4031,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["SetupIntent.ModifyParams"] + ) -> "SetupIntent": + """ + Updates a SetupIntent object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "SetupIntent", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["SetupIntent.RetrieveParams"] @@ -3836,6 +4063,21 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["SetupIntent.RetrieveParams"] + ) -> "SetupIntent": + """ + Retrieves the details of a SetupIntent that has previously been created. + + Client-side retrieval using a publishable key is allowed when the client_secret is provided in the query string. + + When retrieved with a publishable key, only a subset of properties will be returned. Please refer to the [SetupIntent](https://stripe.com/docs/api#setup_intent_object) object reference for more details. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_verify_microdeposits( cls, @@ -3893,6 +4135,63 @@ def verify_microdeposits( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_verify_microdeposits_async( + cls, + intent: str, + **params: Unpack["SetupIntent.VerifyMicrodepositsParams"] + ) -> "SetupIntent": + """ + Verifies microdeposits on a SetupIntent object. + """ + return cast( + "SetupIntent", + await cls._static_request_async( + "post", + "/v1/setup_intents/{intent}/verify_microdeposits".format( + intent=sanitize_id(intent) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def verify_microdeposits_async( + intent: str, **params: Unpack["SetupIntent.VerifyMicrodepositsParams"] + ) -> "SetupIntent": + """ + Verifies microdeposits on a SetupIntent object. + """ + ... + + @overload + async def verify_microdeposits_async( + self, **params: Unpack["SetupIntent.VerifyMicrodepositsParams"] + ) -> "SetupIntent": + """ + Verifies microdeposits on a SetupIntent object. + """ + ... + + @class_method_variant("_cls_verify_microdeposits_async") + async def verify_microdeposits_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SetupIntent.VerifyMicrodepositsParams"] + ) -> "SetupIntent": + """ + Verifies microdeposits on a SetupIntent object. + """ + return cast( + "SetupIntent", + await self._request_async( + "post", + "/v1/setup_intents/{intent}/verify_microdeposits".format( + intent=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + _inner_class_types = { "automatic_payment_methods": AutomaticPaymentMethods, "last_setup_error": LastSetupError, diff --git a/stripe/_shipping_rate.py b/stripe/_shipping_rate.py index a647e9610..ed96ee0d9 100644 --- a/stripe/_shipping_rate.py +++ b/stripe/_shipping_rate.py @@ -350,6 +350,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ShippingRate.CreateParams"] + ) -> "ShippingRate": + """ + Creates a new shipping rate object. + """ + return cast( + "ShippingRate", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["ShippingRate.ListParams"] @@ -371,6 +387,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ShippingRate.ListParams"] + ) -> ListObject["ShippingRate"]: + """ + Returns a list of your shipping rates. + """ + 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["ShippingRate.ModifyParams"] @@ -388,6 +425,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["ShippingRate.ModifyParams"] + ) -> "ShippingRate": + """ + Updates an existing shipping rate object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "ShippingRate", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["ShippingRate.RetrieveParams"] @@ -399,6 +453,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ShippingRate.RetrieveParams"] + ) -> "ShippingRate": + """ + Returns the shipping rate object with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "delivery_estimate": DeliveryEstimate, "fixed_amount": FixedAmount, diff --git a/stripe/_source.py b/stripe/_source.py index 8a626a915..2287cfe74 100644 --- a/stripe/_source.py +++ b/stripe/_source.py @@ -1136,6 +1136,22 @@ def create(cls, **params: Unpack["Source.CreateParams"]) -> "Source": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Source.CreateParams"] + ) -> "Source": + """ + Creates a new source object. + """ + return cast( + "Source", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_list_source_transactions( cls, @@ -1193,6 +1209,63 @@ def list_source_transactions( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_source_transactions_async( + cls, + source: str, + **params: Unpack["Source.ListSourceTransactionsParams"] + ) -> ListObject["SourceTransaction"]: + """ + List source transactions for a given source. + """ + return cast( + ListObject["SourceTransaction"], + await cls._static_request_async( + "get", + "/v1/sources/{source}/source_transactions".format( + source=sanitize_id(source) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_source_transactions_async( + source: str, **params: Unpack["Source.ListSourceTransactionsParams"] + ) -> ListObject["SourceTransaction"]: + """ + List source transactions for a given source. + """ + ... + + @overload + async def list_source_transactions_async( + self, **params: Unpack["Source.ListSourceTransactionsParams"] + ) -> ListObject["SourceTransaction"]: + """ + List source transactions for a given source. + """ + ... + + @class_method_variant("_cls_list_source_transactions_async") + async def list_source_transactions_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Source.ListSourceTransactionsParams"] + ) -> ListObject["SourceTransaction"]: + """ + List source transactions for a given source. + """ + return cast( + ListObject["SourceTransaction"], + await self._request_async( + "get", + "/v1/sources/{source}/source_transactions".format( + source=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def modify( cls, id: str, **params: Unpack["Source.ModifyParams"] @@ -1212,6 +1285,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Source.ModifyParams"] + ) -> "Source": + """ + Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + + This request accepts the metadata and owner as arguments. It is also possible to update type specific information for selected payment methods. Please refer to our [payment method guides](https://stripe.com/docs/sources) for more detail. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Source", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Source.RetrieveParams"] @@ -1223,6 +1315,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Source.RetrieveParams"] + ) -> "Source": + """ + Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_verify( cls, source: str, **params: Unpack["Source.VerifyParams"] @@ -1276,6 +1379,61 @@ def verify( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_verify_async( + cls, source: str, **params: Unpack["Source.VerifyParams"] + ) -> "Source": + """ + Verify a given source. + """ + return cast( + "Source", + await cls._static_request_async( + "post", + "/v1/sources/{source}/verify".format( + source=sanitize_id(source) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def verify_async( + source: str, **params: Unpack["Source.VerifyParams"] + ) -> "Source": + """ + Verify a given source. + """ + ... + + @overload + async def verify_async( + self, **params: Unpack["Source.VerifyParams"] + ) -> "Source": + """ + Verify a given source. + """ + ... + + @class_method_variant("_cls_verify_async") + async def verify_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Source.VerifyParams"] + ) -> "Source": + """ + Verify a given source. + """ + return cast( + "Source", + await self._request_async( + "post", + "/v1/sources/{source}/verify".format( + source=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + def detach(self, **params) -> "Source": token = self.id diff --git a/stripe/_subscription.py b/stripe/_subscription.py index ac594f686..0fbe8c79b 100644 --- a/stripe/_subscription.py +++ b/stripe/_subscription.py @@ -12,6 +12,7 @@ from stripe._updateable_api_resource import UpdateableAPIResource from stripe._util import class_method_variant, sanitize_id from typing import ( + AsyncIterator, ClassVar, Dict, Iterator, @@ -2446,6 +2447,82 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, + subscription_exposed_id: str, + **params: Unpack["Subscription.CancelParams"] + ) -> "Subscription": + """ + Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + + 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. + + 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. + """ + return cast( + "Subscription", + await cls._static_request_async( + "delete", + "/v1/subscriptions/{subscription_exposed_id}".format( + subscription_exposed_id=sanitize_id( + subscription_exposed_id + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + subscription_exposed_id: str, + **params: Unpack["Subscription.CancelParams"] + ) -> "Subscription": + """ + Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. + + 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. + + 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. + """ + ... + + @overload + 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. + + 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. + + 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. + """ + ... + + @class_method_variant("_cls_cancel_async") + 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. + + 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. + + 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. + """ + return cast( + "Subscription", + await self._request_async( + "delete", + "/v1/subscriptions/{subscription_exposed_id}".format( + subscription_exposed_id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["Subscription.CreateParams"] @@ -2468,6 +2545,28 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Subscription.CreateParams"] + ) -> "Subscription": + """ + Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions. + + When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request. + The payment_behavior parameter determines the exact behavior of the initial payment. + + To start subscriptions where the first invoice always begins in a draft status, use [subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules#managing) instead. + Schedules provide the flexibility to model more complex billing configurations that change over time. + """ + return cast( + "Subscription", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete_discount( cls, @@ -2528,6 +2627,66 @@ def delete_discount( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_delete_discount_async( + cls, + subscription_exposed_id: str, + **params: Unpack["Subscription.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a subscription. + """ + return cast( + "Discount", + await cls._static_request_async( + "delete", + "/v1/subscriptions/{subscription_exposed_id}/discount".format( + subscription_exposed_id=sanitize_id( + subscription_exposed_id + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def delete_discount_async( + subscription_exposed_id: str, + **params: Unpack["Subscription.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a subscription. + """ + ... + + @overload + async def delete_discount_async( + self, **params: Unpack["Subscription.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a subscription. + """ + ... + + @class_method_variant("_cls_delete_discount_async") + async def delete_discount_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Subscription.DeleteDiscountParams"] + ) -> "Discount": + """ + Removes the currently applied discount on a subscription. + """ + return cast( + "Discount", + await self._request_async( + "delete", + "/v1/subscriptions/{subscription_exposed_id}/discount".format( + subscription_exposed_id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Subscription.ListParams"] @@ -2549,6 +2708,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Subscription.ListParams"] + ) -> ListObject["Subscription"]: + """ + By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled. + """ + 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["Subscription.ModifyParams"] @@ -2586,6 +2766,43 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Subscription.ModifyParams"] + ) -> "Subscription": + """ + Updates an existing subscription to match the specified parameters. + When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes. + To preview how the proration is calculated, use the [upcoming invoice](https://stripe.com/docs/api/invoices/upcoming) endpoint. + + By default, we prorate subscription changes. For example, if a customer signs up on May 1 for a 100 price, they'll be billed 100 immediately. If on May 15 they switch to a 200 price, then on June 1 they'll be billed 250 (200 for a renewal of her subscription, plus a 50 prorating adjustment for half of the previous month's 100 difference). Similarly, a downgrade generates a credit that is applied to the next invoice. We also prorate when you make quantity changes. + + Switching prices does not normally change the billing date or generate an immediate charge unless: + + + The billing interval is changed (for example, from monthly to yearly). + The subscription moves from free to paid, or paid to free. + A trial starts or ends. + + + In these cases, we apply a credit for the unused time on the previous price, immediately charge the customer using the new price, and reset the billing date. + + If you want to charge for an upgrade immediately, pass proration_behavior as always_invoice to create prorations, automatically invoice the customer for those proration adjustments, and attempt to collect payment. If you pass create_prorations, the prorations are created but not automatically invoiced. If you want to bill the customer for the prorations before the subscription's renewal date, you need to manually [invoice the customer](https://stripe.com/docs/api/invoices/create). + + If you don't want to prorate, set the proration_behavior option to none. With this option, the customer is billed 100 on May 1 and 200 on June 1. Similarly, if you set proration_behavior to none when switching between different billing intervals (for example, from monthly to yearly), we don't generate any credits for the old subscription's unused time. We still reset the billing date and bill immediately for the new subscription. + + Updating the quantity on a subscription many times in an hour may result in [rate limiting. If you need to bill for a frequently changing quantity, consider integrating usage-based billing](https://stripe.com/docs/rate-limits) instead. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Subscription", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def _cls_resume( cls, subscription: str, **params: Unpack["Subscription.ResumeParams"] @@ -2641,6 +2858,61 @@ def resume( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_resume_async( + cls, subscription: str, **params: Unpack["Subscription.ResumeParams"] + ) -> "Subscription": + """ + Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. + """ + return cast( + "Subscription", + await cls._static_request_async( + "post", + "/v1/subscriptions/{subscription}/resume".format( + subscription=sanitize_id(subscription) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def resume_async( + subscription: str, **params: Unpack["Subscription.ResumeParams"] + ) -> "Subscription": + """ + Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. + """ + ... + + @overload + async def resume_async( + self, **params: Unpack["Subscription.ResumeParams"] + ) -> "Subscription": + """ + Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. + """ + ... + + @class_method_variant("_cls_resume_async") + async def resume_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Subscription.ResumeParams"] + ) -> "Subscription": + """ + Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. If payment succeeds the subscription will become active, and if payment fails the subscription will be past_due. The resumption invoice will void automatically if not paid by the expiration date. + """ + return cast( + "Subscription", + await self._request_async( + "post", + "/v1/subscriptions/{subscription}/resume".format( + subscription=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Subscription.RetrieveParams"] @@ -2652,6 +2924,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Subscription.RetrieveParams"] + ) -> "Subscription": + """ + Retrieves the subscription with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def search( cls, *args, **kwargs: Unpack["Subscription.SearchParams"] @@ -2666,11 +2949,33 @@ def search( search_url="/v1/subscriptions/search", *args, **kwargs ) + @classmethod + async def search_async( + cls, *args, **kwargs: Unpack["Subscription.SearchParams"] + ) -> SearchResultObject["Subscription"]: + """ + Search for subscriptions you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + to an hour behind during outages. Search functionality is not available to merchants in India. + """ + return await cls._search_async( + search_url="/v1/subscriptions/search", *args, **kwargs + ) + @classmethod def search_auto_paging_iter( cls, *args, **kwargs: Unpack["Subscription.SearchParams"] ) -> Iterator["Subscription"]: - return cls.search(*args, **kwargs).auto_paging_iter() + return (cls.search(*args, **kwargs)).auto_paging_iter() + + @classmethod + async def search_auto_paging_iter_async( + cls, *args, **kwargs: Unpack["Subscription.SearchParams"] + ) -> AsyncIterator["Subscription"]: + return ( + await cls.search_async(*args, **kwargs) + ).auto_paging_iter_async() _inner_class_types = { "automatic_tax": AutomaticTax, diff --git a/stripe/_subscription_item.py b/stripe/_subscription_item.py index 180c8062e..ca25978d9 100644 --- a/stripe/_subscription_item.py +++ b/stripe/_subscription_item.py @@ -550,6 +550,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["SubscriptionItem.CreateParams"] + ) -> "SubscriptionItem": + """ + Adds a new item to an existing subscription. No existing items will be changed or replaced. + """ + return cast( + "SubscriptionItem", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["SubscriptionItem.DeleteParams"] @@ -599,6 +615,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["SubscriptionItem.DeleteParams"] + ) -> "SubscriptionItem": + """ + Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "SubscriptionItem", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["SubscriptionItem.DeleteParams"] + ) -> "SubscriptionItem": + """ + Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["SubscriptionItem.DeleteParams"] + ) -> "SubscriptionItem": + """ + Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SubscriptionItem.DeleteParams"] + ) -> "SubscriptionItem": + """ + Deletes an item from the subscription. Removing a subscription item from a subscription will not cancel the subscription. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["SubscriptionItem.ListParams"] @@ -620,6 +685,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["SubscriptionItem.ListParams"] + ) -> ListObject["SubscriptionItem"]: + """ + Returns a list of your subscription items for a given subscription. + """ + 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["SubscriptionItem.ModifyParams"] @@ -637,6 +723,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["SubscriptionItem.ModifyParams"] + ) -> "SubscriptionItem": + """ + Updates the plan or quantity of an item on a current subscription. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "SubscriptionItem", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["SubscriptionItem.RetrieveParams"] @@ -648,6 +751,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["SubscriptionItem.RetrieveParams"] + ) -> "SubscriptionItem": + """ + Retrieves the subscription item with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def create_usage_record( cls, @@ -674,6 +788,32 @@ def create_usage_record( ), ) + @classmethod + async def create_usage_record_async( + cls, + subscription_item: str, + **params: Unpack["SubscriptionItem.CreateUsageRecordParams"] + ) -> "UsageRecord": + """ + Creates a usage record for a specified subscription item and date, and fills it with a quantity. + + Usage records provide quantity information that Stripe uses to track how much a customer is using your service. With usage information and the pricing model set up by the [metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing) plan, Stripe helps you send accurate invoices to your customers. + + The default calculation for usage is to add up all the quantity values of the usage records within a billing period. You can change this default behavior with the billing plan's aggregate_usage [parameter](https://stripe.com/docs/api/plans/create#create_plan-aggregate_usage). When there is more than one usage record with the same timestamp, Stripe adds the quantity values together. In most cases, this is the desired resolution, however, you can change this behavior with the action parameter. + + The default pricing model for metered billing is [per-unit pricing. For finer granularity, you can configure metered billing to have a tiered pricing](https://stripe.com/docs/api/plans/object#plan_object-billing_scheme) model. + """ + return cast( + "UsageRecord", + await cls._static_request_async( + "post", + "/v1/subscription_items/{subscription_item}/usage_records".format( + subscription_item=sanitize_id(subscription_item) + ), + params=params, + ), + ) + @classmethod def list_usage_record_summaries( cls, @@ -696,6 +836,28 @@ def list_usage_record_summaries( ), ) + @classmethod + async def list_usage_record_summaries_async( + cls, + subscription_item: str, + **params: Unpack["SubscriptionItem.ListUsageRecordSummariesParams"] + ) -> ListObject["UsageRecordSummary"]: + """ + For the specified subscription item, returns a list of summary objects. Each object in the list provides usage information that's been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September). + + The list is sorted in reverse-chronological order (newest first). The first list item represents the most current usage period that hasn't ended yet. Since new usage records can still be added, the returned summary information for the subscription item's ID should be seen as unstable until the subscription billing period ends. + """ + return cast( + ListObject["UsageRecordSummary"], + await cls._static_request_async( + "get", + "/v1/subscription_items/{subscription_item}/usage_record_summaries".format( + subscription_item=sanitize_id(subscription_item) + ), + params=params, + ), + ) + _inner_class_types = { "billing_thresholds": BillingThresholds, "trial": Trial, diff --git a/stripe/_subscription_schedule.py b/stripe/_subscription_schedule.py index d9f0a88ca..807361ab5 100644 --- a/stripe/_subscription_schedule.py +++ b/stripe/_subscription_schedule.py @@ -2793,6 +2793,63 @@ def amend( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_amend_async( + cls, + schedule: str, + **params: Unpack["SubscriptionSchedule.AmendParams"] + ) -> "SubscriptionSchedule": + """ + Amends an existing subscription schedule. + """ + return cast( + "SubscriptionSchedule", + await cls._static_request_async( + "post", + "/v1/subscription_schedules/{schedule}/amend".format( + schedule=sanitize_id(schedule) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def amend_async( + schedule: str, **params: Unpack["SubscriptionSchedule.AmendParams"] + ) -> "SubscriptionSchedule": + """ + Amends an existing subscription schedule. + """ + ... + + @overload + async def amend_async( + self, **params: Unpack["SubscriptionSchedule.AmendParams"] + ) -> "SubscriptionSchedule": + """ + Amends an existing subscription schedule. + """ + ... + + @class_method_variant("_cls_amend_async") + async def amend_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SubscriptionSchedule.AmendParams"] + ) -> "SubscriptionSchedule": + """ + Amends an existing subscription schedule. + """ + return cast( + "SubscriptionSchedule", + await self._request_async( + "post", + "/v1/subscription_schedules/{schedule}/amend".format( + schedule=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_cancel( cls, @@ -2850,6 +2907,63 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, + schedule: str, + **params: Unpack["SubscriptionSchedule.CancelParams"] + ) -> "SubscriptionSchedule": + """ + Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active. + """ + return cast( + "SubscriptionSchedule", + await cls._static_request_async( + "post", + "/v1/subscription_schedules/{schedule}/cancel".format( + schedule=sanitize_id(schedule) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + schedule: str, **params: Unpack["SubscriptionSchedule.CancelParams"] + ) -> "SubscriptionSchedule": + """ + Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["SubscriptionSchedule.CancelParams"] + ) -> "SubscriptionSchedule": + """ + Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SubscriptionSchedule.CancelParams"] + ) -> "SubscriptionSchedule": + """ + Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). A subscription schedule can only be canceled if its status is not_started or active. + """ + return cast( + "SubscriptionSchedule", + await self._request_async( + "post", + "/v1/subscription_schedules/{schedule}/cancel".format( + schedule=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["SubscriptionSchedule.CreateParams"] @@ -2866,6 +2980,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["SubscriptionSchedule.CreateParams"] + ) -> "SubscriptionSchedule": + """ + Creates a new subscription schedule object. Each customer can have up to 500 active or scheduled subscriptions. + """ + return cast( + "SubscriptionSchedule", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["SubscriptionSchedule.ListParams"] @@ -2887,6 +3017,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["SubscriptionSchedule.ListParams"] + ) -> ListObject["SubscriptionSchedule"]: + """ + Retrieves the list of your subscription schedules. + """ + 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["SubscriptionSchedule.ModifyParams"] @@ -2904,6 +3055,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["SubscriptionSchedule.ModifyParams"] + ) -> "SubscriptionSchedule": + """ + Updates an existing subscription schedule. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "SubscriptionSchedule", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def _cls_release( cls, @@ -2961,6 +3129,63 @@ def release( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_release_async( + cls, + schedule: str, + **params: Unpack["SubscriptionSchedule.ReleaseParams"] + ) -> "SubscriptionSchedule": + """ + Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. + """ + return cast( + "SubscriptionSchedule", + await cls._static_request_async( + "post", + "/v1/subscription_schedules/{schedule}/release".format( + schedule=sanitize_id(schedule) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def release_async( + schedule: str, **params: Unpack["SubscriptionSchedule.ReleaseParams"] + ) -> "SubscriptionSchedule": + """ + Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. + """ + ... + + @overload + async def release_async( + self, **params: Unpack["SubscriptionSchedule.ReleaseParams"] + ) -> "SubscriptionSchedule": + """ + Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. + """ + ... + + @class_method_variant("_cls_release_async") + async def release_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["SubscriptionSchedule.ReleaseParams"] + ) -> "SubscriptionSchedule": + """ + Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. A schedule can only be released if its status is not_started or active. If the subscription schedule is currently associated with a subscription, releasing it will remove its subscription property and set the subscription's ID to the released_subscription property. + """ + return cast( + "SubscriptionSchedule", + await self._request_async( + "post", + "/v1/subscription_schedules/{schedule}/release".format( + schedule=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["SubscriptionSchedule.RetrieveParams"] @@ -2972,6 +3197,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["SubscriptionSchedule.RetrieveParams"] + ) -> "SubscriptionSchedule": + """ + Retrieves the details of an existing subscription schedule. You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "current_phase": CurrentPhase, "default_settings": DefaultSettings, diff --git a/stripe/_tax_code.py b/stripe/_tax_code.py index 42b142c72..7ac651f1e 100644 --- a/stripe/_tax_code.py +++ b/stripe/_tax_code.py @@ -76,6 +76,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["TaxCode.ListParams"] + ) -> ListObject["TaxCode"]: + """ + A list of [all tax codes available](https://stripe.com/docs/tax/tax-categories) to add to Products in order to allow specific tax calculations. + """ + 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["TaxCode.RetrieveParams"] @@ -86,3 +107,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["TaxCode.RetrieveParams"] + ) -> "TaxCode": + """ + Retrieves the details of an existing tax code. Supply the unique tax code ID and Stripe will return the corresponding tax code information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_tax_rate.py b/stripe/_tax_rate.py index 8bcebeeb8..8cd8a2794 100644 --- a/stripe/_tax_rate.py +++ b/stripe/_tax_rate.py @@ -264,6 +264,22 @@ def create(cls, **params: Unpack["TaxRate.CreateParams"]) -> "TaxRate": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["TaxRate.CreateParams"] + ) -> "TaxRate": + """ + Creates a new tax rate. + """ + return cast( + "TaxRate", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["TaxRate.ListParams"] @@ -285,6 +301,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["TaxRate.ListParams"] + ) -> ListObject["TaxRate"]: + """ + Returns a list of your tax rates. Tax rates are returned sorted by creation date, with the most recently created tax rates appearing first. + """ + 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["TaxRate.ModifyParams"] @@ -302,6 +339,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["TaxRate.ModifyParams"] + ) -> "TaxRate": + """ + Updates an existing tax rate. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "TaxRate", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["TaxRate.RetrieveParams"] @@ -312,3 +366,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["TaxRate.RetrieveParams"] + ) -> "TaxRate": + """ + Retrieves a tax rate with the given ID + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_token.py b/stripe/_token.py index 9ee9d3caf..b54740d5b 100644 --- a/stripe/_token.py +++ b/stripe/_token.py @@ -1110,6 +1110,23 @@ def create(cls, **params: Unpack["Token.CreateParams"]) -> "Token": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Token.CreateParams"] + ) -> "Token": + """ + Creates a single-use token that represents a bank account's details. + You can use this token with any API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [Custom account](https://stripe.com/docs/api#accounts). + """ + return cast( + "Token", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Token.RetrieveParams"] @@ -1120,3 +1137,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Token.RetrieveParams"] + ) -> "Token": + """ + Retrieves the token with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_topup.py b/stripe/_topup.py index b9edd5280..336d9b5f8 100644 --- a/stripe/_topup.py +++ b/stripe/_topup.py @@ -278,6 +278,59 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, topup: str, **params: Unpack["Topup.CancelParams"] + ) -> "Topup": + """ + Cancels a top-up. Only pending top-ups can be canceled. + """ + return cast( + "Topup", + await cls._static_request_async( + "post", + "/v1/topups/{topup}/cancel".format(topup=sanitize_id(topup)), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + topup: str, **params: Unpack["Topup.CancelParams"] + ) -> "Topup": + """ + Cancels a top-up. Only pending top-ups can be canceled. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Topup.CancelParams"] + ) -> "Topup": + """ + Cancels a top-up. Only pending top-ups can be canceled. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Topup.CancelParams"] + ) -> "Topup": + """ + Cancels a top-up. Only pending top-ups can be canceled. + """ + return cast( + "Topup", + await self._request_async( + "post", + "/v1/topups/{topup}/cancel".format( + topup=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Topup.CreateParams"]) -> "Topup": """ @@ -292,6 +345,22 @@ def create(cls, **params: Unpack["Topup.CreateParams"]) -> "Topup": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Topup.CreateParams"] + ) -> "Topup": + """ + Top up the balance of an account + """ + return cast( + "Topup", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Topup.ListParams"]) -> ListObject["Topup"]: """ @@ -311,6 +380,27 @@ def list(cls, **params: Unpack["Topup.ListParams"]) -> ListObject["Topup"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Topup.ListParams"] + ) -> ListObject["Topup"]: + """ + Returns a list of top-ups. + """ + 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["Topup.ModifyParams"] @@ -328,6 +418,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Topup.ModifyParams"] + ) -> "Topup": + """ + Updates the metadata of a top-up. Other top-up details are not editable by design. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Topup", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Topup.RetrieveParams"] @@ -338,3 +445,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Topup.RetrieveParams"] + ) -> "Topup": + """ + Retrieves the details of a top-up that has previously been created. Supply the unique top-up ID that was returned from your previous request, and Stripe will return the corresponding top-up information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/_transfer.py b/stripe/_transfer.py index f9d2b2b9d..11f577419 100644 --- a/stripe/_transfer.py +++ b/stripe/_transfer.py @@ -287,6 +287,22 @@ def create(cls, **params: Unpack["Transfer.CreateParams"]) -> "Transfer": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Transfer.CreateParams"] + ) -> "Transfer": + """ + To send funds from your Stripe account to a connected account, you create a new transfer object. Your [Stripe balance](https://stripe.com/docs/api#balance) must be able to cover the transfer amount, or you'll receive an “Insufficient Funds” error. + """ + return cast( + "Transfer", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Transfer.ListParams"] @@ -308,6 +324,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Transfer.ListParams"] + ) -> ListObject["Transfer"]: + """ + Returns a list of existing transfers sent to connected accounts. The transfers are returned in sorted order, with the most recently created transfers appearing first. + """ + 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["Transfer.ModifyParams"] @@ -327,6 +364,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Transfer.ModifyParams"] + ) -> "Transfer": + """ + Updates the specified transfer by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + + This request accepts only metadata as an argument. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Transfer", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Transfer.RetrieveParams"] @@ -338,6 +394,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Transfer.RetrieveParams"] + ) -> "Transfer": + """ + Retrieves the details of an existing transfer. Supply the unique transfer ID from either a transfer creation request or the transfer list, and Stripe will return the corresponding transfer information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def create_reversal( cls, id: str, **params: Unpack["Transfer.CreateReversalParams"] @@ -358,6 +425,26 @@ def create_reversal( ), ) + @classmethod + async def create_reversal_async( + cls, id: str, **params: Unpack["Transfer.CreateReversalParams"] + ) -> "Reversal": + """ + When you create a new reversal, you must specify a transfer to create it on. + + When reversing transfers, you can optionally reverse part of the transfer. You can do so as many times as you wish until the entire transfer has been reversed. + + Once entirely reversed, a transfer can't be reversed again. This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer. + """ + return cast( + "Reversal", + await cls._static_request_async( + "post", + "/v1/transfers/{id}/reversals".format(id=sanitize_id(id)), + params=params, + ), + ) + @classmethod def retrieve_reversal( cls, @@ -379,6 +466,27 @@ def retrieve_reversal( ), ) + @classmethod + async def retrieve_reversal_async( + cls, + transfer: str, + id: str, + **params: Unpack["Transfer.RetrieveReversalParams"] + ) -> "Reversal": + """ + By default, you can see the 10 most recent reversals stored directly on the transfer object, but you can also retrieve details about a specific reversal stored on the transfer. + """ + return cast( + "Reversal", + await cls._static_request_async( + "get", + "/v1/transfers/{transfer}/reversals/{id}".format( + transfer=sanitize_id(transfer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def modify_reversal( cls, @@ -402,6 +510,29 @@ def modify_reversal( ), ) + @classmethod + async def modify_reversal_async( + cls, + transfer: str, + id: str, + **params: Unpack["Transfer.ModifyReversalParams"] + ) -> "Reversal": + """ + Updates the specified reversal by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + + This request only accepts metadata and description as arguments. + """ + return cast( + "Reversal", + await cls._static_request_async( + "post", + "/v1/transfers/{transfer}/reversals/{id}".format( + transfer=sanitize_id(transfer), id=sanitize_id(id) + ), + params=params, + ), + ) + @classmethod def list_reversals( cls, id: str, **params: Unpack["Transfer.ListReversalsParams"] @@ -417,3 +548,19 @@ def list_reversals( params=params, ), ) + + @classmethod + async def list_reversals_async( + cls, id: str, **params: Unpack["Transfer.ListReversalsParams"] + ) -> ListObject["Reversal"]: + """ + You can see a list of the reversals belonging to a specific transfer. Note that the 10 most recent reversals are always available by default on the transfer object. If you need more than those 10, you can use this API method and the limit and starting_after parameters to page through additional reversals. + """ + return cast( + ListObject["Reversal"], + await cls._static_request_async( + "get", + "/v1/transfers/{id}/reversals".format(id=sanitize_id(id)), + params=params, + ), + ) diff --git a/stripe/_webhook_endpoint.py b/stripe/_webhook_endpoint.py index 99176c72b..eebb6d480 100644 --- a/stripe/_webhook_endpoint.py +++ b/stripe/_webhook_endpoint.py @@ -453,6 +453,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["WebhookEndpoint.CreateParams"] + ) -> "WebhookEndpoint": + """ + A webhook endpoint must have a url and a list of enabled_events. You may optionally specify the Boolean connect parameter. If set to true, then a Connect webhook endpoint that notifies the specified url about events from all connected accounts is created; otherwise an account webhook endpoint that notifies the specified url only about events from your account is created. You can also create webhook endpoints in the [webhooks settings](https://dashboard.stripe.com/account/webhooks) section of the Dashboard. + """ + return cast( + "WebhookEndpoint", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["WebhookEndpoint.DeleteParams"] @@ -502,6 +518,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["WebhookEndpoint.DeleteParams"] + ) -> "WebhookEndpoint": + """ + You can also delete webhook endpoints via the [webhook endpoint management](https://dashboard.stripe.com/account/webhooks) page of the Stripe dashboard. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "WebhookEndpoint", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["WebhookEndpoint.DeleteParams"] + ) -> "WebhookEndpoint": + """ + You can also delete webhook endpoints via the [webhook endpoint management](https://dashboard.stripe.com/account/webhooks) page of the Stripe dashboard. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["WebhookEndpoint.DeleteParams"] + ) -> "WebhookEndpoint": + """ + You can also delete webhook endpoints via the [webhook endpoint management](https://dashboard.stripe.com/account/webhooks) page of the Stripe dashboard. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["WebhookEndpoint.DeleteParams"] + ) -> "WebhookEndpoint": + """ + You can also delete webhook endpoints via the [webhook endpoint management](https://dashboard.stripe.com/account/webhooks) page of the Stripe dashboard. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["WebhookEndpoint.ListParams"] @@ -523,6 +588,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["WebhookEndpoint.ListParams"] + ) -> ListObject["WebhookEndpoint"]: + """ + Returns a list of your webhook endpoints. + """ + 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["WebhookEndpoint.ModifyParams"] @@ -540,6 +626,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["WebhookEndpoint.ModifyParams"] + ) -> "WebhookEndpoint": + """ + Updates the webhook endpoint. You may edit the url, the list of enabled_events, and the status of your endpoint. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "WebhookEndpoint", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["WebhookEndpoint.RetrieveParams"] @@ -550,3 +653,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["WebhookEndpoint.RetrieveParams"] + ) -> "WebhookEndpoint": + """ + Retrieves the webhook endpoint with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/apps/_secret.py b/stripe/apps/_secret.py index f10d8797a..6102cafc6 100644 --- a/stripe/apps/_secret.py +++ b/stripe/apps/_secret.py @@ -194,6 +194,22 @@ def create(cls, **params: Unpack["Secret.CreateParams"]) -> "Secret": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Secret.CreateParams"] + ) -> "Secret": + """ + Create or replace a secret in the secret store. + """ + return cast( + "Secret", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def delete_where( cls, **params: Unpack["Secret.DeleteWhereParams"] @@ -210,6 +226,22 @@ def delete_where( ), ) + @classmethod + async def delete_where_async( + cls, **params: Unpack["Secret.DeleteWhereParams"] + ) -> "Secret": + """ + Deletes a secret from the secret store by name and scope. + """ + return cast( + "Secret", + await cls._static_request_async( + "post", + "/v1/apps/secrets/delete", + params=params, + ), + ) + @classmethod def find(cls, **params: Unpack["Secret.FindParams"]) -> "Secret": """ @@ -224,6 +256,22 @@ def find(cls, **params: Unpack["Secret.FindParams"]) -> "Secret": ), ) + @classmethod + async def find_async( + cls, **params: Unpack["Secret.FindParams"] + ) -> "Secret": + """ + Finds a secret in the secret store by name and scope. + """ + return cast( + "Secret", + await cls._static_request_async( + "get", + "/v1/apps/secrets/find", + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Secret.ListParams"] @@ -245,4 +293,25 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Secret.ListParams"] + ) -> ListObject["Secret"]: + """ + List all secrets stored on the given scope. + """ + 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 + _inner_class_types = {"scope": Scope} diff --git a/stripe/billing_portal/_configuration.py b/stripe/billing_portal/_configuration.py index 29b445e75..a2ec6f8c0 100644 --- a/stripe/billing_portal/_configuration.py +++ b/stripe/billing_portal/_configuration.py @@ -659,6 +659,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Configuration.CreateParams"] + ) -> "Configuration": + """ + Creates a configuration that describes the functionality and behavior of a PortalSession + """ + return cast( + "Configuration", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Configuration.ListParams"] @@ -680,6 +696,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Configuration.ListParams"] + ) -> ListObject["Configuration"]: + """ + Returns a list of configurations that describe the functionality of the customer portal. + """ + 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["Configuration.ModifyParams"] @@ -697,6 +734,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Configuration.ModifyParams"] + ) -> "Configuration": + """ + Updates a configuration that describes the functionality of the customer portal. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Configuration", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Configuration.RetrieveParams"] @@ -708,6 +762,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Configuration.RetrieveParams"] + ) -> "Configuration": + """ + Retrieves a configuration that describes the functionality of the customer portal. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "business_profile": BusinessProfile, "features": Features, diff --git a/stripe/billing_portal/_session.py b/stripe/billing_portal/_session.py index 001041d1d..5c3d3cd97 100644 --- a/stripe/billing_portal/_session.py +++ b/stripe/billing_portal/_session.py @@ -456,4 +456,20 @@ def create(cls, **params: Unpack["Session.CreateParams"]) -> "Session": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Session.CreateParams"] + ) -> "Session": + """ + Creates a session of the customer portal. + """ + return cast( + "Session", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + _inner_class_types = {"flow": Flow} diff --git a/stripe/capital/_financing_offer.py b/stripe/capital/_financing_offer.py index ea16f748c..00c146511 100644 --- a/stripe/capital/_financing_offer.py +++ b/stripe/capital/_financing_offer.py @@ -234,6 +234,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["FinancingOffer.ListParams"] + ) -> ListObject["FinancingOffer"]: + """ + Retrieves the financing offers available for Connected accounts that belong to your platform. + """ + 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 _cls_mark_delivered( cls, @@ -296,6 +317,68 @@ def mark_delivered( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_mark_delivered_async( + cls, + financing_offer: str, + **params: Unpack["FinancingOffer.MarkDeliveredParams"] + ) -> "FinancingOffer": + """ + Acknowledges that platform has received and delivered the financing_offer to + the intended merchant recipient. + """ + return cast( + "FinancingOffer", + await cls._static_request_async( + "post", + "/v1/capital/financing_offers/{financing_offer}/mark_delivered".format( + financing_offer=sanitize_id(financing_offer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def mark_delivered_async( + financing_offer: str, + **params: Unpack["FinancingOffer.MarkDeliveredParams"] + ) -> "FinancingOffer": + """ + Acknowledges that platform has received and delivered the financing_offer to + the intended merchant recipient. + """ + ... + + @overload + async def mark_delivered_async( + self, **params: Unpack["FinancingOffer.MarkDeliveredParams"] + ) -> "FinancingOffer": + """ + Acknowledges that platform has received and delivered the financing_offer to + the intended merchant recipient. + """ + ... + + @class_method_variant("_cls_mark_delivered_async") + async def mark_delivered_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["FinancingOffer.MarkDeliveredParams"] + ) -> "FinancingOffer": + """ + Acknowledges that platform has received and delivered the financing_offer to + the intended merchant recipient. + """ + return cast( + "FinancingOffer", + await self._request_async( + "post", + "/v1/capital/financing_offers/{financing_offer}/mark_delivered".format( + financing_offer=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["FinancingOffer.RetrieveParams"] @@ -307,6 +390,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["FinancingOffer.RetrieveParams"] + ) -> "FinancingOffer": + """ + Get the details of the financing offer + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "accepted_terms": AcceptedTerms, "offered_terms": OfferedTerms, diff --git a/stripe/capital/_financing_summary.py b/stripe/capital/_financing_summary.py index 9f7710490..07206ccb4 100644 --- a/stripe/capital/_financing_summary.py +++ b/stripe/capital/_financing_summary.py @@ -109,6 +109,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, **params: Unpack["FinancingSummary.RetrieveParams"] + ) -> "FinancingSummary": + """ + Retrieve the financing state for the account that was authenticated in the request. + """ + instance = cls(None, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/capital/financing_summary" diff --git a/stripe/capital/_financing_transaction.py b/stripe/capital/_financing_transaction.py index 3d55642c1..ebe7793fa 100644 --- a/stripe/capital/_financing_transaction.py +++ b/stripe/capital/_financing_transaction.py @@ -179,6 +179,28 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["FinancingTransaction.ListParams"] + ) -> ListObject["FinancingTransaction"]: + """ + Returns a list of financing transactions. The transactions are returned in sorted order, + with the most recent transactions appearing first. + """ + 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["FinancingTransaction.RetrieveParams"] @@ -190,4 +212,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["FinancingTransaction.RetrieveParams"] + ) -> "FinancingTransaction": + """ + Retrieves a financing transaction for a financing offer. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"details": Details} diff --git a/stripe/checkout/_session.py b/stripe/checkout/_session.py index b5c1a125a..7bc6d0ec6 100644 --- a/stripe/checkout/_session.py +++ b/stripe/checkout/_session.py @@ -3762,6 +3762,22 @@ def create(cls, **params: Unpack["Session.CreateParams"]) -> "Session": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Session.CreateParams"] + ) -> "Session": + """ + Creates a Session object. + """ + return cast( + "Session", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_expire( cls, session: str, **params: Unpack["Session.ExpireParams"] @@ -3823,6 +3839,69 @@ def expire( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_expire_async( + cls, session: str, **params: Unpack["Session.ExpireParams"] + ) -> "Session": + """ + A Session can be expired when it is in one of these statuses: open + + After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired. + """ + return cast( + "Session", + await cls._static_request_async( + "post", + "/v1/checkout/sessions/{session}/expire".format( + session=sanitize_id(session) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def expire_async( + session: str, **params: Unpack["Session.ExpireParams"] + ) -> "Session": + """ + A Session can be expired when it is in one of these statuses: open + + After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired. + """ + ... + + @overload + async def expire_async( + self, **params: Unpack["Session.ExpireParams"] + ) -> "Session": + """ + A Session can be expired when it is in one of these statuses: open + + After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired. + """ + ... + + @class_method_variant("_cls_expire_async") + async def expire_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Session.ExpireParams"] + ) -> "Session": + """ + A Session can be expired when it is in one of these statuses: open + + After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired. + """ + return cast( + "Session", + await self._request_async( + "post", + "/v1/checkout/sessions/{session}/expire".format( + session=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Session.ListParams"] @@ -3844,6 +3923,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Session.ListParams"] + ) -> ListObject["Session"]: + """ + Returns a list of Checkout Sessions. + """ + 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 _cls_list_line_items( cls, session: str, **params: Unpack["Session.ListLineItemsParams"] @@ -3899,6 +3999,61 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, session: str, **params: Unpack["Session.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await cls._static_request_async( + "get", + "/v1/checkout/sessions/{session}/line_items".format( + session=sanitize_id(session) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + session: str, **params: Unpack["Session.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["Session.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Session.ListLineItemsParams"] + ) -> ListObject["LineItem"]: + """ + When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + """ + return cast( + ListObject["LineItem"], + await self._request_async( + "get", + "/v1/checkout/sessions/{session}/line_items".format( + session=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Session.RetrieveParams"] @@ -3910,6 +4065,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Session.RetrieveParams"] + ) -> "Session": + """ + Retrieves a Session object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "after_expiration": AfterExpiration, "automatic_tax": AutomaticTax, diff --git a/stripe/climate/_order.py b/stripe/climate/_order.py index be7330d6b..f227c2332 100644 --- a/stripe/climate/_order.py +++ b/stripe/climate/_order.py @@ -324,6 +324,73 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, order: str, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels a Climate order. You can cancel an order within 30 days of creation. Stripe refunds the + reservation amount_subtotal, but not the amount_fees for user-triggered cancellations. Frontier + might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe + provides 90 days advance notice and refunds the amount_total. + """ + return cast( + "Order", + await cls._static_request_async( + "post", + "/v1/climate/orders/{order}/cancel".format( + order=sanitize_id(order) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + order: str, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels a Climate order. You can cancel an order within 30 days of creation. Stripe refunds the + reservation amount_subtotal, but not the amount_fees for user-triggered cancellations. Frontier + might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe + provides 90 days advance notice and refunds the amount_total. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels a Climate order. You can cancel an order within 30 days of creation. Stripe refunds the + reservation amount_subtotal, but not the amount_fees for user-triggered cancellations. Frontier + might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe + provides 90 days advance notice and refunds the amount_total. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Order.CancelParams"] + ) -> "Order": + """ + Cancels a Climate order. You can cancel an order within 30 days of creation. Stripe refunds the + reservation amount_subtotal, but not the amount_fees for user-triggered cancellations. Frontier + might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe + provides 90 days advance notice and refunds the amount_total. + """ + return cast( + "Order", + await self._request_async( + "post", + "/v1/climate/orders/{order}/cancel".format( + order=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Order.CreateParams"]) -> "Order": """ @@ -339,6 +406,23 @@ def create(cls, **params: Unpack["Order.CreateParams"]) -> "Order": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Order.CreateParams"] + ) -> "Order": + """ + Creates a Climate order object for a given Climate product. The order will be processed immediately + after creation and payment will be deducted your Stripe balance. + """ + return cast( + "Order", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Order.ListParams"]) -> ListObject["Order"]: """ @@ -359,6 +443,28 @@ def list(cls, **params: Unpack["Order.ListParams"]) -> ListObject["Order"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Order.ListParams"] + ) -> ListObject["Order"]: + """ + Lists all Climate order objects. The orders are returned sorted by creation date, with the + most recently created orders appearing first. + """ + 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["Order.ModifyParams"] @@ -376,6 +482,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Order.ModifyParams"] + ) -> "Order": + """ + Updates the specified order by setting the values of the parameters passed. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Order", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Order.RetrieveParams"] @@ -387,6 +510,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Order.RetrieveParams"] + ) -> "Order": + """ + Retrieves the details of a Climate order object with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "beneficiary": Beneficiary, "delivery_details": DeliveryDetail, diff --git a/stripe/climate/_product.py b/stripe/climate/_product.py index a6ba2fa56..07823436b 100644 --- a/stripe/climate/_product.py +++ b/stripe/climate/_product.py @@ -117,6 +117,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Product.ListParams"] + ) -> ListObject["Product"]: + """ + Lists all available Climate product objects. + """ + 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["Product.RetrieveParams"] @@ -128,6 +149,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Product.RetrieveParams"] + ) -> "Product": + """ + Retrieves the details of a Climate product with the given ID. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "current_prices_per_metric_ton": CurrentPricesPerMetricTon, } diff --git a/stripe/climate/_supplier.py b/stripe/climate/_supplier.py index 63e97b0dc..eeacc535a 100644 --- a/stripe/climate/_supplier.py +++ b/stripe/climate/_supplier.py @@ -116,6 +116,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Supplier.ListParams"] + ) -> ListObject["Supplier"]: + """ + Lists all available Climate supplier objects. + """ + 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["Supplier.RetrieveParams"] @@ -127,4 +148,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Supplier.RetrieveParams"] + ) -> "Supplier": + """ + Retrieves a Climate supplier object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"locations": Location} diff --git a/stripe/entitlements/_event.py b/stripe/entitlements/_event.py index 5f9a51d49..66b1bfd5f 100644 --- a/stripe/entitlements/_event.py +++ b/stripe/entitlements/_event.py @@ -183,6 +183,22 @@ def create(cls, **params: Unpack["Event.CreateParams"]) -> "Event": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Event.CreateParams"] + ) -> "Event": + """ + Create an entitlement event manually, outside of the entitlement events automatically created by Stripe lifecycle events. + """ + return cast( + "Event", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + _inner_class_types = { "grant": Grant, "quantity": Quantity, diff --git a/stripe/entitlements/_feature.py b/stripe/entitlements/_feature.py index f28285115..a28379a46 100644 --- a/stripe/entitlements/_feature.py +++ b/stripe/entitlements/_feature.py @@ -116,6 +116,22 @@ def create(cls, **params: Unpack["Feature.CreateParams"]) -> "Feature": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Feature.CreateParams"] + ) -> "Feature": + """ + Creates a feature + """ + return cast( + "Feature", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Feature.ListParams"] @@ -137,4 +153,25 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Feature.ListParams"] + ) -> ListObject["Feature"]: + """ + Retrieve a list of features + """ + 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 + _inner_class_types = {"quantity": Quantity} diff --git a/stripe/financial_connections/_account.py b/stripe/financial_connections/_account.py index 8c5251ee9..4ddf2a4ad 100644 --- a/stripe/financial_connections/_account.py +++ b/stripe/financial_connections/_account.py @@ -435,6 +435,61 @@ def disconnect( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_disconnect_async( + cls, account: str, **params: Unpack["Account.DisconnectParams"] + ) -> "Account": + """ + Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions). + """ + return cast( + "Account", + await cls._static_request_async( + "post", + "/v1/financial_connections/accounts/{account}/disconnect".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def disconnect_async( + account: str, **params: Unpack["Account.DisconnectParams"] + ) -> "Account": + """ + Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions). + """ + ... + + @overload + async def disconnect_async( + self, **params: Unpack["Account.DisconnectParams"] + ) -> "Account": + """ + Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions). + """ + ... + + @class_method_variant("_cls_disconnect_async") + async def disconnect_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.DisconnectParams"] + ) -> "Account": + """ + Disables your access to a Financial Connections Account. You will no longer be able to access data associated with the account (e.g. balances, transactions). + """ + return cast( + "Account", + await self._request_async( + "post", + "/v1/financial_connections/accounts/{account}/disconnect".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Account.ListParams"] @@ -456,6 +511,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Account.ListParams"] + ) -> ListObject["Account"]: + """ + Returns a list of Financial Connections Account objects. + """ + 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 _cls_list_owners( cls, account: str, **params: Unpack["Account.ListOwnersParams"] @@ -511,6 +587,61 @@ def list_owners( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_owners_async( + cls, account: str, **params: Unpack["Account.ListOwnersParams"] + ) -> ListObject["AccountOwner"]: + """ + Lists all owners for a given Account + """ + return cast( + ListObject["AccountOwner"], + await cls._static_request_async( + "get", + "/v1/financial_connections/accounts/{account}/owners".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_owners_async( + account: str, **params: Unpack["Account.ListOwnersParams"] + ) -> ListObject["AccountOwner"]: + """ + Lists all owners for a given Account + """ + ... + + @overload + async def list_owners_async( + self, **params: Unpack["Account.ListOwnersParams"] + ) -> ListObject["AccountOwner"]: + """ + Lists all owners for a given Account + """ + ... + + @class_method_variant("_cls_list_owners_async") + async def list_owners_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.ListOwnersParams"] + ) -> ListObject["AccountOwner"]: + """ + Lists all owners for a given Account + """ + return cast( + ListObject["AccountOwner"], + await self._request_async( + "get", + "/v1/financial_connections/accounts/{account}/owners".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_refresh_account( cls, account: str, **params: Unpack["Account.RefreshAccountParams"] @@ -566,6 +697,61 @@ def refresh_account( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_refresh_account_async( + cls, account: str, **params: Unpack["Account.RefreshAccountParams"] + ) -> "Account": + """ + Refreshes the data associated with a Financial Connections Account. + """ + return cast( + "Account", + await cls._static_request_async( + "post", + "/v1/financial_connections/accounts/{account}/refresh".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def refresh_account_async( + account: str, **params: Unpack["Account.RefreshAccountParams"] + ) -> "Account": + """ + Refreshes the data associated with a Financial Connections Account. + """ + ... + + @overload + async def refresh_account_async( + self, **params: Unpack["Account.RefreshAccountParams"] + ) -> "Account": + """ + Refreshes the data associated with a Financial Connections Account. + """ + ... + + @class_method_variant("_cls_refresh_account_async") + async def refresh_account_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.RefreshAccountParams"] + ) -> "Account": + """ + Refreshes the data associated with a Financial Connections Account. + """ + return cast( + "Account", + await self._request_async( + "post", + "/v1/financial_connections/accounts/{account}/refresh".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Account.RetrieveParams"] @@ -577,6 +763,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Account.RetrieveParams"] + ) -> "Account": + """ + Retrieves the details of an Financial Connections Account. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_subscribe( cls, account: str, **params: Unpack["Account.SubscribeParams"] @@ -632,6 +829,61 @@ def subscribe( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_subscribe_async( + cls, account: str, **params: Unpack["Account.SubscribeParams"] + ) -> "Account": + """ + Subscribes to periodic refreshes of data associated with a Financial Connections Account. + """ + return cast( + "Account", + await cls._static_request_async( + "post", + "/v1/financial_connections/accounts/{account}/subscribe".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def subscribe_async( + account: str, **params: Unpack["Account.SubscribeParams"] + ) -> "Account": + """ + Subscribes to periodic refreshes of data associated with a Financial Connections Account. + """ + ... + + @overload + async def subscribe_async( + self, **params: Unpack["Account.SubscribeParams"] + ) -> "Account": + """ + Subscribes to periodic refreshes of data associated with a Financial Connections Account. + """ + ... + + @class_method_variant("_cls_subscribe_async") + async def subscribe_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.SubscribeParams"] + ) -> "Account": + """ + Subscribes to periodic refreshes of data associated with a Financial Connections Account. + """ + return cast( + "Account", + await self._request_async( + "post", + "/v1/financial_connections/accounts/{account}/subscribe".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_unsubscribe( cls, account: str, **params: Unpack["Account.UnsubscribeParams"] @@ -687,6 +939,61 @@ def unsubscribe( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_unsubscribe_async( + cls, account: str, **params: Unpack["Account.UnsubscribeParams"] + ) -> "Account": + """ + Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. + """ + return cast( + "Account", + await cls._static_request_async( + "post", + "/v1/financial_connections/accounts/{account}/unsubscribe".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def unsubscribe_async( + account: str, **params: Unpack["Account.UnsubscribeParams"] + ) -> "Account": + """ + Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. + """ + ... + + @overload + async def unsubscribe_async( + self, **params: Unpack["Account.UnsubscribeParams"] + ) -> "Account": + """ + Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. + """ + ... + + @class_method_variant("_cls_unsubscribe_async") + async def unsubscribe_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Account.UnsubscribeParams"] + ) -> "Account": + """ + Unsubscribes from periodic refreshes of data associated with a Financial Connections Account. + """ + return cast( + "Account", + await self._request_async( + "post", + "/v1/financial_connections/accounts/{account}/unsubscribe".format( + account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list_inferred_balances( cls, @@ -707,6 +1014,26 @@ def list_inferred_balances( ), ) + @classmethod + async def list_inferred_balances_async( + cls, + account: str, + **params: Unpack["Account.ListInferredBalancesParams"] + ) -> ListObject["AccountInferredBalance"]: + """ + Lists the recorded inferred balances for a Financial Connections Account. + """ + return cast( + ListObject["AccountInferredBalance"], + await cls._static_request_async( + "get", + "/v1/financial_connections/accounts/{account}/inferred_balances".format( + account=sanitize_id(account) + ), + params=params, + ), + ) + _inner_class_types = { "account_holder": AccountHolder, "balance": Balance, diff --git a/stripe/financial_connections/_account_inferred_balance.py b/stripe/financial_connections/_account_inferred_balance.py index 0afc094e3..c248b1933 100644 --- a/stripe/financial_connections/_account_inferred_balance.py +++ b/stripe/financial_connections/_account_inferred_balance.py @@ -75,3 +75,24 @@ def list( ) return result + + @classmethod + async def list_async( + cls, **params: Unpack["AccountInferredBalance.ListParams"] + ) -> ListObject["AccountInferredBalance"]: + """ + Lists the recorded inferred balances for a Financial Connections Account. + """ + 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 diff --git a/stripe/financial_connections/_session.py b/stripe/financial_connections/_session.py index 153cf6e3a..8711c6da5 100644 --- a/stripe/financial_connections/_session.py +++ b/stripe/financial_connections/_session.py @@ -215,6 +215,22 @@ def create(cls, **params: Unpack["Session.CreateParams"]) -> "Session": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Session.CreateParams"] + ) -> "Session": + """ + To launch the Financial Connections authorization flow, create a Session. The session's client_secret can be used to launch the flow using Stripe.js. + """ + return cast( + "Session", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Session.RetrieveParams"] @@ -226,6 +242,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Session.RetrieveParams"] + ) -> "Session": + """ + Retrieves the details of a Financial Connections Session + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "account_holder": AccountHolder, "filters": Filters, diff --git a/stripe/financial_connections/_transaction.py b/stripe/financial_connections/_transaction.py index f08dec81e..191383592 100644 --- a/stripe/financial_connections/_transaction.py +++ b/stripe/financial_connections/_transaction.py @@ -156,6 +156,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Transaction.ListParams"] + ) -> ListObject["Transaction"]: + """ + Returns a list of Financial Connections Transaction objects. + """ + 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["Transaction.RetrieveParams"] @@ -167,4 +188,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Transaction.RetrieveParams"] + ) -> "Transaction": + """ + Retrieves the details of a Financial Connections Transaction + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"status_transitions": StatusTransitions} diff --git a/stripe/gift_cards/_card.py b/stripe/gift_cards/_card.py index 7bcc1ad45..17b9208a5 100644 --- a/stripe/gift_cards/_card.py +++ b/stripe/gift_cards/_card.py @@ -225,6 +225,22 @@ def create(cls, **params: Unpack["Card.CreateParams"]) -> "Card": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Card.CreateParams"] + ) -> "Card": + """ + Creates a new gift card object. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Card.ListParams"]) -> ListObject["Card"]: """ @@ -244,6 +260,27 @@ def list(cls, **params: Unpack["Card.ListParams"]) -> ListObject["Card"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Card.ListParams"] + ) -> ListObject["Card"]: + """ + List gift cards for an account + """ + 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["Card.ModifyParams"]) -> "Card": """ @@ -259,6 +296,23 @@ def modify(cls, id: str, **params: Unpack["Card.ModifyParams"]) -> "Card": ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Card.ModifyParams"] + ) -> "Card": + """ + Update a gift card + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Card", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Card.RetrieveParams"] @@ -270,6 +324,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Card.RetrieveParams"] + ) -> "Card": + """ + Retrieve a gift card by id + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def validate(cls, **params: Unpack["Card.ValidateParams"]) -> "Card": """ @@ -284,4 +349,20 @@ def validate(cls, **params: Unpack["Card.ValidateParams"]) -> "Card": ), ) + @classmethod + async def validate_async( + cls, **params: Unpack["Card.ValidateParams"] + ) -> "Card": + """ + Validates a gift card code, returning the matching gift card object if it exists. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + "/v1/gift_cards/cards/validate", + params=params, + ), + ) + _inner_class_types = {"created_by": CreatedBy} diff --git a/stripe/gift_cards/_transaction.py b/stripe/gift_cards/_transaction.py index acfa388ec..9b889f614 100644 --- a/stripe/gift_cards/_transaction.py +++ b/stripe/gift_cards/_transaction.py @@ -285,6 +285,61 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, id: str, **params: Unpack["Transaction.CancelParams"] + ) -> "Transaction": + """ + Cancel a gift card transaction + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/gift_cards/transactions/{id}/cancel".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + id: str, **params: Unpack["Transaction.CancelParams"] + ) -> "Transaction": + """ + Cancel a gift card transaction + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["Transaction.CancelParams"] + ) -> "Transaction": + """ + Cancel a gift card transaction + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Transaction.CancelParams"] + ) -> "Transaction": + """ + Cancel a gift card transaction + """ + return cast( + "Transaction", + await self._request_async( + "post", + "/v1/gift_cards/transactions/{id}/cancel".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_confirm( cls, id: str, **params: Unpack["Transaction.ConfirmParams"] @@ -340,6 +395,61 @@ def confirm( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_confirm_async( + cls, id: str, **params: Unpack["Transaction.ConfirmParams"] + ) -> "Transaction": + """ + Confirm a gift card transaction + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/gift_cards/transactions/{id}/confirm".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def confirm_async( + id: str, **params: Unpack["Transaction.ConfirmParams"] + ) -> "Transaction": + """ + Confirm a gift card transaction + """ + ... + + @overload + async def confirm_async( + self, **params: Unpack["Transaction.ConfirmParams"] + ) -> "Transaction": + """ + Confirm a gift card transaction + """ + ... + + @class_method_variant("_cls_confirm_async") + async def confirm_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Transaction.ConfirmParams"] + ) -> "Transaction": + """ + Confirm a gift card transaction + """ + return cast( + "Transaction", + await self._request_async( + "post", + "/v1/gift_cards/transactions/{id}/confirm".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["Transaction.CreateParams"] @@ -356,6 +466,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Transaction.CreateParams"] + ) -> "Transaction": + """ + Create a gift card transaction + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Transaction.ListParams"] @@ -377,6 +503,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Transaction.ListParams"] + ) -> ListObject["Transaction"]: + """ + List gift card transactions for a gift card + """ + 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["Transaction.ModifyParams"] @@ -394,6 +541,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Transaction.ModifyParams"] + ) -> "Transaction": + """ + Update a gift card transaction + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Transaction", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Transaction.RetrieveParams"] @@ -405,4 +569,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Transaction.RetrieveParams"] + ) -> "Transaction": + """ + Retrieves the gift card transaction. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"created_by": CreatedBy} diff --git a/stripe/identity/_verification_report.py b/stripe/identity/_verification_report.py index c1dec98ff..ebeacac64 100644 --- a/stripe/identity/_verification_report.py +++ b/stripe/identity/_verification_report.py @@ -403,6 +403,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["VerificationReport.ListParams"] + ) -> ListObject["VerificationReport"]: + """ + List all verification reports. + """ + 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["VerificationReport.RetrieveParams"] @@ -414,6 +435,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["VerificationReport.RetrieveParams"] + ) -> "VerificationReport": + """ + Retrieves an existing VerificationReport + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "document": Document, "id_number": IdNumber, diff --git a/stripe/identity/_verification_session.py b/stripe/identity/_verification_session.py index d668cefb1..4d3045c25 100644 --- a/stripe/identity/_verification_session.py +++ b/stripe/identity/_verification_session.py @@ -450,6 +450,69 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, session: str, **params: Unpack["VerificationSession.CancelParams"] + ) -> "VerificationSession": + """ + A VerificationSession object can be canceled when it is in requires_input [status](https://stripe.com/docs/identity/how-sessions-work). + + Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). + """ + return cast( + "VerificationSession", + await cls._static_request_async( + "post", + "/v1/identity/verification_sessions/{session}/cancel".format( + session=sanitize_id(session) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + session: str, **params: Unpack["VerificationSession.CancelParams"] + ) -> "VerificationSession": + """ + A VerificationSession object can be canceled when it is in requires_input [status](https://stripe.com/docs/identity/how-sessions-work). + + Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["VerificationSession.CancelParams"] + ) -> "VerificationSession": + """ + A VerificationSession object can be canceled when it is in requires_input [status](https://stripe.com/docs/identity/how-sessions-work). + + Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["VerificationSession.CancelParams"] + ) -> "VerificationSession": + """ + A VerificationSession object can be canceled when it is in requires_input [status](https://stripe.com/docs/identity/how-sessions-work). + + Once canceled, future submission attempts are disabled. This cannot be undone. [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). + """ + return cast( + "VerificationSession", + await self._request_async( + "post", + "/v1/identity/verification_sessions/{session}/cancel".format( + session=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["VerificationSession.CreateParams"] @@ -472,6 +535,28 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["VerificationSession.CreateParams"] + ) -> "VerificationSession": + """ + Creates a VerificationSession object. + + After the VerificationSession is created, display a verification modal using the session client_secret or send your users to the session's url. + + If your API key is in test mode, verification checks won't actually process, though everything else will occur as if in live mode. + + Related guide: [Verify your users' identity documents](https://stripe.com/docs/identity/verify-identity-documents) + """ + return cast( + "VerificationSession", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["VerificationSession.ListParams"] @@ -493,6 +578,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["VerificationSession.ListParams"] + ) -> ListObject["VerificationSession"]: + """ + Returns a list of VerificationSessions + """ + 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["VerificationSession.ModifyParams"] @@ -513,6 +619,26 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["VerificationSession.ModifyParams"] + ) -> "VerificationSession": + """ + Updates a VerificationSession object. + + When the session status is requires_input, you can use this method to update the + verification check and options. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "VerificationSession", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def _cls_redact( cls, session: str, **params: Unpack["VerificationSession.RedactParams"] @@ -640,6 +766,133 @@ def redact( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_redact_async( + cls, session: str, **params: Unpack["VerificationSession.RedactParams"] + ) -> "VerificationSession": + """ + Redact a VerificationSession to remove all collected information from Stripe. This will redact + the VerificationSession and all objects related to it, including VerificationReports, Events, + request logs, etc. + + A VerificationSession object can be redacted when it is in requires_input or verified + [status](https://stripe.com/docs/identity/how-sessions-work). Redacting a VerificationSession in requires_action + state will automatically cancel it. + + The redaction process may take up to four days. When the redaction process is in progress, the + VerificationSession's redaction.status field will be set to processing; when the process is + finished, it will change to redacted and an identity.verification_session.redacted event + will be emitted. + + Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the + fields that contain personal data will be replaced by the string [redacted] or a similar + placeholder. The metadata field will also be erased. Redacted objects cannot be updated or + used for any purpose. + + [Learn more](https://stripe.com/docs/identity/verification-sessions#redact). + """ + return cast( + "VerificationSession", + await cls._static_request_async( + "post", + "/v1/identity/verification_sessions/{session}/redact".format( + session=sanitize_id(session) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def redact_async( + session: str, **params: Unpack["VerificationSession.RedactParams"] + ) -> "VerificationSession": + """ + Redact a VerificationSession to remove all collected information from Stripe. This will redact + the VerificationSession and all objects related to it, including VerificationReports, Events, + request logs, etc. + + A VerificationSession object can be redacted when it is in requires_input or verified + [status](https://stripe.com/docs/identity/how-sessions-work). Redacting a VerificationSession in requires_action + state will automatically cancel it. + + The redaction process may take up to four days. When the redaction process is in progress, the + VerificationSession's redaction.status field will be set to processing; when the process is + finished, it will change to redacted and an identity.verification_session.redacted event + will be emitted. + + Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the + fields that contain personal data will be replaced by the string [redacted] or a similar + placeholder. The metadata field will also be erased. Redacted objects cannot be updated or + used for any purpose. + + [Learn more](https://stripe.com/docs/identity/verification-sessions#redact). + """ + ... + + @overload + async def redact_async( + self, **params: Unpack["VerificationSession.RedactParams"] + ) -> "VerificationSession": + """ + Redact a VerificationSession to remove all collected information from Stripe. This will redact + the VerificationSession and all objects related to it, including VerificationReports, Events, + request logs, etc. + + A VerificationSession object can be redacted when it is in requires_input or verified + [status](https://stripe.com/docs/identity/how-sessions-work). Redacting a VerificationSession in requires_action + state will automatically cancel it. + + The redaction process may take up to four days. When the redaction process is in progress, the + VerificationSession's redaction.status field will be set to processing; when the process is + finished, it will change to redacted and an identity.verification_session.redacted event + will be emitted. + + Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the + fields that contain personal data will be replaced by the string [redacted] or a similar + placeholder. The metadata field will also be erased. Redacted objects cannot be updated or + used for any purpose. + + [Learn more](https://stripe.com/docs/identity/verification-sessions#redact). + """ + ... + + @class_method_variant("_cls_redact_async") + async def redact_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["VerificationSession.RedactParams"] + ) -> "VerificationSession": + """ + Redact a VerificationSession to remove all collected information from Stripe. This will redact + the VerificationSession and all objects related to it, including VerificationReports, Events, + request logs, etc. + + A VerificationSession object can be redacted when it is in requires_input or verified + [status](https://stripe.com/docs/identity/how-sessions-work). Redacting a VerificationSession in requires_action + state will automatically cancel it. + + The redaction process may take up to four days. When the redaction process is in progress, the + VerificationSession's redaction.status field will be set to processing; when the process is + finished, it will change to redacted and an identity.verification_session.redacted event + will be emitted. + + Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the + fields that contain personal data will be replaced by the string [redacted] or a similar + placeholder. The metadata field will also be erased. Redacted objects cannot be updated or + used for any purpose. + + [Learn more](https://stripe.com/docs/identity/verification-sessions#redact). + """ + return cast( + "VerificationSession", + await self._request_async( + "post", + "/v1/identity/verification_sessions/{session}/redact".format( + session=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["VerificationSession.RetrieveParams"] @@ -654,6 +907,20 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["VerificationSession.RetrieveParams"] + ) -> "VerificationSession": + """ + Retrieves the details of a VerificationSession that was previously created. + + When the session status is requires_input, you can use this method to retrieve a valid + client_secret or url to allow re-submission. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "last_error": LastError, "options": Options, diff --git a/stripe/issuing/_authorization.py b/stripe/issuing/_authorization.py index 09b794fef..492889583 100644 --- a/stripe/issuing/_authorization.py +++ b/stripe/issuing/_authorization.py @@ -869,6 +869,67 @@ def approve( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_approve_async( + cls, + authorization: str, + **params: Unpack["Authorization.ApproveParams"] + ) -> "Authorization": + """ + [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/issuing/authorizations/{authorization}/approve".format( + authorization=sanitize_id(authorization) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def approve_async( + authorization: str, **params: Unpack["Authorization.ApproveParams"] + ) -> "Authorization": + """ + [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + ... + + @overload + async def approve_async( + self, **params: Unpack["Authorization.ApproveParams"] + ) -> "Authorization": + """ + [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + ... + + @class_method_variant("_cls_approve_async") + async def approve_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Authorization.ApproveParams"] + ) -> "Authorization": + """ + [Deprecated] Approves a pending Issuing Authorization object. This request should be made within the timeout window of the [real-time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + return cast( + "Authorization", + await self._request_async( + "post", + "/v1/issuing/authorizations/{authorization}/approve".format( + authorization=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_decline( cls, @@ -930,6 +991,67 @@ def decline( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_decline_async( + cls, + authorization: str, + **params: Unpack["Authorization.DeclineParams"] + ) -> "Authorization": + """ + [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/issuing/authorizations/{authorization}/decline".format( + authorization=sanitize_id(authorization) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def decline_async( + authorization: str, **params: Unpack["Authorization.DeclineParams"] + ) -> "Authorization": + """ + [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + ... + + @overload + async def decline_async( + self, **params: Unpack["Authorization.DeclineParams"] + ) -> "Authorization": + """ + [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + ... + + @class_method_variant("_cls_decline_async") + async def decline_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Authorization.DeclineParams"] + ) -> "Authorization": + """ + [Deprecated] Declines a pending Issuing Authorization object. This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. + This method is deprecated. Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). + """ + return cast( + "Authorization", + await self._request_async( + "post", + "/v1/issuing/authorizations/{authorization}/decline".format( + authorization=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Authorization.ListParams"] @@ -951,6 +1073,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Authorization.ListParams"] + ) -> ListObject["Authorization"]: + """ + Returns a list of Issuing Authorization objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["Authorization.ModifyParams"] @@ -968,6 +1111,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Authorization.ModifyParams"] + ) -> "Authorization": + """ + Updates the specified Issuing Authorization object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Authorization", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Authorization.RetrieveParams"] @@ -979,6 +1139,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Authorization.RetrieveParams"] + ) -> "Authorization": + """ + Retrieves an Issuing Authorization object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["Authorization"]): _resource_cls: Type["Authorization"] @@ -1039,6 +1210,63 @@ def capture( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_capture_async( + cls, + authorization: str, + **params: Unpack["Authorization.CaptureParams"] + ) -> "Authorization": + """ + Capture a test-mode authorization. + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/capture".format( + authorization=sanitize_id(authorization) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def capture_async( + authorization: str, **params: Unpack["Authorization.CaptureParams"] + ) -> "Authorization": + """ + Capture a test-mode authorization. + """ + ... + + @overload + async def capture_async( + self, **params: Unpack["Authorization.CaptureParams"] + ) -> "Authorization": + """ + Capture a test-mode authorization. + """ + ... + + @class_method_variant("_cls_capture_async") + async def capture_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Authorization.CaptureParams"] + ) -> "Authorization": + """ + Capture a test-mode authorization. + """ + return cast( + "Authorization", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/capture".format( + authorization=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["Authorization.CreateParams"] @@ -1055,6 +1283,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Authorization.CreateParams"] + ) -> "Authorization": + """ + Create a test-mode authorization. + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/authorizations", + params=params, + ), + ) + @classmethod def _cls_expire( cls, @@ -1112,6 +1356,63 @@ def expire( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_expire_async( + cls, + authorization: str, + **params: Unpack["Authorization.ExpireParams"] + ) -> "Authorization": + """ + Expire a test-mode Authorization. + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/expire".format( + authorization=sanitize_id(authorization) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def expire_async( + authorization: str, **params: Unpack["Authorization.ExpireParams"] + ) -> "Authorization": + """ + Expire a test-mode Authorization. + """ + ... + + @overload + async def expire_async( + self, **params: Unpack["Authorization.ExpireParams"] + ) -> "Authorization": + """ + Expire a test-mode Authorization. + """ + ... + + @class_method_variant("_cls_expire_async") + async def expire_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Authorization.ExpireParams"] + ) -> "Authorization": + """ + Expire a test-mode Authorization. + """ + return cast( + "Authorization", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/expire".format( + authorization=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_increment( cls, @@ -1170,6 +1471,64 @@ def increment( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_increment_async( + cls, + authorization: str, + **params: Unpack["Authorization.IncrementParams"] + ) -> "Authorization": + """ + Increment a test-mode Authorization. + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/increment".format( + authorization=sanitize_id(authorization) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def increment_async( + authorization: str, + **params: Unpack["Authorization.IncrementParams"] + ) -> "Authorization": + """ + Increment a test-mode Authorization. + """ + ... + + @overload + async def increment_async( + self, **params: Unpack["Authorization.IncrementParams"] + ) -> "Authorization": + """ + Increment a test-mode Authorization. + """ + ... + + @class_method_variant("_cls_increment_async") + async def increment_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Authorization.IncrementParams"] + ) -> "Authorization": + """ + Increment a test-mode Authorization. + """ + return cast( + "Authorization", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/increment".format( + authorization=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_reverse( cls, @@ -1227,6 +1586,63 @@ def reverse( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_reverse_async( + cls, + authorization: str, + **params: Unpack["Authorization.ReverseParams"] + ) -> "Authorization": + """ + Reverse a test-mode Authorization. + """ + return cast( + "Authorization", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/reverse".format( + authorization=sanitize_id(authorization) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def reverse_async( + authorization: str, **params: Unpack["Authorization.ReverseParams"] + ) -> "Authorization": + """ + Reverse a test-mode Authorization. + """ + ... + + @overload + async def reverse_async( + self, **params: Unpack["Authorization.ReverseParams"] + ) -> "Authorization": + """ + Reverse a test-mode Authorization. + """ + ... + + @class_method_variant("_cls_reverse_async") + async def reverse_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Authorization.ReverseParams"] + ) -> "Authorization": + """ + Reverse a test-mode Authorization. + """ + return cast( + "Authorization", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/authorizations/{authorization}/reverse".format( + authorization=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/issuing/_card.py b/stripe/issuing/_card.py index ac7f248d9..2c430185b 100644 --- a/stripe/issuing/_card.py +++ b/stripe/issuing/_card.py @@ -1705,6 +1705,22 @@ def create(cls, **params: Unpack["Card.CreateParams"]) -> "Card": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Card.CreateParams"] + ) -> "Card": + """ + Creates an Issuing Card object. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list(cls, **params: Unpack["Card.ListParams"]) -> ListObject["Card"]: """ @@ -1724,6 +1740,27 @@ def list(cls, **params: Unpack["Card.ListParams"]) -> ListObject["Card"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Card.ListParams"] + ) -> ListObject["Card"]: + """ + Returns a list of Issuing Card objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["Card.ModifyParams"]) -> "Card": """ @@ -1739,6 +1776,23 @@ def modify(cls, id: str, **params: Unpack["Card.ModifyParams"]) -> "Card": ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Card.ModifyParams"] + ) -> "Card": + """ + Updates the specified Issuing Card object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Card", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Card.RetrieveParams"] @@ -1750,6 +1804,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Card.RetrieveParams"] + ) -> "Card": + """ + Retrieves an Issuing Card object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["Card"]): _resource_cls: Type["Card"] @@ -1808,6 +1873,61 @@ def deliver_card( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_deliver_card_async( + cls, card: str, **params: Unpack["Card.DeliverCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to delivered. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/deliver".format( + card=sanitize_id(card) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def deliver_card_async( + card: str, **params: Unpack["Card.DeliverCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to delivered. + """ + ... + + @overload + async def deliver_card_async( + self, **params: Unpack["Card.DeliverCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to delivered. + """ + ... + + @class_method_variant("_cls_deliver_card_async") + async def deliver_card_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Card.DeliverCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to delivered. + """ + return cast( + "Card", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/deliver".format( + card=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_fail_card( cls, card: str, **params: Unpack["Card.FailCardParams"] @@ -1861,6 +1981,61 @@ def fail_card( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_fail_card_async( + cls, card: str, **params: Unpack["Card.FailCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to failure. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/fail".format( + card=sanitize_id(card) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def fail_card_async( + card: str, **params: Unpack["Card.FailCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to failure. + """ + ... + + @overload + async def fail_card_async( + self, **params: Unpack["Card.FailCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to failure. + """ + ... + + @class_method_variant("_cls_fail_card_async") + async def fail_card_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Card.FailCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to failure. + """ + return cast( + "Card", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/fail".format( + card=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_return_card( cls, card: str, **params: Unpack["Card.ReturnCardParams"] @@ -1916,6 +2091,61 @@ def return_card( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_return_card_async( + cls, card: str, **params: Unpack["Card.ReturnCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to returned. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/return".format( + card=sanitize_id(card) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def return_card_async( + card: str, **params: Unpack["Card.ReturnCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to returned. + """ + ... + + @overload + async def return_card_async( + self, **params: Unpack["Card.ReturnCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to returned. + """ + ... + + @class_method_variant("_cls_return_card_async") + async def return_card_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Card.ReturnCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to returned. + """ + return cast( + "Card", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/return".format( + card=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_ship_card( cls, card: str, **params: Unpack["Card.ShipCardParams"] @@ -1969,6 +2199,61 @@ def ship_card( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_ship_card_async( + cls, card: str, **params: Unpack["Card.ShipCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to shipped. + """ + return cast( + "Card", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/ship".format( + card=sanitize_id(card) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def ship_card_async( + card: str, **params: Unpack["Card.ShipCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to shipped. + """ + ... + + @overload + async def ship_card_async( + self, **params: Unpack["Card.ShipCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to shipped. + """ + ... + + @class_method_variant("_cls_ship_card_async") + async def ship_card_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Card.ShipCardParams"] + ) -> "Card": + """ + Updates the shipping status of the specified Issuing Card object to shipped. + """ + return cast( + "Card", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/cards/{card}/shipping/ship".format( + card=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/issuing/_cardholder.py b/stripe/issuing/_cardholder.py index fdead322b..db235f9ea 100644 --- a/stripe/issuing/_cardholder.py +++ b/stripe/issuing/_cardholder.py @@ -1691,6 +1691,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Cardholder.CreateParams"] + ) -> "Cardholder": + """ + Creates a new Issuing Cardholder object that can be issued cards. + """ + return cast( + "Cardholder", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Cardholder.ListParams"] @@ -1712,6 +1728,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Cardholder.ListParams"] + ) -> ListObject["Cardholder"]: + """ + Returns a list of Issuing Cardholder objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["Cardholder.ModifyParams"] @@ -1729,6 +1766,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Cardholder.ModifyParams"] + ) -> "Cardholder": + """ + Updates the specified Issuing Cardholder object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Cardholder", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Cardholder.RetrieveParams"] @@ -1740,6 +1794,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Cardholder.RetrieveParams"] + ) -> "Cardholder": + """ + Retrieves an Issuing Cardholder object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "billing": Billing, "company": Company, diff --git a/stripe/issuing/_credit_underwriting_record.py b/stripe/issuing/_credit_underwriting_record.py index f71fba98b..238439d8f 100644 --- a/stripe/issuing/_credit_underwriting_record.py +++ b/stripe/issuing/_credit_underwriting_record.py @@ -1342,6 +1342,66 @@ def correct( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_correct_async( + cls, + credit_underwriting_record: str, + **params: Unpack["CreditUnderwritingRecord.CorrectParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object to correct mistakes. + """ + return cast( + "CreditUnderwritingRecord", + await cls._static_request_async( + "post", + "/v1/issuing/credit_underwriting_records/{credit_underwriting_record}/correct".format( + credit_underwriting_record=sanitize_id( + credit_underwriting_record + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def correct_async( + credit_underwriting_record: str, + **params: Unpack["CreditUnderwritingRecord.CorrectParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object to correct mistakes. + """ + ... + + @overload + async def correct_async( + self, **params: Unpack["CreditUnderwritingRecord.CorrectParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object to correct mistakes. + """ + ... + + @class_method_variant("_cls_correct_async") + async def correct_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditUnderwritingRecord.CorrectParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object to correct mistakes. + """ + return cast( + "CreditUnderwritingRecord", + await self._request_async( + "post", + "/v1/issuing/credit_underwriting_records/{credit_underwriting_record}/correct".format( + credit_underwriting_record=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create_from_application( cls, @@ -1361,6 +1421,25 @@ def create_from_application( ), ) + @classmethod + async def create_from_application_async( + cls, + **params: Unpack[ + "CreditUnderwritingRecord.CreateFromApplicationParams" + ] + ) -> "CreditUnderwritingRecord": + """ + Creates a CreditUnderwritingRecord object with information about a credit application submission. + """ + return cast( + "CreditUnderwritingRecord", + await cls._static_request_async( + "post", + "/v1/issuing/credit_underwriting_records/create_from_application", + params=params, + ), + ) + @classmethod def create_from_proactive_review( cls, @@ -1380,6 +1459,25 @@ def create_from_proactive_review( ), ) + @classmethod + async def create_from_proactive_review_async( + cls, + **params: Unpack[ + "CreditUnderwritingRecord.CreateFromProactiveReviewParams" + ] + ) -> "CreditUnderwritingRecord": + """ + Creates a CreditUnderwritingRecord object from an underwriting decision coming from a proactive review of an existing accountholder. + """ + return cast( + "CreditUnderwritingRecord", + await cls._static_request_async( + "post", + "/v1/issuing/credit_underwriting_records/create_from_proactive_review", + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["CreditUnderwritingRecord.ListParams"] @@ -1401,6 +1499,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CreditUnderwritingRecord.ListParams"] + ) -> ListObject["CreditUnderwritingRecord"]: + """ + Retrieves a list of CreditUnderwritingRecord objects. The objects are sorted in descending order by creation date, with the most-recently-created object appearing first. + """ + 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 _cls_report_decision( cls, @@ -1461,6 +1580,66 @@ def report_decision( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_report_decision_async( + cls, + credit_underwriting_record: str, + **params: Unpack["CreditUnderwritingRecord.ReportDecisionParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object from a decision made on a credit application. + """ + return cast( + "CreditUnderwritingRecord", + await cls._static_request_async( + "post", + "/v1/issuing/credit_underwriting_records/{credit_underwriting_record}/report_decision".format( + credit_underwriting_record=sanitize_id( + credit_underwriting_record + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def report_decision_async( + credit_underwriting_record: str, + **params: Unpack["CreditUnderwritingRecord.ReportDecisionParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object from a decision made on a credit application. + """ + ... + + @overload + async def report_decision_async( + self, **params: Unpack["CreditUnderwritingRecord.ReportDecisionParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object from a decision made on a credit application. + """ + ... + + @class_method_variant("_cls_report_decision_async") + async def report_decision_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["CreditUnderwritingRecord.ReportDecisionParams"] + ) -> "CreditUnderwritingRecord": + """ + Update a CreditUnderwritingRecord object from a decision made on a credit application. + """ + return cast( + "CreditUnderwritingRecord", + await self._request_async( + "post", + "/v1/issuing/credit_underwriting_records/{credit_underwriting_record}/report_decision".format( + credit_underwriting_record=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, @@ -1474,6 +1653,19 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, + id: str, + **params: Unpack["CreditUnderwritingRecord.RetrieveParams"] + ) -> "CreditUnderwritingRecord": + """ + Retrieves a CreditUnderwritingRecord object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "application": Application, "credit_user": CreditUser, diff --git a/stripe/issuing/_dispute.py b/stripe/issuing/_dispute.py index e51c3acf1..0cf0b2f1e 100644 --- a/stripe/issuing/_dispute.py +++ b/stripe/issuing/_dispute.py @@ -866,6 +866,22 @@ def create(cls, **params: Unpack["Dispute.CreateParams"]) -> "Dispute": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Dispute.CreateParams"] + ) -> "Dispute": + """ + Creates an Issuing Dispute object. Individual pieces of evidence within the evidence object are optional at this point. Stripe only validates that required evidence is present during submission. Refer to [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence) for more details about evidence requirements. + """ + return cast( + "Dispute", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Dispute.ListParams"] @@ -887,6 +903,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Dispute.ListParams"] + ) -> ListObject["Dispute"]: + """ + Returns a list of Issuing Dispute objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["Dispute.ModifyParams"] @@ -904,6 +941,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Dispute.ModifyParams"] + ) -> "Dispute": + """ + Updates the specified Issuing Dispute object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Properties on the evidence object can be unset by passing in an empty string. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Dispute", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Dispute.RetrieveParams"] @@ -915,6 +969,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Dispute.RetrieveParams"] + ) -> "Dispute": + """ + Retrieves an Issuing Dispute object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_submit( cls, dispute: str, **params: Unpack["Dispute.SubmitParams"] @@ -968,4 +1033,59 @@ def submit( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_submit_async( + cls, dispute: str, **params: Unpack["Dispute.SubmitParams"] + ) -> "Dispute": + """ + Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). + """ + return cast( + "Dispute", + await cls._static_request_async( + "post", + "/v1/issuing/disputes/{dispute}/submit".format( + dispute=sanitize_id(dispute) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def submit_async( + dispute: str, **params: Unpack["Dispute.SubmitParams"] + ) -> "Dispute": + """ + Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). + """ + ... + + @overload + async def submit_async( + self, **params: Unpack["Dispute.SubmitParams"] + ) -> "Dispute": + """ + Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). + """ + ... + + @class_method_variant("_cls_submit_async") + async def submit_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Dispute.SubmitParams"] + ) -> "Dispute": + """ + Submits an Issuing Dispute to the card network. Stripe validates that all evidence fields required for the dispute's reason are present. For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). + """ + return cast( + "Dispute", + await self._request_async( + "post", + "/v1/issuing/disputes/{dispute}/submit".format( + dispute=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + _inner_class_types = {"evidence": Evidence, "treasury": Treasury} diff --git a/stripe/issuing/_personalization_design.py b/stripe/issuing/_personalization_design.py index 669e79906..b649f85a4 100644 --- a/stripe/issuing/_personalization_design.py +++ b/stripe/issuing/_personalization_design.py @@ -375,6 +375,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["PersonalizationDesign.CreateParams"] + ) -> "PersonalizationDesign": + """ + Creates a personalization design object. + """ + return cast( + "PersonalizationDesign", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["PersonalizationDesign.ListParams"] @@ -396,6 +412,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PersonalizationDesign.ListParams"] + ) -> ListObject["PersonalizationDesign"]: + """ + Returns a list of personalization design objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["PersonalizationDesign.ModifyParams"] @@ -413,6 +450,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["PersonalizationDesign.ModifyParams"] + ) -> "PersonalizationDesign": + """ + Updates a card personalization object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "PersonalizationDesign", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["PersonalizationDesign.RetrieveParams"] @@ -424,6 +478,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PersonalizationDesign.RetrieveParams"] + ) -> "PersonalizationDesign": + """ + Retrieves a personalization design object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["PersonalizationDesign"]): _resource_cls: Type["PersonalizationDesign"] @@ -489,6 +554,68 @@ def activate( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_activate_async( + cls, + personalization_design: str, + **params: Unpack["PersonalizationDesign.ActivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to active. + """ + return cast( + "PersonalizationDesign", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/activate".format( + personalization_design=sanitize_id( + personalization_design + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def activate_async( + personalization_design: str, + **params: Unpack["PersonalizationDesign.ActivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to active. + """ + ... + + @overload + async def activate_async( + self, **params: Unpack["PersonalizationDesign.ActivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to active. + """ + ... + + @class_method_variant("_cls_activate_async") + async def activate_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PersonalizationDesign.ActivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to active. + """ + return cast( + "PersonalizationDesign", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/activate".format( + personalization_design=sanitize_id( + self.resource.get("id") + ) + ), + params=params, + ), + ) + @classmethod def _cls_deactivate( cls, @@ -551,6 +678,68 @@ def deactivate( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_deactivate_async( + cls, + personalization_design: str, + **params: Unpack["PersonalizationDesign.DeactivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to inactive. + """ + return cast( + "PersonalizationDesign", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/deactivate".format( + personalization_design=sanitize_id( + personalization_design + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def deactivate_async( + personalization_design: str, + **params: Unpack["PersonalizationDesign.DeactivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to inactive. + """ + ... + + @overload + async def deactivate_async( + self, **params: Unpack["PersonalizationDesign.DeactivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to inactive. + """ + ... + + @class_method_variant("_cls_deactivate_async") + async def deactivate_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PersonalizationDesign.DeactivateParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to inactive. + """ + return cast( + "PersonalizationDesign", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/deactivate".format( + personalization_design=sanitize_id( + self.resource.get("id") + ) + ), + params=params, + ), + ) + @classmethod def _cls_reject( cls, @@ -613,6 +802,68 @@ def reject( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_reject_async( + cls, + personalization_design: str, + **params: Unpack["PersonalizationDesign.RejectParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to rejected. + """ + return cast( + "PersonalizationDesign", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/reject".format( + personalization_design=sanitize_id( + personalization_design + ) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def reject_async( + personalization_design: str, + **params: Unpack["PersonalizationDesign.RejectParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to rejected. + """ + ... + + @overload + async def reject_async( + self, **params: Unpack["PersonalizationDesign.RejectParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to rejected. + """ + ... + + @class_method_variant("_cls_reject_async") + async def reject_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["PersonalizationDesign.RejectParams"] + ) -> "PersonalizationDesign": + """ + Updates the status of the specified testmode personalization design object to rejected. + """ + return cast( + "PersonalizationDesign", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/personalization_designs/{personalization_design}/reject".format( + personalization_design=sanitize_id( + self.resource.get("id") + ) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/issuing/_physical_bundle.py b/stripe/issuing/_physical_bundle.py index f63e4d88b..e1d7a1c43 100644 --- a/stripe/issuing/_physical_bundle.py +++ b/stripe/issuing/_physical_bundle.py @@ -106,6 +106,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["PhysicalBundle.ListParams"] + ) -> ListObject["PhysicalBundle"]: + """ + Returns a list of physical bundle objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["PhysicalBundle.RetrieveParams"] @@ -117,4 +138,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["PhysicalBundle.RetrieveParams"] + ) -> "PhysicalBundle": + """ + Retrieves a physical bundle object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"features": Features} diff --git a/stripe/issuing/_token.py b/stripe/issuing/_token.py index 5ec5c7c58..4a56dd193 100644 --- a/stripe/issuing/_token.py +++ b/stripe/issuing/_token.py @@ -325,6 +325,27 @@ def list(cls, **params: Unpack["Token.ListParams"]) -> ListObject["Token"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Token.ListParams"] + ) -> ListObject["Token"]: + """ + Lists all Issuing Token objects for a given card. + """ + 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["Token.ModifyParams"] @@ -342,6 +363,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Token.ModifyParams"] + ) -> "Token": + """ + Attempts to update the specified Issuing Token object to the status specified. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Token", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Token.RetrieveParams"] @@ -353,4 +391,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Token.RetrieveParams"] + ) -> "Token": + """ + Retrieves an Issuing Token object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"network_data": NetworkData} diff --git a/stripe/issuing/_transaction.py b/stripe/issuing/_transaction.py index 36bd97f4d..c67dc9674 100644 --- a/stripe/issuing/_transaction.py +++ b/stripe/issuing/_transaction.py @@ -799,6 +799,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Transaction.ListParams"] + ) -> ListObject["Transaction"]: + """ + Returns a list of Issuing Transaction objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["Transaction.ModifyParams"] @@ -816,6 +837,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Transaction.ModifyParams"] + ) -> "Transaction": + """ + Updates the specified Issuing Transaction object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Transaction", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Transaction.RetrieveParams"] @@ -827,6 +865,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Transaction.RetrieveParams"] + ) -> "Transaction": + """ + Retrieves an Issuing Transaction object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["Transaction"]): _resource_cls: Type["Transaction"] @@ -846,6 +895,22 @@ def create_force_capture( ), ) + @classmethod + async def create_force_capture_async( + cls, **params: Unpack["Transaction.CreateForceCaptureParams"] + ) -> "Transaction": + """ + Allows the user to capture an arbitrary amount, also known as a forced capture. + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/transactions/create_force_capture", + params=params, + ), + ) + @classmethod def create_unlinked_refund( cls, **params: Unpack["Transaction.CreateUnlinkedRefundParams"] @@ -862,6 +927,22 @@ def create_unlinked_refund( ), ) + @classmethod + async def create_unlinked_refund_async( + cls, **params: Unpack["Transaction.CreateUnlinkedRefundParams"] + ) -> "Transaction": + """ + Allows the user to refund an arbitrary amount, also known as a unlinked refund. + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/transactions/create_unlinked_refund", + params=params, + ), + ) + @classmethod def _cls_refund( cls, transaction: str, **params: Unpack["Transaction.RefundParams"] @@ -917,6 +998,61 @@ def refund( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_refund_async( + cls, transaction: str, **params: Unpack["Transaction.RefundParams"] + ) -> "Transaction": + """ + Refund a test-mode Transaction. + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/test_helpers/issuing/transactions/{transaction}/refund".format( + transaction=sanitize_id(transaction) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def refund_async( + transaction: str, **params: Unpack["Transaction.RefundParams"] + ) -> "Transaction": + """ + Refund a test-mode Transaction. + """ + ... + + @overload + async def refund_async( + self, **params: Unpack["Transaction.RefundParams"] + ) -> "Transaction": + """ + Refund a test-mode Transaction. + """ + ... + + @class_method_variant("_cls_refund_async") + async def refund_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Transaction.RefundParams"] + ) -> "Transaction": + """ + Refund a test-mode Transaction. + """ + return cast( + "Transaction", + await self.resource._request_async( + "post", + "/v1/test_helpers/issuing/transactions/{transaction}/refund".format( + transaction=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/radar/_early_fraud_warning.py b/stripe/radar/_early_fraud_warning.py index 2204622c2..4b4b0d51b 100644 --- a/stripe/radar/_early_fraud_warning.py +++ b/stripe/radar/_early_fraud_warning.py @@ -138,6 +138,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["EarlyFraudWarning.ListParams"] + ) -> ListObject["EarlyFraudWarning"]: + """ + Returns a list of early fraud warnings. + """ + 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["EarlyFraudWarning.RetrieveParams"] @@ -150,3 +171,16 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["EarlyFraudWarning.RetrieveParams"] + ) -> "EarlyFraudWarning": + """ + Retrieves the details of an early fraud warning that has previously been created. + + Please refer to the [early fraud warning](https://stripe.com/docs/api#early_fraud_warning_object) object reference for more details. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/radar/_value_list.py b/stripe/radar/_value_list.py index 50191d016..75c28a60e 100644 --- a/stripe/radar/_value_list.py +++ b/stripe/radar/_value_list.py @@ -200,6 +200,22 @@ def create(cls, **params: Unpack["ValueList.CreateParams"]) -> "ValueList": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ValueList.CreateParams"] + ) -> "ValueList": + """ + Creates a new ValueList object, which can then be referenced in rules. + """ + return cast( + "ValueList", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["ValueList.DeleteParams"] @@ -249,6 +265,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["ValueList.DeleteParams"] + ) -> "ValueList": + """ + Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "ValueList", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["ValueList.DeleteParams"] + ) -> "ValueList": + """ + Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["ValueList.DeleteParams"] + ) -> "ValueList": + """ + Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["ValueList.DeleteParams"] + ) -> "ValueList": + """ + Deletes a ValueList object, also deleting any items contained within the value list. To be deleted, a value list must not be referenced in any rules. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["ValueList.ListParams"] @@ -270,6 +335,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ValueList.ListParams"] + ) -> ListObject["ValueList"]: + """ + Returns a list of ValueList objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["ValueList.ModifyParams"] @@ -287,6 +373,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["ValueList.ModifyParams"] + ) -> "ValueList": + """ + Updates a ValueList object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. Note that item_type is immutable. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "ValueList", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["ValueList.RetrieveParams"] @@ -297,3 +400,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ValueList.RetrieveParams"] + ) -> "ValueList": + """ + Retrieves a ValueList object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/radar/_value_list_item.py b/stripe/radar/_value_list_item.py index bcc0a9f15..1a3dfe781 100644 --- a/stripe/radar/_value_list_item.py +++ b/stripe/radar/_value_list_item.py @@ -142,6 +142,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ValueListItem.CreateParams"] + ) -> "ValueListItem": + """ + Creates a new ValueListItem object, which is added to the specified parent value list. + """ + return cast( + "ValueListItem", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["ValueListItem.DeleteParams"] @@ -191,6 +207,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["ValueListItem.DeleteParams"] + ) -> "ValueListItem": + """ + Deletes a ValueListItem object, removing it from its parent value list. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "ValueListItem", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["ValueListItem.DeleteParams"] + ) -> "ValueListItem": + """ + Deletes a ValueListItem object, removing it from its parent value list. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["ValueListItem.DeleteParams"] + ) -> "ValueListItem": + """ + Deletes a ValueListItem object, removing it from its parent value list. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["ValueListItem.DeleteParams"] + ) -> "ValueListItem": + """ + Deletes a ValueListItem object, removing it from its parent value list. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["ValueListItem.ListParams"] @@ -212,6 +277,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ValueListItem.ListParams"] + ) -> ListObject["ValueListItem"]: + """ + Returns a list of ValueListItem objects. The objects are sorted in descending order by creation date, with the most recently created object appearing first. + """ + 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["ValueListItem.RetrieveParams"] @@ -222,3 +308,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ValueListItem.RetrieveParams"] + ) -> "ValueListItem": + """ + Retrieves a ValueListItem object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/reporting/_report_run.py b/stripe/reporting/_report_run.py index 2dba14623..dc631a52b 100644 --- a/stripe/reporting/_report_run.py +++ b/stripe/reporting/_report_run.py @@ -223,6 +223,22 @@ def create(cls, **params: Unpack["ReportRun.CreateParams"]) -> "ReportRun": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ReportRun.CreateParams"] + ) -> "ReportRun": + """ + Creates a new object and begin running the report. (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).) + """ + return cast( + "ReportRun", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["ReportRun.ListParams"] @@ -244,6 +260,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ReportRun.ListParams"] + ) -> ListObject["ReportRun"]: + """ + Returns a list of Report Runs, with the most recent appearing first. + """ + 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["ReportRun.RetrieveParams"] @@ -255,4 +292,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ReportRun.RetrieveParams"] + ) -> "ReportRun": + """ + Retrieves the details of an existing Report Run. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"parameters": Parameters} diff --git a/stripe/reporting/_report_type.py b/stripe/reporting/_report_type.py index 3fa5375fe..72794c353 100644 --- a/stripe/reporting/_report_type.py +++ b/stripe/reporting/_report_type.py @@ -93,6 +93,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ReportType.ListParams"] + ) -> ListObject["ReportType"]: + """ + Returns a full list of Report Types. + """ + 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["ReportType.RetrieveParams"] @@ -103,3 +124,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ReportType.RetrieveParams"] + ) -> "ReportType": + """ + Retrieves the details of a Report Type. (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).) + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/sigma/_scheduled_query_run.py b/stripe/sigma/_scheduled_query_run.py index a31c701a6..1d46bfef3 100644 --- a/stripe/sigma/_scheduled_query_run.py +++ b/stripe/sigma/_scheduled_query_run.py @@ -116,6 +116,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ScheduledQueryRun.ListParams"] + ) -> ListObject["ScheduledQueryRun"]: + """ + Returns a list of scheduled query runs. + """ + 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["ScheduledQueryRun.RetrieveParams"] @@ -127,6 +148,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ScheduledQueryRun.RetrieveParams"] + ) -> "ScheduledQueryRun": + """ + Retrieves the details of an scheduled query run. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/sigma/scheduled_query_runs" diff --git a/stripe/tax/_calculation.py b/stripe/tax/_calculation.py index 6c096005e..e1edf6442 100644 --- a/stripe/tax/_calculation.py +++ b/stripe/tax/_calculation.py @@ -707,6 +707,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Calculation.CreateParams"] + ) -> "Calculation": + """ + Calculates tax based on input and returns a Tax Calculation object. + """ + return cast( + "Calculation", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_list_line_items( cls, @@ -764,6 +780,63 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, + calculation: str, + **params: Unpack["Calculation.ListLineItemsParams"] + ) -> ListObject["CalculationLineItem"]: + """ + Retrieves the line items of a persisted tax calculation as a collection. + """ + return cast( + ListObject["CalculationLineItem"], + await cls._static_request_async( + "get", + "/v1/tax/calculations/{calculation}/line_items".format( + calculation=sanitize_id(calculation) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + calculation: str, **params: Unpack["Calculation.ListLineItemsParams"] + ) -> ListObject["CalculationLineItem"]: + """ + Retrieves the line items of a persisted tax calculation as a collection. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["Calculation.ListLineItemsParams"] + ) -> ListObject["CalculationLineItem"]: + """ + Retrieves the line items of a persisted tax calculation as a collection. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Calculation.ListLineItemsParams"] + ) -> ListObject["CalculationLineItem"]: + """ + Retrieves the line items of a persisted tax calculation as a collection. + """ + return cast( + ListObject["CalculationLineItem"], + await self._request_async( + "get", + "/v1/tax/calculations/{calculation}/line_items".format( + calculation=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + _inner_class_types = { "customer_details": CustomerDetails, "ship_from_details": ShipFromDetails, diff --git a/stripe/tax/_form.py b/stripe/tax/_form.py index 8d82378f6..d110882d1 100644 --- a/stripe/tax/_form.py +++ b/stripe/tax/_form.py @@ -184,6 +184,27 @@ def list(cls, **params: Unpack["Form.ListParams"]) -> ListObject["Form"]: return result + @classmethod + async def list_async( + cls, **params: Unpack["Form.ListParams"] + ) -> ListObject["Form"]: + """ + Returns a list of tax forms which were previously created. The tax forms are returned in sorted order, with the oldest tax forms appearing first. + """ + 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 _cls_pdf(cls, id: str, **params: Unpack["Form.PdfParams"]) -> Any: """ @@ -232,6 +253,56 @@ def pdf( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_pdf_async( + cls, id: str, **params: Unpack["Form.PdfParams"] + ) -> Any: + """ + Download the PDF for a tax form. + """ + return cast( + Any, + await cls._static_request_stream_async( + "get", + "/v1/tax/forms/{id}/pdf".format(id=sanitize_id(id)), + params=params, + base_address="files", + ), + ) + + @overload + @staticmethod + async def pdf_async(id: str, **params: Unpack["Form.PdfParams"]) -> Any: + """ + Download the PDF for a tax form. + """ + ... + + @overload + async def pdf_async(self, **params: Unpack["Form.PdfParams"]) -> Any: + """ + Download the PDF for a tax form. + """ + ... + + @class_method_variant("_cls_pdf_async") + async def pdf_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Form.PdfParams"] + ) -> Any: + """ + Download the PDF for a tax form. + """ + return cast( + Any, + await self._request_stream_async( + "get", + "/v1/tax/forms/{id}/pdf".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Form.RetrieveParams"] @@ -243,6 +314,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Form.RetrieveParams"] + ) -> "Form": + """ + Retrieves the details of a tax form that has previously been created. Supply the unique tax form ID that was returned from your previous request, and Stripe will return the corresponding tax form information. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "filing_statuses": FilingStatus, "payee": Payee, diff --git a/stripe/tax/_registration.py b/stripe/tax/_registration.py index c2e29d3c5..1d8350e69 100644 --- a/stripe/tax/_registration.py +++ b/stripe/tax/_registration.py @@ -1650,6 +1650,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Registration.CreateParams"] + ) -> "Registration": + """ + Creates a new Tax Registration object. + """ + return cast( + "Registration", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["Registration.ListParams"] @@ -1671,6 +1687,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Registration.ListParams"] + ) -> ListObject["Registration"]: + """ + Returns a list of Tax Registration objects. + """ + 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["Registration.ModifyParams"] @@ -1690,6 +1727,25 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Registration.ModifyParams"] + ) -> "Registration": + """ + Updates an existing Tax Registration object. + + A registration cannot be deleted after it has been created. If you wish to end a registration you may do so by setting expires_at. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Registration", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Registration.RetrieveParams"] @@ -1701,4 +1757,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Registration.RetrieveParams"] + ) -> "Registration": + """ + Returns a Tax Registration object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"country_options": CountryOptions} diff --git a/stripe/tax/_settings.py b/stripe/tax/_settings.py index f7d7316a2..b4bd1728a 100644 --- a/stripe/tax/_settings.py +++ b/stripe/tax/_settings.py @@ -173,6 +173,22 @@ def modify(cls, **params: Unpack["Settings.ModifyParams"]) -> "Settings": ), ) + @classmethod + async def modify_async( + cls, **params: Unpack["Settings.ModifyParams"] + ) -> "Settings": + """ + Updates Tax Settings parameters used in tax calculations. All parameters are editable but none can be removed once set. + """ + return cast( + "Settings", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def retrieve( cls, **params: Unpack["Settings.RetrieveParams"] @@ -184,6 +200,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, **params: Unpack["Settings.RetrieveParams"] + ) -> "Settings": + """ + Retrieves Tax Settings for a merchant. + """ + instance = cls(None, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/tax/settings" diff --git a/stripe/tax/_transaction.py b/stripe/tax/_transaction.py index 4ec255144..45b99fd2d 100644 --- a/stripe/tax/_transaction.py +++ b/stripe/tax/_transaction.py @@ -499,6 +499,22 @@ def create_from_calculation( ), ) + @classmethod + async def create_from_calculation_async( + cls, **params: Unpack["Transaction.CreateFromCalculationParams"] + ) -> "Transaction": + """ + Creates a Tax Transaction from a calculation. + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/tax/transactions/create_from_calculation", + params=params, + ), + ) + @classmethod def create_reversal( cls, **params: Unpack["Transaction.CreateReversalParams"] @@ -515,6 +531,22 @@ def create_reversal( ), ) + @classmethod + async def create_reversal_async( + cls, **params: Unpack["Transaction.CreateReversalParams"] + ) -> "Transaction": + """ + Partially or fully reverses a previously created Transaction. + """ + return cast( + "Transaction", + await cls._static_request_async( + "post", + "/v1/tax/transactions/create_reversal", + params=params, + ), + ) + @classmethod def _cls_list_line_items( cls, @@ -572,6 +604,63 @@ def list_line_items( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_list_line_items_async( + cls, + transaction: str, + **params: Unpack["Transaction.ListLineItemsParams"] + ) -> ListObject["TransactionLineItem"]: + """ + Retrieves the line items of a committed standalone transaction as a collection. + """ + return cast( + ListObject["TransactionLineItem"], + await cls._static_request_async( + "get", + "/v1/tax/transactions/{transaction}/line_items".format( + transaction=sanitize_id(transaction) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def list_line_items_async( + transaction: str, **params: Unpack["Transaction.ListLineItemsParams"] + ) -> ListObject["TransactionLineItem"]: + """ + Retrieves the line items of a committed standalone transaction as a collection. + """ + ... + + @overload + async def list_line_items_async( + self, **params: Unpack["Transaction.ListLineItemsParams"] + ) -> ListObject["TransactionLineItem"]: + """ + Retrieves the line items of a committed standalone transaction as a collection. + """ + ... + + @class_method_variant("_cls_list_line_items_async") + async def list_line_items_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Transaction.ListLineItemsParams"] + ) -> ListObject["TransactionLineItem"]: + """ + Retrieves the line items of a committed standalone transaction as a collection. + """ + return cast( + ListObject["TransactionLineItem"], + await self._request_async( + "get", + "/v1/tax/transactions/{transaction}/line_items".format( + transaction=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Transaction.RetrieveParams"] @@ -583,6 +672,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Transaction.RetrieveParams"] + ) -> "Transaction": + """ + Retrieves a Tax Transaction object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "customer_details": CustomerDetails, "reversal": Reversal, diff --git a/stripe/terminal/_configuration.py b/stripe/terminal/_configuration.py index 8814af346..150bafdda 100644 --- a/stripe/terminal/_configuration.py +++ b/stripe/terminal/_configuration.py @@ -946,6 +946,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Configuration.CreateParams"] + ) -> "Configuration": + """ + Creates a new Configuration object. + """ + return cast( + "Configuration", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Configuration.DeleteParams"] @@ -995,6 +1011,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Configuration.DeleteParams"] + ) -> "Configuration": + """ + Deletes a Configuration object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Configuration", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Configuration.DeleteParams"] + ) -> "Configuration": + """ + Deletes a Configuration object. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Configuration.DeleteParams"] + ) -> "Configuration": + """ + Deletes a Configuration object. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Configuration.DeleteParams"] + ) -> "Configuration": + """ + Deletes a Configuration object. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["Configuration.ListParams"] @@ -1016,6 +1081,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Configuration.ListParams"] + ) -> ListObject["Configuration"]: + """ + Returns a list of Configuration objects. + """ + 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["Configuration.ModifyParams"] @@ -1033,6 +1119,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Configuration.ModifyParams"] + ) -> "Configuration": + """ + Updates a new Configuration object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Configuration", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Configuration.RetrieveParams"] @@ -1044,6 +1147,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Configuration.RetrieveParams"] + ) -> "Configuration": + """ + Retrieves a Configuration object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "bbpos_wisepos_e": BbposWiseposE, "offline": Offline, diff --git a/stripe/terminal/_connection_token.py b/stripe/terminal/_connection_token.py index d564a6088..84f1fdc79 100644 --- a/stripe/terminal/_connection_token.py +++ b/stripe/terminal/_connection_token.py @@ -55,3 +55,19 @@ def create( params=params, ), ) + + @classmethod + async def create_async( + cls, **params: Unpack["ConnectionToken.CreateParams"] + ) -> "ConnectionToken": + """ + To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived connection token from Stripe, proxied through your server. On your backend, add an endpoint that creates and returns a connection token. + """ + return cast( + "ConnectionToken", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) diff --git a/stripe/terminal/_location.py b/stripe/terminal/_location.py index bb72c5baa..e2e129486 100644 --- a/stripe/terminal/_location.py +++ b/stripe/terminal/_location.py @@ -220,6 +220,23 @@ def create(cls, **params: Unpack["Location.CreateParams"]) -> "Location": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Location.CreateParams"] + ) -> "Location": + """ + Creates a new Location object. + For further details, including which address fields are required in each country, see the [Manage locations](https://stripe.com/docs/terminal/fleet/locations) guide. + """ + return cast( + "Location", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Location.DeleteParams"] @@ -267,6 +284,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Location.DeleteParams"] + ) -> "Location": + """ + Deletes a Location object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Location", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Location.DeleteParams"] + ) -> "Location": + """ + Deletes a Location object. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Location.DeleteParams"] + ) -> "Location": + """ + Deletes a Location object. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Location.DeleteParams"] + ) -> "Location": + """ + Deletes a Location object. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["Location.ListParams"] @@ -288,6 +354,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Location.ListParams"] + ) -> ListObject["Location"]: + """ + Returns a list of Location objects. + """ + 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["Location.ModifyParams"] @@ -305,6 +392,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["Location.ModifyParams"] + ) -> "Location": + """ + Updates a Location object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Location", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Location.RetrieveParams"] @@ -316,4 +420,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Location.RetrieveParams"] + ) -> "Location": + """ + Retrieves a Location object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"address": Address} diff --git a/stripe/terminal/_reader.py b/stripe/terminal/_reader.py index d145a9450..02b12593a 100644 --- a/stripe/terminal/_reader.py +++ b/stripe/terminal/_reader.py @@ -846,6 +846,61 @@ def cancel_action( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_action_async( + cls, reader: str, **params: Unpack["Reader.CancelActionParams"] + ) -> "Reader": + """ + Cancels the current reader action. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/cancel_action".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_action_async( + reader: str, **params: Unpack["Reader.CancelActionParams"] + ) -> "Reader": + """ + Cancels the current reader action. + """ + ... + + @overload + async def cancel_action_async( + self, **params: Unpack["Reader.CancelActionParams"] + ) -> "Reader": + """ + Cancels the current reader action. + """ + ... + + @class_method_variant("_cls_cancel_action_async") + async def cancel_action_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.CancelActionParams"] + ) -> "Reader": + """ + Cancels the current reader action. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/cancel_action".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_collect_inputs( cls, reader: str, **params: Unpack["Reader.CollectInputsParams"] @@ -901,6 +956,61 @@ def collect_inputs( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_collect_inputs_async( + cls, reader: str, **params: Unpack["Reader.CollectInputsParams"] + ) -> "Reader": + """ + Initiates an input collection flow on a Reader. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/collect_inputs".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def collect_inputs_async( + reader: str, **params: Unpack["Reader.CollectInputsParams"] + ) -> "Reader": + """ + Initiates an input collection flow on a Reader. + """ + ... + + @overload + async def collect_inputs_async( + self, **params: Unpack["Reader.CollectInputsParams"] + ) -> "Reader": + """ + Initiates an input collection flow on a Reader. + """ + ... + + @class_method_variant("_cls_collect_inputs_async") + async def collect_inputs_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.CollectInputsParams"] + ) -> "Reader": + """ + Initiates an input collection flow on a Reader. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/collect_inputs".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_collect_payment_method( cls, reader: str, **params: Unpack["Reader.CollectPaymentMethodParams"] @@ -956,6 +1066,61 @@ def collect_payment_method( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_collect_payment_method_async( + cls, reader: str, **params: Unpack["Reader.CollectPaymentMethodParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/collect_payment_method".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def collect_payment_method_async( + reader: str, **params: Unpack["Reader.CollectPaymentMethodParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation. + """ + ... + + @overload + async def collect_payment_method_async( + self, **params: Unpack["Reader.CollectPaymentMethodParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation. + """ + ... + + @class_method_variant("_cls_collect_payment_method_async") + async def collect_payment_method_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.CollectPaymentMethodParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader and updates the PaymentIntent with card details before manual confirmation. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/collect_payment_method".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_confirm_payment_intent( cls, reader: str, **params: Unpack["Reader.ConfirmPaymentIntentParams"] @@ -1011,6 +1176,61 @@ def confirm_payment_intent( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_confirm_payment_intent_async( + cls, reader: str, **params: Unpack["Reader.ConfirmPaymentIntentParams"] + ) -> "Reader": + """ + Finalizes a payment on a Reader. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/confirm_payment_intent".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def confirm_payment_intent_async( + reader: str, **params: Unpack["Reader.ConfirmPaymentIntentParams"] + ) -> "Reader": + """ + Finalizes a payment on a Reader. + """ + ... + + @overload + async def confirm_payment_intent_async( + self, **params: Unpack["Reader.ConfirmPaymentIntentParams"] + ) -> "Reader": + """ + Finalizes a payment on a Reader. + """ + ... + + @class_method_variant("_cls_confirm_payment_intent_async") + async def confirm_payment_intent_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.ConfirmPaymentIntentParams"] + ) -> "Reader": + """ + Finalizes a payment on a Reader. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/confirm_payment_intent".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["Reader.CreateParams"]) -> "Reader": """ @@ -1025,6 +1245,22 @@ def create(cls, **params: Unpack["Reader.CreateParams"]) -> "Reader": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["Reader.CreateParams"] + ) -> "Reader": + """ + Creates a new Reader object. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["Reader.DeleteParams"] @@ -1070,6 +1306,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["Reader.DeleteParams"] + ) -> "Reader": + """ + Deletes a Reader object. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "Reader", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["Reader.DeleteParams"] + ) -> "Reader": + """ + Deletes a Reader object. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["Reader.DeleteParams"] + ) -> "Reader": + """ + Deletes a Reader object. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.DeleteParams"] + ) -> "Reader": + """ + Deletes a Reader object. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["Reader.ListParams"] @@ -1092,7 +1377,45 @@ def list( return result @classmethod - def modify( + async def list_async( + cls, **params: Unpack["Reader.ListParams"] + ) -> ListObject["Reader"]: + """ + Returns a list of Reader objects. + """ + 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["Reader.ModifyParams"] + ) -> "Reader": + """ + Updates a Reader object by setting the values of the parameters passed. Any parameters not provided will be left unchanged. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "Reader", + cls._static_request( + "post", + url, + params=params, + ), + ) + + @classmethod + async def modify_async( cls, id: str, **params: Unpack["Reader.ModifyParams"] ) -> "Reader": """ @@ -1101,7 +1424,7 @@ def modify( url = "%s/%s" % (cls.class_url(), sanitize_id(id)) return cast( "Reader", - cls._static_request( + await cls._static_request_async( "post", url, params=params, @@ -1163,6 +1486,61 @@ def process_payment_intent( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_process_payment_intent_async( + cls, reader: str, **params: Unpack["Reader.ProcessPaymentIntentParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/process_payment_intent".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def process_payment_intent_async( + reader: str, **params: Unpack["Reader.ProcessPaymentIntentParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader. + """ + ... + + @overload + async def process_payment_intent_async( + self, **params: Unpack["Reader.ProcessPaymentIntentParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader. + """ + ... + + @class_method_variant("_cls_process_payment_intent_async") + async def process_payment_intent_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.ProcessPaymentIntentParams"] + ) -> "Reader": + """ + Initiates a payment flow on a Reader. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/process_payment_intent".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_process_setup_intent( cls, reader: str, **params: Unpack["Reader.ProcessSetupIntentParams"] @@ -1218,6 +1596,61 @@ def process_setup_intent( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_process_setup_intent_async( + cls, reader: str, **params: Unpack["Reader.ProcessSetupIntentParams"] + ) -> "Reader": + """ + Initiates a setup intent flow on a Reader. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/process_setup_intent".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def process_setup_intent_async( + reader: str, **params: Unpack["Reader.ProcessSetupIntentParams"] + ) -> "Reader": + """ + Initiates a setup intent flow on a Reader. + """ + ... + + @overload + async def process_setup_intent_async( + self, **params: Unpack["Reader.ProcessSetupIntentParams"] + ) -> "Reader": + """ + Initiates a setup intent flow on a Reader. + """ + ... + + @class_method_variant("_cls_process_setup_intent_async") + async def process_setup_intent_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.ProcessSetupIntentParams"] + ) -> "Reader": + """ + Initiates a setup intent flow on a Reader. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/process_setup_intent".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_refund_payment( cls, reader: str, **params: Unpack["Reader.RefundPaymentParams"] @@ -1273,6 +1706,61 @@ def refund_payment( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_refund_payment_async( + cls, reader: str, **params: Unpack["Reader.RefundPaymentParams"] + ) -> "Reader": + """ + Initiates a refund on a Reader + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/refund_payment".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def refund_payment_async( + reader: str, **params: Unpack["Reader.RefundPaymentParams"] + ) -> "Reader": + """ + Initiates a refund on a Reader + """ + ... + + @overload + async def refund_payment_async( + self, **params: Unpack["Reader.RefundPaymentParams"] + ) -> "Reader": + """ + Initiates a refund on a Reader + """ + ... + + @class_method_variant("_cls_refund_payment_async") + async def refund_payment_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.RefundPaymentParams"] + ) -> "Reader": + """ + Initiates a refund on a Reader + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/refund_payment".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["Reader.RetrieveParams"] @@ -1284,6 +1772,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Reader.RetrieveParams"] + ) -> "Reader": + """ + Retrieves a Reader object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_set_reader_display( cls, reader: str, **params: Unpack["Reader.SetReaderDisplayParams"] @@ -1339,6 +1838,61 @@ def set_reader_display( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_set_reader_display_async( + cls, reader: str, **params: Unpack["Reader.SetReaderDisplayParams"] + ) -> "Reader": + """ + Sets reader display to show cart details. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/terminal/readers/{reader}/set_reader_display".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def set_reader_display_async( + reader: str, **params: Unpack["Reader.SetReaderDisplayParams"] + ) -> "Reader": + """ + Sets reader display to show cart details. + """ + ... + + @overload + async def set_reader_display_async( + self, **params: Unpack["Reader.SetReaderDisplayParams"] + ) -> "Reader": + """ + Sets reader display to show cart details. + """ + ... + + @class_method_variant("_cls_set_reader_display_async") + async def set_reader_display_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.SetReaderDisplayParams"] + ) -> "Reader": + """ + Sets reader display to show cart details. + """ + return cast( + "Reader", + await self._request_async( + "post", + "/v1/terminal/readers/{reader}/set_reader_display".format( + reader=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + class TestHelpers(APIResourceTestHelpers["Reader"]): _resource_cls: Type["Reader"] @@ -1399,6 +1953,63 @@ def present_payment_method( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_present_payment_method_async( + cls, + reader: str, + **params: Unpack["Reader.PresentPaymentMethodParams"] + ) -> "Reader": + """ + Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction. + """ + return cast( + "Reader", + await cls._static_request_async( + "post", + "/v1/test_helpers/terminal/readers/{reader}/present_payment_method".format( + reader=sanitize_id(reader) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def present_payment_method_async( + reader: str, **params: Unpack["Reader.PresentPaymentMethodParams"] + ) -> "Reader": + """ + Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction. + """ + ... + + @overload + async def present_payment_method_async( + self, **params: Unpack["Reader.PresentPaymentMethodParams"] + ) -> "Reader": + """ + Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction. + """ + ... + + @class_method_variant("_cls_present_payment_method_async") + async def present_payment_method_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["Reader.PresentPaymentMethodParams"] + ) -> "Reader": + """ + Presents a payment method on a simulated reader. Can be used to simulate accepting a payment, saving a card or refunding a transaction. + """ + return cast( + "Reader", + await self.resource._request_async( + "post", + "/v1/test_helpers/terminal/readers/{reader}/present_payment_method".format( + reader=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/test_helpers/_test_clock.py b/stripe/test_helpers/_test_clock.py index d1dc4e9ce..79cdd52c0 100644 --- a/stripe/test_helpers/_test_clock.py +++ b/stripe/test_helpers/_test_clock.py @@ -168,6 +168,61 @@ def advance( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_advance_async( + cls, test_clock: str, **params: Unpack["TestClock.AdvanceParams"] + ) -> "TestClock": + """ + Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready. + """ + return cast( + "TestClock", + await cls._static_request_async( + "post", + "/v1/test_helpers/test_clocks/{test_clock}/advance".format( + test_clock=sanitize_id(test_clock) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def advance_async( + test_clock: str, **params: Unpack["TestClock.AdvanceParams"] + ) -> "TestClock": + """ + Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready. + """ + ... + + @overload + async def advance_async( + self, **params: Unpack["TestClock.AdvanceParams"] + ) -> "TestClock": + """ + Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready. + """ + ... + + @class_method_variant("_cls_advance_async") + async def advance_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["TestClock.AdvanceParams"] + ) -> "TestClock": + """ + Starts advancing a test clock to a specified time in the future. Advancement is done when status changes to Ready. + """ + return cast( + "TestClock", + await self._request_async( + "post", + "/v1/test_helpers/test_clocks/{test_clock}/advance".format( + test_clock=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create(cls, **params: Unpack["TestClock.CreateParams"]) -> "TestClock": """ @@ -182,6 +237,22 @@ def create(cls, **params: Unpack["TestClock.CreateParams"]) -> "TestClock": ), ) + @classmethod + async def create_async( + cls, **params: Unpack["TestClock.CreateParams"] + ) -> "TestClock": + """ + Creates a new test clock that can be attached to new customers and quotes. + """ + return cast( + "TestClock", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def _cls_delete( cls, sid: str, **params: Unpack["TestClock.DeleteParams"] @@ -231,6 +302,55 @@ def delete( # pyright: ignore[reportGeneralTypeIssues] params=params, ) + @classmethod + async def _cls_delete_async( + cls, sid: str, **params: Unpack["TestClock.DeleteParams"] + ) -> "TestClock": + """ + Deletes a test clock. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(sid)) + return cast( + "TestClock", + await cls._static_request_async( + "delete", + url, + params=params, + ), + ) + + @overload + @staticmethod + async def delete_async( + sid: str, **params: Unpack["TestClock.DeleteParams"] + ) -> "TestClock": + """ + Deletes a test clock. + """ + ... + + @overload + async def delete_async( + self, **params: Unpack["TestClock.DeleteParams"] + ) -> "TestClock": + """ + Deletes a test clock. + """ + ... + + @class_method_variant("_cls_delete_async") + async def delete_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["TestClock.DeleteParams"] + ) -> "TestClock": + """ + Deletes a test clock. + """ + return await self._request_and_refresh_async( + "delete", + self.instance_url(), + params=params, + ) + @classmethod def list( cls, **params: Unpack["TestClock.ListParams"] @@ -252,6 +372,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["TestClock.ListParams"] + ) -> ListObject["TestClock"]: + """ + Returns a list of your test clocks. + """ + 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["TestClock.RetrieveParams"] @@ -262,3 +403,14 @@ def retrieve( instance = cls(id, **params) instance.refresh() return instance + + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["TestClock.RetrieveParams"] + ) -> "TestClock": + """ + Retrieves a test clock. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance diff --git a/stripe/treasury/_credit_reversal.py b/stripe/treasury/_credit_reversal.py index 819b6ed02..025ff7948 100644 --- a/stripe/treasury/_credit_reversal.py +++ b/stripe/treasury/_credit_reversal.py @@ -151,6 +151,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["CreditReversal.CreateParams"] + ) -> "CreditReversal": + """ + Reverses a ReceivedCredit and creates a CreditReversal object. + """ + return cast( + "CreditReversal", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["CreditReversal.ListParams"] @@ -172,6 +188,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["CreditReversal.ListParams"] + ) -> ListObject["CreditReversal"]: + """ + Returns a list of CreditReversals. + """ + 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["CreditReversal.RetrieveParams"] @@ -183,4 +220,15 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["CreditReversal.RetrieveParams"] + ) -> "CreditReversal": + """ + Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID from either the CreditReversal creation request or CreditReversal list + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = {"status_transitions": StatusTransitions} diff --git a/stripe/treasury/_debit_reversal.py b/stripe/treasury/_debit_reversal.py index 6205ed1df..627c7eec9 100644 --- a/stripe/treasury/_debit_reversal.py +++ b/stripe/treasury/_debit_reversal.py @@ -165,6 +165,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["DebitReversal.CreateParams"] + ) -> "DebitReversal": + """ + Reverses a ReceivedDebit and creates a DebitReversal object. + """ + return cast( + "DebitReversal", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["DebitReversal.ListParams"] @@ -186,6 +202,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["DebitReversal.ListParams"] + ) -> ListObject["DebitReversal"]: + """ + Returns a list of DebitReversals. + """ + 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["DebitReversal.RetrieveParams"] @@ -197,6 +234,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["DebitReversal.RetrieveParams"] + ) -> "DebitReversal": + """ + Retrieves a DebitReversal object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "linked_flows": LinkedFlows, "status_transitions": StatusTransitions, diff --git a/stripe/treasury/_financial_account.py b/stripe/treasury/_financial_account.py index 98a44f87d..99af084d3 100644 --- a/stripe/treasury/_financial_account.py +++ b/stripe/treasury/_financial_account.py @@ -779,6 +779,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["FinancialAccount.CreateParams"] + ) -> "FinancialAccount": + """ + Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. + """ + return cast( + "FinancialAccount", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["FinancialAccount.ListParams"] @@ -800,6 +816,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["FinancialAccount.ListParams"] + ) -> ListObject["FinancialAccount"]: + """ + Returns a list of FinancialAccounts. + """ + 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["FinancialAccount.ModifyParams"] @@ -817,6 +854,23 @@ def modify( ), ) + @classmethod + async def modify_async( + cls, id: str, **params: Unpack["FinancialAccount.ModifyParams"] + ) -> "FinancialAccount": + """ + Updates the details of a FinancialAccount. + """ + url = "%s/%s" % (cls.class_url(), sanitize_id(id)) + return cast( + "FinancialAccount", + await cls._static_request_async( + "post", + url, + params=params, + ), + ) + @classmethod def retrieve( cls, id: str, **params: Unpack["FinancialAccount.RetrieveParams"] @@ -828,6 +882,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["FinancialAccount.RetrieveParams"] + ) -> "FinancialAccount": + """ + Retrieves the details of a FinancialAccount. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def _cls_retrieve_features( cls, @@ -886,6 +951,64 @@ def retrieve_features( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_retrieve_features_async( + cls, + financial_account: str, + **params: Unpack["FinancialAccount.RetrieveFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Retrieves Features information associated with the FinancialAccount. + """ + return cast( + "FinancialAccountFeatures", + await cls._static_request_async( + "get", + "/v1/treasury/financial_accounts/{financial_account}/features".format( + financial_account=sanitize_id(financial_account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def retrieve_features_async( + financial_account: str, + **params: Unpack["FinancialAccount.RetrieveFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Retrieves Features information associated with the FinancialAccount. + """ + ... + + @overload + async def retrieve_features_async( + self, **params: Unpack["FinancialAccount.RetrieveFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Retrieves Features information associated with the FinancialAccount. + """ + ... + + @class_method_variant("_cls_retrieve_features_async") + async def retrieve_features_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["FinancialAccount.RetrieveFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Retrieves Features information associated with the FinancialAccount. + """ + return cast( + "FinancialAccountFeatures", + await self._request_async( + "get", + "/v1/treasury/financial_accounts/{financial_account}/features".format( + financial_account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_update_features( cls, @@ -944,6 +1067,64 @@ def update_features( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_update_features_async( + cls, + financial_account: str, + **params: Unpack["FinancialAccount.UpdateFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Updates the Features associated with a FinancialAccount. + """ + return cast( + "FinancialAccountFeatures", + await cls._static_request_async( + "post", + "/v1/treasury/financial_accounts/{financial_account}/features".format( + financial_account=sanitize_id(financial_account) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def update_features_async( + financial_account: str, + **params: Unpack["FinancialAccount.UpdateFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Updates the Features associated with a FinancialAccount. + """ + ... + + @overload + async def update_features_async( + self, **params: Unpack["FinancialAccount.UpdateFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Updates the Features associated with a FinancialAccount. + """ + ... + + @class_method_variant("_cls_update_features_async") + async def update_features_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["FinancialAccount.UpdateFeaturesParams"] + ) -> "FinancialAccountFeatures": + """ + Updates the Features associated with a FinancialAccount. + """ + return cast( + "FinancialAccountFeatures", + await self._request_async( + "post", + "/v1/treasury/financial_accounts/{financial_account}/features".format( + financial_account=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + _inner_class_types = { "balance": Balance, "financial_addresses": FinancialAddress, diff --git a/stripe/treasury/_inbound_transfer.py b/stripe/treasury/_inbound_transfer.py index 86aa6d66d..81d5b1538 100644 --- a/stripe/treasury/_inbound_transfer.py +++ b/stripe/treasury/_inbound_transfer.py @@ -392,6 +392,63 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, + inbound_transfer: str, + **params: Unpack["InboundTransfer.CancelParams"] + ) -> "InboundTransfer": + """ + Cancels an InboundTransfer. + """ + return cast( + "InboundTransfer", + await cls._static_request_async( + "post", + "/v1/treasury/inbound_transfers/{inbound_transfer}/cancel".format( + inbound_transfer=sanitize_id(inbound_transfer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + inbound_transfer: str, **params: Unpack["InboundTransfer.CancelParams"] + ) -> "InboundTransfer": + """ + Cancels an InboundTransfer. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["InboundTransfer.CancelParams"] + ) -> "InboundTransfer": + """ + Cancels an InboundTransfer. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["InboundTransfer.CancelParams"] + ) -> "InboundTransfer": + """ + Cancels an InboundTransfer. + """ + return cast( + "InboundTransfer", + await self._request_async( + "post", + "/v1/treasury/inbound_transfers/{inbound_transfer}/cancel".format( + inbound_transfer=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["InboundTransfer.CreateParams"] @@ -408,6 +465,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["InboundTransfer.CreateParams"] + ) -> "InboundTransfer": + """ + Creates an InboundTransfer. + """ + return cast( + "InboundTransfer", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["InboundTransfer.ListParams"] @@ -429,6 +502,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["InboundTransfer.ListParams"] + ) -> ListObject["InboundTransfer"]: + """ + Returns a list of InboundTransfers sent from the specified FinancialAccount. + """ + 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["InboundTransfer.RetrieveParams"] @@ -440,6 +534,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["InboundTransfer.RetrieveParams"] + ) -> "InboundTransfer": + """ + Retrieves the details of an existing InboundTransfer. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["InboundTransfer"]): _resource_cls: Type["InboundTransfer"] @@ -498,6 +603,61 @@ def fail( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_fail_async( + cls, id: str, **params: Unpack["InboundTransfer.FailParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. + """ + return cast( + "InboundTransfer", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/inbound_transfers/{id}/fail".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def fail_async( + id: str, **params: Unpack["InboundTransfer.FailParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. + """ + ... + + @overload + async def fail_async( + self, **params: Unpack["InboundTransfer.FailParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. + """ + ... + + @class_method_variant("_cls_fail_async") + async def fail_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["InboundTransfer.FailParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the failed status. The InboundTransfer must already be in the processing state. + """ + return cast( + "InboundTransfer", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/inbound_transfers/{id}/fail".format( + id=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_return_inbound_transfer( cls, @@ -558,6 +718,66 @@ def return_inbound_transfer( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_return_inbound_transfer_async( + cls, + id: str, + **params: Unpack["InboundTransfer.ReturnInboundTransferParams"] + ) -> "InboundTransfer": + """ + Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + """ + return cast( + "InboundTransfer", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/inbound_transfers/{id}/return".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def return_inbound_transfer_async( + id: str, + **params: Unpack["InboundTransfer.ReturnInboundTransferParams"] + ) -> "InboundTransfer": + """ + Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + """ + ... + + @overload + async def return_inbound_transfer_async( + self, + **params: Unpack["InboundTransfer.ReturnInboundTransferParams"] + ) -> "InboundTransfer": + """ + Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + """ + ... + + @class_method_variant("_cls_return_inbound_transfer_async") + async def return_inbound_transfer_async( # pyright: ignore[reportGeneralTypeIssues] + self, + **params: Unpack["InboundTransfer.ReturnInboundTransferParams"] + ) -> "InboundTransfer": + """ + Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the succeeded state. + """ + return cast( + "InboundTransfer", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/inbound_transfers/{id}/return".format( + id=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_succeed( cls, id: str, **params: Unpack["InboundTransfer.SucceedParams"] @@ -613,6 +833,61 @@ def succeed( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_succeed_async( + cls, id: str, **params: Unpack["InboundTransfer.SucceedParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. + """ + return cast( + "InboundTransfer", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/inbound_transfers/{id}/succeed".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def succeed_async( + id: str, **params: Unpack["InboundTransfer.SucceedParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. + """ + ... + + @overload + async def succeed_async( + self, **params: Unpack["InboundTransfer.SucceedParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. + """ + ... + + @class_method_variant("_cls_succeed_async") + async def succeed_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["InboundTransfer.SucceedParams"] + ) -> "InboundTransfer": + """ + Transitions a test mode created InboundTransfer to the succeeded status. The InboundTransfer must already be in the processing state. + """ + return cast( + "InboundTransfer", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/inbound_transfers/{id}/succeed".format( + id=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/treasury/_outbound_payment.py b/stripe/treasury/_outbound_payment.py index 0b0d60145..c73f2998d 100644 --- a/stripe/treasury/_outbound_payment.py +++ b/stripe/treasury/_outbound_payment.py @@ -568,6 +568,61 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, id: str, **params: Unpack["OutboundPayment.CancelParams"] + ) -> "OutboundPayment": + """ + Cancel an OutboundPayment. + """ + return cast( + "OutboundPayment", + await cls._static_request_async( + "post", + "/v1/treasury/outbound_payments/{id}/cancel".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + id: str, **params: Unpack["OutboundPayment.CancelParams"] + ) -> "OutboundPayment": + """ + Cancel an OutboundPayment. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["OutboundPayment.CancelParams"] + ) -> "OutboundPayment": + """ + Cancel an OutboundPayment. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["OutboundPayment.CancelParams"] + ) -> "OutboundPayment": + """ + Cancel an OutboundPayment. + """ + return cast( + "OutboundPayment", + await self._request_async( + "post", + "/v1/treasury/outbound_payments/{id}/cancel".format( + id=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["OutboundPayment.CreateParams"] @@ -584,6 +639,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["OutboundPayment.CreateParams"] + ) -> "OutboundPayment": + """ + Creates an OutboundPayment. + """ + return cast( + "OutboundPayment", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["OutboundPayment.ListParams"] @@ -605,6 +676,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["OutboundPayment.ListParams"] + ) -> ListObject["OutboundPayment"]: + """ + Returns a list of OutboundPayments sent from the specified FinancialAccount. + """ + 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["OutboundPayment.RetrieveParams"] @@ -616,6 +708,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["OutboundPayment.RetrieveParams"] + ) -> "OutboundPayment": + """ + Retrieves the details of an existing OutboundPayment by passing the unique OutboundPayment ID from either the OutboundPayment creation request or OutboundPayment list. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["OutboundPayment"]): _resource_cls: Type["OutboundPayment"] @@ -674,6 +777,61 @@ def fail( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_fail_async( + cls, id: str, **params: Unpack["OutboundPayment.FailParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. + """ + return cast( + "OutboundPayment", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/outbound_payments/{id}/fail".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def fail_async( + id: str, **params: Unpack["OutboundPayment.FailParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. + """ + ... + + @overload + async def fail_async( + self, **params: Unpack["OutboundPayment.FailParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. + """ + ... + + @class_method_variant("_cls_fail_async") + async def fail_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["OutboundPayment.FailParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the failed status. The OutboundPayment must already be in the processing state. + """ + return cast( + "OutboundPayment", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/outbound_payments/{id}/fail".format( + id=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_post( cls, id: str, **params: Unpack["OutboundPayment.PostParams"] @@ -729,6 +887,61 @@ def post( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_post_async( + cls, id: str, **params: Unpack["OutboundPayment.PostParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + """ + return cast( + "OutboundPayment", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/outbound_payments/{id}/post".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def post_async( + id: str, **params: Unpack["OutboundPayment.PostParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + """ + ... + + @overload + async def post_async( + self, **params: Unpack["OutboundPayment.PostParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + """ + ... + + @class_method_variant("_cls_post_async") + async def post_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["OutboundPayment.PostParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the posted status. The OutboundPayment must already be in the processing state. + """ + return cast( + "OutboundPayment", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/outbound_payments/{id}/post".format( + id=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_return_outbound_payment( cls, @@ -789,6 +1002,66 @@ def return_outbound_payment( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_return_outbound_payment_async( + cls, + id: str, + **params: Unpack["OutboundPayment.ReturnOutboundPaymentParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. + """ + return cast( + "OutboundPayment", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/outbound_payments/{id}/return".format( + id=sanitize_id(id) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def return_outbound_payment_async( + id: str, + **params: Unpack["OutboundPayment.ReturnOutboundPaymentParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. + """ + ... + + @overload + async def return_outbound_payment_async( + self, + **params: Unpack["OutboundPayment.ReturnOutboundPaymentParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. + """ + ... + + @class_method_variant("_cls_return_outbound_payment_async") + async def return_outbound_payment_async( # pyright: ignore[reportGeneralTypeIssues] + self, + **params: Unpack["OutboundPayment.ReturnOutboundPaymentParams"] + ) -> "OutboundPayment": + """ + Transitions a test mode created OutboundPayment to the returned status. The OutboundPayment must already be in the processing state. + """ + return cast( + "OutboundPayment", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/outbound_payments/{id}/return".format( + id=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/treasury/_outbound_transfer.py b/stripe/treasury/_outbound_transfer.py index e38393ed9..9c69e74bc 100644 --- a/stripe/treasury/_outbound_transfer.py +++ b/stripe/treasury/_outbound_transfer.py @@ -453,6 +453,64 @@ def cancel( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_cancel_async( + cls, + outbound_transfer: str, + **params: Unpack["OutboundTransfer.CancelParams"] + ) -> "OutboundTransfer": + """ + An OutboundTransfer can be canceled if the funds have not yet been paid out. + """ + return cast( + "OutboundTransfer", + await cls._static_request_async( + "post", + "/v1/treasury/outbound_transfers/{outbound_transfer}/cancel".format( + outbound_transfer=sanitize_id(outbound_transfer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def cancel_async( + outbound_transfer: str, + **params: Unpack["OutboundTransfer.CancelParams"] + ) -> "OutboundTransfer": + """ + An OutboundTransfer can be canceled if the funds have not yet been paid out. + """ + ... + + @overload + async def cancel_async( + self, **params: Unpack["OutboundTransfer.CancelParams"] + ) -> "OutboundTransfer": + """ + An OutboundTransfer can be canceled if the funds have not yet been paid out. + """ + ... + + @class_method_variant("_cls_cancel_async") + async def cancel_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["OutboundTransfer.CancelParams"] + ) -> "OutboundTransfer": + """ + An OutboundTransfer can be canceled if the funds have not yet been paid out. + """ + return cast( + "OutboundTransfer", + await self._request_async( + "post", + "/v1/treasury/outbound_transfers/{outbound_transfer}/cancel".format( + outbound_transfer=sanitize_id(self.get("id")) + ), + params=params, + ), + ) + @classmethod def create( cls, **params: Unpack["OutboundTransfer.CreateParams"] @@ -469,6 +527,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["OutboundTransfer.CreateParams"] + ) -> "OutboundTransfer": + """ + Creates an OutboundTransfer. + """ + return cast( + "OutboundTransfer", + await cls._static_request_async( + "post", + cls.class_url(), + params=params, + ), + ) + @classmethod def list( cls, **params: Unpack["OutboundTransfer.ListParams"] @@ -490,6 +564,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["OutboundTransfer.ListParams"] + ) -> ListObject["OutboundTransfer"]: + """ + Returns a list of OutboundTransfers sent from the specified FinancialAccount. + """ + 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["OutboundTransfer.RetrieveParams"] @@ -501,6 +596,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["OutboundTransfer.RetrieveParams"] + ) -> "OutboundTransfer": + """ + Retrieves the details of an existing OutboundTransfer by passing the unique OutboundTransfer ID from either the OutboundTransfer creation request or OutboundTransfer list. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["OutboundTransfer"]): _resource_cls: Type["OutboundTransfer"] @@ -562,6 +668,64 @@ def fail( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_fail_async( + cls, + outbound_transfer: str, + **params: Unpack["OutboundTransfer.FailParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. + """ + return cast( + "OutboundTransfer", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail".format( + outbound_transfer=sanitize_id(outbound_transfer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def fail_async( + outbound_transfer: str, + **params: Unpack["OutboundTransfer.FailParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. + """ + ... + + @overload + async def fail_async( + self, **params: Unpack["OutboundTransfer.FailParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. + """ + ... + + @class_method_variant("_cls_fail_async") + async def fail_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["OutboundTransfer.FailParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the failed status. The OutboundTransfer must already be in the processing state. + """ + return cast( + "OutboundTransfer", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail".format( + outbound_transfer=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_post( cls, @@ -620,6 +784,64 @@ def post( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_post_async( + cls, + outbound_transfer: str, + **params: Unpack["OutboundTransfer.PostParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + """ + return cast( + "OutboundTransfer", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post".format( + outbound_transfer=sanitize_id(outbound_transfer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def post_async( + outbound_transfer: str, + **params: Unpack["OutboundTransfer.PostParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + """ + ... + + @overload + async def post_async( + self, **params: Unpack["OutboundTransfer.PostParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + """ + ... + + @class_method_variant("_cls_post_async") + async def post_async( # pyright: ignore[reportGeneralTypeIssues] + self, **params: Unpack["OutboundTransfer.PostParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the posted status. The OutboundTransfer must already be in the processing state. + """ + return cast( + "OutboundTransfer", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post".format( + outbound_transfer=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @classmethod def _cls_return_outbound_transfer( cls, @@ -680,6 +902,66 @@ def return_outbound_transfer( # pyright: ignore[reportGeneralTypeIssues] ), ) + @classmethod + async def _cls_return_outbound_transfer_async( + cls, + outbound_transfer: str, + **params: Unpack["OutboundTransfer.ReturnOutboundTransferParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. + """ + return cast( + "OutboundTransfer", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return".format( + outbound_transfer=sanitize_id(outbound_transfer) + ), + params=params, + ), + ) + + @overload + @staticmethod + async def return_outbound_transfer_async( + outbound_transfer: str, + **params: Unpack["OutboundTransfer.ReturnOutboundTransferParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. + """ + ... + + @overload + async def return_outbound_transfer_async( + self, + **params: Unpack["OutboundTransfer.ReturnOutboundTransferParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. + """ + ... + + @class_method_variant("_cls_return_outbound_transfer_async") + async def return_outbound_transfer_async( # pyright: ignore[reportGeneralTypeIssues] + self, + **params: Unpack["OutboundTransfer.ReturnOutboundTransferParams"] + ) -> "OutboundTransfer": + """ + Transitions a test mode created OutboundTransfer to the returned status. The OutboundTransfer must already be in the processing state. + """ + return cast( + "OutboundTransfer", + await self.resource._request_async( + "post", + "/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return".format( + outbound_transfer=sanitize_id(self.resource.get("id")) + ), + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/treasury/_received_credit.py b/stripe/treasury/_received_credit.py index 77bc1b5cf..2f64dcdd9 100644 --- a/stripe/treasury/_received_credit.py +++ b/stripe/treasury/_received_credit.py @@ -423,6 +423,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ReceivedCredit.ListParams"] + ) -> ListObject["ReceivedCredit"]: + """ + Returns a list of ReceivedCredits. + """ + 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["ReceivedCredit.RetrieveParams"] @@ -434,6 +455,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ReceivedCredit.RetrieveParams"] + ) -> "ReceivedCredit": + """ + Retrieves the details of an existing ReceivedCredit by passing the unique ReceivedCredit ID from the ReceivedCredit list. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["ReceivedCredit"]): _resource_cls: Type["ReceivedCredit"] @@ -453,6 +485,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ReceivedCredit.CreateParams"] + ) -> "ReceivedCredit": + """ + Use this endpoint to simulate a test mode ReceivedCredit initiated by a third party. In live mode, you can't directly create ReceivedCredits initiated by third parties. + """ + return cast( + "ReceivedCredit", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/received_credits", + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/treasury/_received_debit.py b/stripe/treasury/_received_debit.py index 6518024ec..1673885f8 100644 --- a/stripe/treasury/_received_debit.py +++ b/stripe/treasury/_received_debit.py @@ -376,6 +376,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["ReceivedDebit.ListParams"] + ) -> ListObject["ReceivedDebit"]: + """ + Returns a list of ReceivedDebits. + """ + 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["ReceivedDebit.RetrieveParams"] @@ -387,6 +408,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["ReceivedDebit.RetrieveParams"] + ) -> "ReceivedDebit": + """ + Retrieves the details of an existing ReceivedDebit by passing the unique ReceivedDebit ID from the ReceivedDebit list + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + class TestHelpers(APIResourceTestHelpers["ReceivedDebit"]): _resource_cls: Type["ReceivedDebit"] @@ -406,6 +438,22 @@ def create( ), ) + @classmethod + async def create_async( + cls, **params: Unpack["ReceivedDebit.CreateParams"] + ) -> "ReceivedDebit": + """ + Use this endpoint to simulate a test mode ReceivedDebit initiated by a third party. In live mode, you can't directly create ReceivedDebits initiated by third parties. + """ + return cast( + "ReceivedDebit", + await cls._static_request_async( + "post", + "/v1/test_helpers/treasury/received_debits", + params=params, + ), + ) + @property def test_helpers(self): return self.TestHelpers(self) diff --git a/stripe/treasury/_transaction.py b/stripe/treasury/_transaction.py index f98ab5c36..7fa806b93 100644 --- a/stripe/treasury/_transaction.py +++ b/stripe/treasury/_transaction.py @@ -290,6 +290,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["Transaction.ListParams"] + ) -> ListObject["Transaction"]: + """ + Retrieves a list of Transaction objects. + """ + 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["Transaction.RetrieveParams"] @@ -301,6 +322,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["Transaction.RetrieveParams"] + ) -> "Transaction": + """ + Retrieves the details of an existing Transaction. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + _inner_class_types = { "balance_impact": BalanceImpact, "flow_details": FlowDetails, diff --git a/stripe/treasury/_transaction_entry.py b/stripe/treasury/_transaction_entry.py index 317a5318b..56cf9caa2 100644 --- a/stripe/treasury/_transaction_entry.py +++ b/stripe/treasury/_transaction_entry.py @@ -284,6 +284,27 @@ def list( return result + @classmethod + async def list_async( + cls, **params: Unpack["TransactionEntry.ListParams"] + ) -> ListObject["TransactionEntry"]: + """ + Retrieves a list of TransactionEntry objects. + """ + 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["TransactionEntry.RetrieveParams"] @@ -295,6 +316,17 @@ def retrieve( instance.refresh() return instance + @classmethod + async def retrieve_async( + cls, id: str, **params: Unpack["TransactionEntry.RetrieveParams"] + ) -> "TransactionEntry": + """ + Retrieves a TransactionEntry object. + """ + instance = cls(id, **params) + await instance.refresh_async() + return instance + @classmethod def class_url(cls): return "/v1/treasury/transaction_entries" diff --git a/tests/test_generated_examples.py b/tests/test_generated_examples.py index e9e76cb85..d3b6050c7 100644 --- a/tests/test_generated_examples.py +++ b/tests/test_generated_examples.py @@ -2,6 +2,7 @@ # File generated from our OpenAPI spec from __future__ import absolute_import, division, print_function import stripe +import pytest from tests.http_client_mock import HTTPClientMock import io @@ -25,6 +26,23 @@ def test_account_links_post( post_data="account=acct_xxxxxxxxxxxxx&refresh_url=https%3A%2F%2Fexample.com%2Freauth&return_url=https%3A%2F%2Fexample.com%2Freturn&type=account_onboarding", ) + @pytest.mark.anyio + async def test_account_links_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.AccountLink.create_async( + account="acct_xxxxxxxxxxxxx", + refresh_url="https://example.com/reauth", + return_url="https://example.com/return", + type="account_onboarding", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/account_links", + query_string="", + post_data="account=acct_xxxxxxxxxxxxx&refresh_url=https%3A%2F%2Fexample.com%2Freauth&return_url=https%3A%2F%2Fexample.com%2Freturn&type=account_onboarding", + ) + def test_account_links_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -63,6 +81,17 @@ def test_accounts_capabilities_get( query_string="", ) + @pytest.mark.anyio + async def test_accounts_capabilities_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.list_capabilities_async("acct_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/capabilities", + query_string="", + ) + def test_accounts_capabilities_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -96,6 +125,20 @@ def test_accounts_capabilities_get_2( query_string="", ) + @pytest.mark.anyio + async def test_accounts_capabilities_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.retrieve_capability_async( + "acct_xxxxxxxxxxxxx", + "card_payments", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/capabilities/card_payments", + query_string="", + ) + def test_accounts_capabilities_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -134,6 +177,22 @@ def test_accounts_capabilities_post( post_data="requested=True", ) + @pytest.mark.anyio + async def test_accounts_capabilities_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.modify_capability_async( + "acct_xxxxxxxxxxxxx", + "card_payments", + requested=True, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/capabilities/card_payments", + query_string="", + post_data="requested=True", + ) + def test_accounts_capabilities_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -167,6 +226,17 @@ def test_accounts_delete(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_accounts_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.delete_async("acct_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/accounts/acct_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -200,6 +270,20 @@ def test_accounts_external_accounts_delete( query_string="", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.delete_external_account_async( + "acct_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "delete", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/ba_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_external_accounts_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -236,6 +320,20 @@ def test_accounts_external_accounts_delete_2( query_string="", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_delete_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.delete_external_account_async( + "acct_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "delete", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/card_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_external_accounts_delete_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -272,6 +370,20 @@ def test_accounts_external_accounts_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.list_external_accounts_async( + "acct_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts", + query_string="limit=3", + ) + def test_accounts_external_accounts_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -310,6 +422,21 @@ def test_accounts_external_accounts_get_2( query_string="object=bank_account&limit=3", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.list_external_accounts_async( + "acct_xxxxxxxxxxxxx", + object="bank_account", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts", + query_string="object=bank_account&limit=3", + ) + def test_accounts_external_accounts_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -348,6 +475,21 @@ def test_accounts_external_accounts_get_3( query_string="object=card&limit=3", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.list_external_accounts_async( + "acct_xxxxxxxxxxxxx", + object="card", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts", + query_string="object=card&limit=3", + ) + def test_accounts_external_accounts_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -385,6 +527,20 @@ def test_accounts_external_accounts_get_4( query_string="", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_get_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.retrieve_external_account_async( + "acct_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/ba_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_external_accounts_get_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -421,6 +577,20 @@ def test_accounts_external_accounts_get_5( query_string="", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_get_5_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.retrieve_external_account_async( + "acct_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/card_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_external_accounts_get_5_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -458,6 +628,21 @@ def test_accounts_external_accounts_post( post_data="external_account=btok_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.create_external_account_async( + "acct_xxxxxxxxxxxxx", + external_account="btok_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts", + query_string="", + post_data="external_account=btok_xxxxxxxxxxxxx", + ) + def test_accounts_external_accounts_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -496,6 +681,21 @@ def test_accounts_external_accounts_post_2( post_data="external_account=tok_xxxx_debit", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.create_external_account_async( + "acct_xxxxxxxxxxxxx", + external_account="tok_xxxx_debit", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts", + query_string="", + post_data="external_account=tok_xxxx_debit", + ) + def test_accounts_external_accounts_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -535,6 +735,22 @@ def test_accounts_external_accounts_post_3( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.modify_external_account_async( + "acct_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/ba_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_accounts_external_accounts_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -575,6 +791,22 @@ def test_accounts_external_accounts_post_4( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_accounts_external_accounts_post_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.modify_external_account_async( + "acct_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/external_accounts/card_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_accounts_external_accounts_post_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -608,6 +840,17 @@ def test_accounts_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_accounts_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts", + query_string="limit=3", + ) + def test_accounts_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -637,6 +880,17 @@ def test_accounts_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_accounts_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.retrieve_async("acct_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -667,6 +921,17 @@ def test_accounts_login_links_post( query_string="", ) + @pytest.mark.anyio + async def test_accounts_login_links_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.create_login_link_async("acct_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/login_links", + query_string="", + ) + def test_accounts_login_links_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -700,6 +965,20 @@ def test_accounts_persons_delete( query_string="", ) + @pytest.mark.anyio + async def test_accounts_persons_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.delete_person_async( + "acct_xxxxxxxxxxxxx", + "person_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "delete", + path="/v1/accounts/acct_xxxxxxxxxxxxx/persons/person_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_persons_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -736,6 +1015,20 @@ def test_accounts_persons_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_accounts_persons_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.list_persons_async( + "acct_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/persons", + query_string="limit=3", + ) + def test_accounts_persons_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -773,6 +1066,20 @@ def test_accounts_persons_get_2( query_string="", ) + @pytest.mark.anyio + async def test_accounts_persons_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.retrieve_person_async( + "acct_xxxxxxxxxxxxx", + "person_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/accounts/acct_xxxxxxxxxxxxx/persons/person_xxxxxxxxxxxxx", + query_string="", + ) + def test_accounts_persons_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -811,6 +1118,22 @@ def test_accounts_persons_post( post_data="first_name=Jane&last_name=Diaz", ) + @pytest.mark.anyio + async def test_accounts_persons_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.create_person_async( + "acct_xxxxxxxxxxxxx", + first_name="Jane", + last_name="Diaz", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/persons", + query_string="", + post_data="first_name=Jane&last_name=Diaz", + ) + def test_accounts_persons_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -850,6 +1173,22 @@ def test_accounts_persons_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_accounts_persons_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.modify_person_async( + "acct_xxxxxxxxxxxxx", + "person_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/persons/person_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_accounts_persons_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -892,6 +1231,26 @@ def test_accounts_post(self, http_client_mock: HTTPClientMock) -> None: post_data="type=custom&country=US&email=jenny.rosen%40example.com&capabilities[card_payments][requested]=True&capabilities[transfers][requested]=True", ) + @pytest.mark.anyio + async def test_accounts_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.create_async( + type="custom", + country="US", + email="jenny.rosen@example.com", + capabilities={ + "card_payments": {"requested": True}, + "transfers": {"requested": True}, + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts", + query_string="", + post_data="type=custom&country=US&email=jenny.rosen%40example.com&capabilities[card_payments][requested]=True&capabilities[transfers][requested]=True", + ) + def test_accounts_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -935,6 +1294,21 @@ def test_accounts_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_accounts_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.modify_async( + "acct_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_accounts_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -973,6 +1347,21 @@ def test_accounts_reject_post( post_data="reason=fraud", ) + @pytest.mark.anyio + async def test_accounts_reject_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Account.reject_async( + "acct_xxxxxxxxxxxxx", + reason="fraud", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/accounts/acct_xxxxxxxxxxxxx/reject", + query_string="", + post_data="reason=fraud", + ) + def test_accounts_reject_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1007,10 +1396,21 @@ def test_application_fees_get( query_string="limit=3", ) - def test_application_fees_get_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_application_fees_get_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.ApplicationFee.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/application_fees", + query_string="limit=3", + ) + + def test_application_fees_get_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( "get", "/v1/application_fees", "limit=3", @@ -1038,6 +1438,17 @@ def test_application_fees_get_2( query_string="", ) + @pytest.mark.anyio + async def test_application_fees_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ApplicationFee.retrieve_async("fee_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/application_fees/fee_xxxxxxxxxxxxx", + query_string="", + ) + def test_application_fees_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1071,6 +1482,20 @@ def test_application_fees_refunds_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_application_fees_refunds_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ApplicationFee.list_refunds_async( + "fee_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/application_fees/fee_xxxxxxxxxxxxx/refunds", + query_string="limit=3", + ) + def test_application_fees_refunds_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1108,6 +1533,20 @@ def test_application_fees_refunds_get_2( query_string="", ) + @pytest.mark.anyio + async def test_application_fees_refunds_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ApplicationFee.retrieve_refund_async( + "fee_xxxxxxxxxxxxx", + "fr_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/application_fees/fee_xxxxxxxxxxxxx/refunds/fr_xxxxxxxxxxxxx", + query_string="", + ) + def test_application_fees_refunds_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1141,6 +1580,17 @@ def test_application_fees_refunds_post( query_string="", ) + @pytest.mark.anyio + async def test_application_fees_refunds_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ApplicationFee.create_refund_async("fee_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/application_fees/fee_xxxxxxxxxxxxx/refunds", + query_string="", + ) + def test_application_fees_refunds_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1176,6 +1626,22 @@ def test_application_fees_refunds_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_application_fees_refunds_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ApplicationFee.modify_refund_async( + "fee_xxxxxxxxxxxxx", + "fr_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/application_fees/fee_xxxxxxxxxxxxx/refunds/fr_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_application_fees_refunds_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1215,6 +1681,21 @@ def test_apps_secrets_delete_post( post_data="name=my-api-key&scope[type]=account", ) + @pytest.mark.anyio + async def test_apps_secrets_delete_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.apps.Secret.delete_where_async( + name="my-api-key", + scope={"type": "account"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/apps/secrets/delete", + query_string="", + post_data="name=my-api-key&scope[type]=account", + ) + def test_apps_secrets_delete_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1254,6 +1735,20 @@ def test_apps_secrets_find_get( query_string="name=sec_123&scope[type]=account", ) + @pytest.mark.anyio + async def test_apps_secrets_find_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.apps.Secret.find_async( + name="sec_123", + scope={"type": "account"}, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/apps/secrets/find", + query_string="name=sec_123&scope[type]=account", + ) + def test_apps_secrets_find_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1291,6 +1786,20 @@ def test_apps_secrets_get(self, http_client_mock: HTTPClientMock) -> None: query_string="scope[type]=account&limit=2", ) + @pytest.mark.anyio + async def test_apps_secrets_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.apps.Secret.list_async( + scope={"type": "account"}, + limit=2, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/apps/secrets", + query_string="scope[type]=account&limit=2", + ) + def test_apps_secrets_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1325,6 +1834,20 @@ def test_apps_secrets_get_2( query_string="scope[type]=account&limit=2", ) + @pytest.mark.anyio + async def test_apps_secrets_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.apps.Secret.list_async( + scope={"type": "account"}, + limit=2, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/apps/secrets", + query_string="scope[type]=account&limit=2", + ) + def test_apps_secrets_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1359,6 +1882,22 @@ def test_apps_secrets_post(self, http_client_mock: HTTPClientMock) -> None: post_data="name=sec_123&payload=very%20secret%20string&scope[type]=account", ) + @pytest.mark.anyio + async def test_apps_secrets_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.apps.Secret.create_async( + name="sec_123", + payload="very secret string", + scope={"type": "account"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/apps/secrets", + query_string="", + post_data="name=sec_123&payload=very%20secret%20string&scope[type]=account", + ) + def test_apps_secrets_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1401,6 +1940,22 @@ def test_apps_secrets_post_2( post_data="name=my-api-key&payload=secret_key_xxxxxx&scope[type]=account", ) + @pytest.mark.anyio + async def test_apps_secrets_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.apps.Secret.create_async( + name="my-api-key", + payload="secret_key_xxxxxx", + scope={"type": "account"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/apps/secrets", + query_string="", + post_data="name=my-api-key&payload=secret_key_xxxxxx&scope[type]=account", + ) + def test_apps_secrets_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1438,6 +1993,17 @@ def test_balance_transactions_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_balance_transactions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.BalanceTransaction.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/balance_transactions", + query_string="limit=3", + ) + def test_balance_transactions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1469,6 +2035,17 @@ def test_balance_transactions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_balance_transactions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.BalanceTransaction.retrieve_async("txn_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/balance_transactions/txn_xxxxxxxxxxxxx", + query_string="", + ) + def test_balance_transactions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1499,6 +2076,17 @@ def test_billing_portal_configurations_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_billing_portal_configurations_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.billing_portal.Configuration.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/billing_portal/configurations", + query_string="limit=3", + ) + def test_billing_portal_configurations_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1530,6 +2118,19 @@ def test_billing_portal_configurations_get_2( query_string="", ) + @pytest.mark.anyio + async def test_billing_portal_configurations_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.billing_portal.Configuration.retrieve_async( + "bpc_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/billing_portal/configurations/bpc_xxxxxxxxxxxxx", + query_string="", + ) + def test_billing_portal_configurations_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1573,6 +2174,30 @@ def test_billing_portal_configurations_post( post_data="features[customer_update][allowed_updates][0]=email&features[customer_update][allowed_updates][1]=tax_id&features[customer_update][enabled]=True&features[invoice_history][enabled]=True&business_profile[privacy_policy_url]=https%3A%2F%2Fexample.com%2Fprivacy&business_profile[terms_of_service_url]=https%3A%2F%2Fexample.com%2Fterms", ) + @pytest.mark.anyio + async def test_billing_portal_configurations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.billing_portal.Configuration.create_async( + features={ + "customer_update": { + "allowed_updates": ["email", "tax_id"], + "enabled": True, + }, + "invoice_history": {"enabled": True}, + }, + business_profile={ + "privacy_policy_url": "https://example.com/privacy", + "terms_of_service_url": "https://example.com/terms", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/billing_portal/configurations", + query_string="", + post_data="features[customer_update][allowed_updates][0]=email&features[customer_update][allowed_updates][1]=tax_id&features[customer_update][enabled]=True&features[invoice_history][enabled]=True&business_profile[privacy_policy_url]=https%3A%2F%2Fexample.com%2Fprivacy&business_profile[terms_of_service_url]=https%3A%2F%2Fexample.com%2Fterms", + ) + def test_billing_portal_configurations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1625,6 +2250,24 @@ def test_billing_portal_configurations_post_2( post_data="business_profile[privacy_policy_url]=https%3A%2F%2Fexample.com%2Fprivacy&business_profile[terms_of_service_url]=https%3A%2F%2Fexample.com%2Fterms", ) + @pytest.mark.anyio + async def test_billing_portal_configurations_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.billing_portal.Configuration.modify_async( + "bpc_xxxxxxxxxxxxx", + business_profile={ + "privacy_policy_url": "https://example.com/privacy", + "terms_of_service_url": "https://example.com/terms", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/billing_portal/configurations/bpc_xxxxxxxxxxxxx", + query_string="", + post_data="business_profile[privacy_policy_url]=https%3A%2F%2Fexample.com%2Fprivacy&business_profile[terms_of_service_url]=https%3A%2F%2Fexample.com%2Fterms", + ) + def test_billing_portal_configurations_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1668,6 +2311,21 @@ def test_billing_portal_sessions_post( post_data="customer=cus_xxxxxxxxxxxxx&return_url=https%3A%2F%2Fexample.com%2Faccount", ) + @pytest.mark.anyio + async def test_billing_portal_sessions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.billing_portal.Session.create_async( + customer="cus_xxxxxxxxxxxxx", + return_url="https://example.com/account", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/billing_portal/sessions", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx&return_url=https%3A%2F%2Fexample.com%2Faccount", + ) + def test_billing_portal_sessions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1704,6 +2362,17 @@ def test_charges_capture_post( query_string="", ) + @pytest.mark.anyio + async def test_charges_capture_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Charge.capture_async("ch_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/charges/ch_xxxxxxxxxxxxx/capture", + query_string="", + ) + def test_charges_capture_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1732,6 +2401,17 @@ def test_charges_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_charges_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Charge.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/charges", + query_string="limit=3", + ) + def test_charges_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1761,6 +2441,17 @@ def test_charges_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_charges_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Charge.retrieve_async("ch_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/charges/ch_xxxxxxxxxxxxx", + query_string="", + ) + def test_charges_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1795,6 +2486,23 @@ def test_charges_post(self, http_client_mock: HTTPClientMock) -> None: post_data="amount=2000¤cy=usd&source=tok_xxxx&description=My%20First%20Test%20Charge%20%28created%20for%20API%20docs%20at%20https%3A%2F%2Fwww.stripe.com%2Fdocs%2Fapi%29", ) + @pytest.mark.anyio + async def test_charges_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Charge.create_async( + amount=2000, + currency="usd", + source="tok_xxxx", + description="My First Test Charge (created for API docs at https://www.stripe.com/docs/api)", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/charges", + query_string="", + post_data="amount=2000¤cy=usd&source=tok_xxxx&description=My%20First%20Test%20Charge%20%28created%20for%20API%20docs%20at%20https%3A%2F%2Fwww.stripe.com%2Fdocs%2Fapi%29", + ) + def test_charges_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1835,6 +2543,21 @@ def test_charges_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_charges_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Charge.modify_async( + "ch_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/charges/ch_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_charges_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1871,6 +2594,19 @@ def test_charges_search_get( query_string="query=amount%3E999%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", ) + @pytest.mark.anyio + async def test_charges_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Charge.search_async( + query="amount>999 AND metadata['order_id']:'6735'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/charges/search", + query_string="query=amount%3E999%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", + ) + def test_charges_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1906,6 +2642,17 @@ def test_checkout_sessions_expire_post( query_string="", ) + @pytest.mark.anyio + async def test_checkout_sessions_expire_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.expire_async("sess_xyz") + http_client_mock_async.assert_requested( + "post", + path="/v1/checkout/sessions/sess_xyz/expire", + query_string="", + ) + def test_checkout_sessions_expire_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1936,6 +2683,17 @@ def test_checkout_sessions_expire_post_2( query_string="", ) + @pytest.mark.anyio + async def test_checkout_sessions_expire_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.expire_async("cs_test_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/checkout/sessions/cs_test_xxxxxxxxxxxxx/expire", + query_string="", + ) + def test_checkout_sessions_expire_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1966,6 +2724,17 @@ def test_checkout_sessions_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_checkout_sessions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/checkout/sessions", + query_string="limit=3", + ) + def test_checkout_sessions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -1997,6 +2766,17 @@ def test_checkout_sessions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_checkout_sessions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.retrieve_async("cs_test_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/checkout/sessions/cs_test_xxxxxxxxxxxxx", + query_string="", + ) + def test_checkout_sessions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2027,6 +2807,17 @@ def test_checkout_sessions_line_items_get( query_string="", ) + @pytest.mark.anyio + async def test_checkout_sessions_line_items_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.list_line_items_async("sess_xyz") + http_client_mock_async.assert_requested( + "get", + path="/v1/checkout/sessions/sess_xyz/line_items", + query_string="", + ) + def test_checkout_sessions_line_items_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2074,8 +2865,36 @@ def test_checkout_sessions_post( post_data="success_url=https%3A%2F%2Fexample.com%2Fsuccess&cancel_url=https%3A%2F%2Fexample.com%2Fcancel&mode=payment&shipping_options[0][shipping_rate]=shr_standard&shipping_options[1][shipping_rate_data][display_name]=Standard&shipping_options[1][shipping_rate_data][delivery_estimate][minimum][unit]=day&shipping_options[1][shipping_rate_data][delivery_estimate][minimum][value]=5&shipping_options[1][shipping_rate_data][delivery_estimate][maximum][unit]=day&shipping_options[1][shipping_rate_data][delivery_estimate][maximum][value]=7", ) - def test_checkout_sessions_post_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_checkout_sessions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.create_async( + success_url="https://example.com/success", + cancel_url="https://example.com/cancel", + mode="payment", + shipping_options=[ + {"shipping_rate": "shr_standard"}, + { + "shipping_rate_data": { + "display_name": "Standard", + "delivery_estimate": { + "minimum": {"unit": "day", "value": 5}, + "maximum": {"unit": "day", "value": 7}, + }, + }, + }, + ], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/checkout/sessions", + query_string="", + post_data="success_url=https%3A%2F%2Fexample.com%2Fsuccess&cancel_url=https%3A%2F%2Fexample.com%2Fcancel&mode=payment&shipping_options[0][shipping_rate]=shr_standard&shipping_options[1][shipping_rate_data][display_name]=Standard&shipping_options[1][shipping_rate_data][delivery_estimate][minimum][unit]=day&shipping_options[1][shipping_rate_data][delivery_estimate][minimum][value]=5&shipping_options[1][shipping_rate_data][delivery_estimate][maximum][unit]=day&shipping_options[1][shipping_rate_data][delivery_estimate][maximum][value]=7", + ) + + def test_checkout_sessions_post_service( + self, http_client_mock: HTTPClientMock ) -> None: http_client_mock.stub_request( "post", @@ -2128,6 +2947,22 @@ def test_checkout_sessions_post_2( post_data="success_url=https%3A%2F%2Fexample.com%2Fsuccess&line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=2&mode=payment", ) + @pytest.mark.anyio + async def test_checkout_sessions_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.checkout.Session.create_async( + success_url="https://example.com/success", + line_items=[{"price": "price_xxxxxxxxxxxxx", "quantity": 2}], + mode="payment", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/checkout/sessions", + query_string="", + post_data="success_url=https%3A%2F%2Fexample.com%2Fsuccess&line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=2&mode=payment", + ) + def test_checkout_sessions_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2165,6 +3000,17 @@ def test_country_specs_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_country_specs_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CountrySpec.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/country_specs", + query_string="limit=3", + ) + def test_country_specs_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2196,6 +3042,17 @@ def test_country_specs_get_2( query_string="", ) + @pytest.mark.anyio + async def test_country_specs_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CountrySpec.retrieve_async("US") + http_client_mock_async.assert_requested( + "get", + path="/v1/country_specs/US", + query_string="", + ) + def test_country_specs_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2224,6 +3081,17 @@ def test_coupons_delete(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_coupons_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Coupon.delete_async("Z4OV52SU") + http_client_mock_async.assert_requested( + "delete", + path="/v1/coupons/Z4OV52SU", + query_string="", + ) + def test_coupons_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2252,6 +3120,17 @@ def test_coupons_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_coupons_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Coupon.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/coupons", + query_string="limit=3", + ) + def test_coupons_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2281,6 +3160,17 @@ def test_coupons_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_coupons_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Coupon.retrieve_async("Z4OV52SU") + http_client_mock_async.assert_requested( + "get", + path="/v1/coupons/Z4OV52SU", + query_string="", + ) + def test_coupons_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2314,6 +3204,22 @@ def test_coupons_post(self, http_client_mock: HTTPClientMock) -> None: post_data="percent_off=25.5&duration=repeating&duration_in_months=3", ) + @pytest.mark.anyio + async def test_coupons_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Coupon.create_async( + percent_off=25.5, + duration="repeating", + duration_in_months=3, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/coupons", + query_string="", + post_data="percent_off=25.5&duration=repeating&duration_in_months=3", + ) + def test_coupons_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2353,6 +3259,21 @@ def test_coupons_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_coupons_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Coupon.modify_async( + "Z4OV52SU", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/coupons/Z4OV52SU", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_coupons_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2385,6 +3306,17 @@ def test_credit_notes_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_credit_notes_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CreditNote.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/credit_notes", + query_string="limit=3", + ) + def test_credit_notes_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2419,6 +3351,20 @@ def test_credit_notes_lines_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_credit_notes_lines_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CreditNote.list_lines_async( + "cn_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/credit_notes/cn_xxxxxxxxxxxxx/lines", + query_string="limit=3", + ) + def test_credit_notes_lines_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2461,6 +3407,27 @@ def test_credit_notes_post(self, http_client_mock: HTTPClientMock) -> None: post_data="invoice=in_xxxxxxxxxxxxx&lines[0][type]=invoice_line_item&lines[0][invoice_line_item]=il_xxxxxxxxxxxxx&lines[0][quantity]=1", ) + @pytest.mark.anyio + async def test_credit_notes_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CreditNote.create_async( + invoice="in_xxxxxxxxxxxxx", + lines=[ + { + "type": "invoice_line_item", + "invoice_line_item": "il_xxxxxxxxxxxxx", + "quantity": 1, + }, + ], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/credit_notes", + query_string="", + post_data="invoice=in_xxxxxxxxxxxxx&lines[0][type]=invoice_line_item&lines[0][invoice_line_item]=il_xxxxxxxxxxxxx&lines[0][quantity]=1", + ) + def test_credit_notes_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2512,6 +3479,26 @@ def test_credit_notes_preview_get( query_string="invoice=in_xxxxxxxxxxxxx&lines[0][type]=invoice_line_item&lines[0][invoice_line_item]=il_xxxxxxxxxxxxx&lines[0][quantity]=1", ) + @pytest.mark.anyio + async def test_credit_notes_preview_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CreditNote.preview_async( + invoice="in_xxxxxxxxxxxxx", + lines=[ + { + "type": "invoice_line_item", + "invoice_line_item": "il_xxxxxxxxxxxxx", + "quantity": 1, + }, + ], + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/credit_notes/preview", + query_string="invoice=in_xxxxxxxxxxxxx&lines[0][type]=invoice_line_item&lines[0][invoice_line_item]=il_xxxxxxxxxxxxx&lines[0][quantity]=1", + ) + def test_credit_notes_preview_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2557,6 +3544,20 @@ def test_credit_notes_preview_lines_get( query_string="limit=3&invoice=in_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_credit_notes_preview_lines_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CreditNote.preview_lines_async( + limit=3, + invoice="in_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/credit_notes/preview/lines", + query_string="limit=3&invoice=in_xxxxxxxxxxxxx", + ) + def test_credit_notes_preview_lines_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2593,6 +3594,17 @@ def test_credit_notes_void_post( query_string="", ) + @pytest.mark.anyio + async def test_credit_notes_void_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CreditNote.void_credit_note_async("cn_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/credit_notes/cn_xxxxxxxxxxxxx/void", + query_string="", + ) + def test_credit_notes_void_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2627,6 +3639,21 @@ def test_customer_sessions_post( post_data="customer=cus_123&components[buy_button][enabled]=True", ) + @pytest.mark.anyio + async def test_customer_sessions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.CustomerSession.create_async( + customer="cus_123", + components={"buy_button": {"enabled": True}}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customer_sessions", + query_string="", + post_data="customer=cus_123&components[buy_button][enabled]=True", + ) + def test_customer_sessions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2666,6 +3693,20 @@ def test_customers_balance_transactions_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_customers_balance_transactions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_balance_transactions_async( + "cus_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions", + query_string="limit=3", + ) + def test_customers_balance_transactions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2703,6 +3744,20 @@ def test_customers_balance_transactions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_customers_balance_transactions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.retrieve_balance_transaction_async( + "cus_xxxxxxxxxxxxx", + "cbtxn_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions/cbtxn_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_balance_transactions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2741,6 +3796,22 @@ def test_customers_balance_transactions_post( post_data="amount=-500¤cy=usd", ) + @pytest.mark.anyio + async def test_customers_balance_transactions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.create_balance_transaction_async( + "cus_xxxxxxxxxxxxx", + amount=-500, + currency="usd", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions", + query_string="", + post_data="amount=-500¤cy=usd", + ) + def test_customers_balance_transactions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2780,6 +3851,22 @@ def test_customers_balance_transactions_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_customers_balance_transactions_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.modify_balance_transaction_async( + "cus_xxxxxxxxxxxxx", + "cbtxn_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/balance_transactions/cbtxn_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_customers_balance_transactions_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2815,6 +3902,17 @@ def test_customers_cash_balance_get( query_string="", ) + @pytest.mark.anyio + async def test_customers_cash_balance_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.retrieve_cash_balance_async("cus_123") + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_123/cash_balance", + query_string="", + ) + def test_customers_cash_balance_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2849,6 +3947,21 @@ def test_customers_cash_balance_post( post_data="settings[reconciliation_mode]=manual", ) + @pytest.mark.anyio + async def test_customers_cash_balance_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.modify_cash_balance_async( + "cus_123", + settings={"reconciliation_mode": "manual"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_123/cash_balance", + query_string="", + post_data="settings[reconciliation_mode]=manual", + ) + def test_customers_cash_balance_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2881,6 +3994,17 @@ def test_customers_delete(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_customers_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.delete_async("cus_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/customers/cus_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2920,6 +4044,26 @@ def test_customers_funding_instructions_post( post_data="bank_transfer[requested_address_types][0]=zengin&bank_transfer[type]=jp_bank_transfer¤cy=usd&funding_type=bank_transfer", ) + @pytest.mark.anyio + async def test_customers_funding_instructions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.create_funding_instructions_async( + "cus_123", + bank_transfer={ + "requested_address_types": ["zengin"], + "type": "jp_bank_transfer", + }, + currency="usd", + funding_type="bank_transfer", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_123/funding_instructions", + query_string="", + post_data="bank_transfer[requested_address_types][0]=zengin&bank_transfer[type]=jp_bank_transfer¤cy=usd&funding_type=bank_transfer", + ) + def test_customers_funding_instructions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2959,6 +4103,17 @@ def test_customers_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_customers_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers", + query_string="limit=3", + ) + def test_customers_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -2988,6 +4143,17 @@ def test_customers_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_customers_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers", + query_string="limit=3", + ) + def test_customers_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3017,6 +4183,17 @@ def test_customers_get_3(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_customers_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.retrieve_async("cus_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3050,10 +4227,24 @@ def test_customers_payment_methods_get( query_string="type=card", ) - def test_customers_payment_methods_get_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_customers_payment_methods_get_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.Customer.list_payment_methods_async( + "cus_xyz", + type="card", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xyz/payment_methods", + query_string="type=card", + ) + + def test_customers_payment_methods_get_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( "get", "/v1/customers/cus_xyz/payment_methods", "type=card", @@ -3087,6 +4278,20 @@ def test_customers_payment_methods_get_2( query_string="type=card", ) + @pytest.mark.anyio + async def test_customers_payment_methods_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_payment_methods_async( + "cus_xxxxxxxxxxxxx", + type="card", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/payment_methods", + query_string="type=card", + ) + def test_customers_payment_methods_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3122,6 +4327,20 @@ def test_customers_post(self, http_client_mock: HTTPClientMock) -> None: post_data="description=My%20First%20Test%20Customer%20%28created%20for%20API%20docs%20at%20https%3A%2F%2Fwww.stripe.com%2Fdocs%2Fapi%29", ) + @pytest.mark.anyio + async def test_customers_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.create_async( + description="My First Test Customer (created for API docs at https://www.stripe.com/docs/api)", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers", + query_string="", + post_data="description=My%20First%20Test%20Customer%20%28created%20for%20API%20docs%20at%20https%3A%2F%2Fwww.stripe.com%2Fdocs%2Fapi%29", + ) + def test_customers_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3159,6 +4378,21 @@ def test_customers_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_customers_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.modify_async( + "cus_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_customers_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3195,6 +4429,19 @@ def test_customers_search_get( query_string="query=name%3A%27fakename%27%20AND%20metadata%5B%27foo%27%5D%3A%27bar%27", ) + @pytest.mark.anyio + async def test_customers_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.search_async( + query="name:'fakename' AND metadata['foo']:'bar'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/search", + query_string="query=name%3A%27fakename%27%20AND%20metadata%5B%27foo%27%5D%3A%27bar%27", + ) + def test_customers_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3232,6 +4479,19 @@ def test_customers_search_get_2( query_string="query=name%3A%27fakename%27%20AND%20metadata%5B%27foo%27%5D%3A%27bar%27", ) + @pytest.mark.anyio + async def test_customers_search_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.search_async( + query="name:'fakename' AND metadata['foo']:'bar'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/search", + query_string="query=name%3A%27fakename%27%20AND%20metadata%5B%27foo%27%5D%3A%27bar%27", + ) + def test_customers_search_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3270,6 +4530,20 @@ def test_customers_sources_delete( query_string="", ) + @pytest.mark.anyio + async def test_customers_sources_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.delete_source_async( + "cus_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "delete", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_sources_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3306,6 +4580,20 @@ def test_customers_sources_delete_2( query_string="", ) + @pytest.mark.anyio + async def test_customers_sources_delete_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.delete_source_async( + "cus_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "delete", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_sources_delete_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3343,6 +4631,21 @@ def test_customers_sources_get( query_string="object=bank_account&limit=3", ) + @pytest.mark.anyio + async def test_customers_sources_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_sources_async( + "cus_xxxxxxxxxxxxx", + object="bank_account", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources", + query_string="object=bank_account&limit=3", + ) + def test_customers_sources_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3381,6 +4684,21 @@ def test_customers_sources_get_2( query_string="object=card&limit=3", ) + @pytest.mark.anyio + async def test_customers_sources_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_sources_async( + "cus_xxxxxxxxxxxxx", + object="card", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources", + query_string="object=card&limit=3", + ) + def test_customers_sources_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3418,6 +4736,20 @@ def test_customers_sources_get_3( query_string="", ) + @pytest.mark.anyio + async def test_customers_sources_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.retrieve_source_async( + "cus_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_sources_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3454,6 +4786,20 @@ def test_customers_sources_get_4( query_string="", ) + @pytest.mark.anyio + async def test_customers_sources_get_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.retrieve_source_async( + "cus_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_sources_get_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3492,6 +4838,22 @@ def test_customers_sources_post( post_data="account_holder_name=Kamil", ) + @pytest.mark.anyio + async def test_customers_sources_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.modify_source_async( + "cus_123", + "card_123", + account_holder_name="Kamil", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_123/sources/card_123", + query_string="", + post_data="account_holder_name=Kamil", + ) + def test_customers_sources_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3531,6 +4893,21 @@ def test_customers_sources_post_2( post_data="source=btok_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_customers_sources_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.create_source_async( + "cus_xxxxxxxxxxxxx", + source="btok_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources", + query_string="", + post_data="source=btok_xxxxxxxxxxxxx", + ) + def test_customers_sources_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3569,6 +4946,21 @@ def test_customers_sources_post_3( post_data="source=tok_xxxx", ) + @pytest.mark.anyio + async def test_customers_sources_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.create_source_async( + "cus_xxxxxxxxxxxxx", + source="tok_xxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources", + query_string="", + post_data="source=tok_xxxx", + ) + def test_customers_sources_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3608,6 +5000,22 @@ def test_customers_sources_post_4( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_customers_sources_post_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.modify_source_async( + "cus_xxxxxxxxxxxxx", + "ba_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources/ba_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_customers_sources_post_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3648,6 +5056,22 @@ def test_customers_sources_post_5( post_data="name=Jenny%20Rosen", ) + @pytest.mark.anyio + async def test_customers_sources_post_5_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.modify_source_async( + "cus_xxxxxxxxxxxxx", + "card_xxxxxxxxxxxxx", + name="Jenny Rosen", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/sources/card_xxxxxxxxxxxxx", + query_string="", + post_data="name=Jenny%20Rosen", + ) + def test_customers_sources_post_5_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3686,6 +5110,20 @@ def test_customers_tax_ids_delete( query_string="", ) + @pytest.mark.anyio + async def test_customers_tax_ids_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.delete_tax_id_async( + "cus_xxxxxxxxxxxxx", + "txi_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "delete", + path="/v1/customers/cus_xxxxxxxxxxxxx/tax_ids/txi_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_tax_ids_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3722,6 +5160,20 @@ def test_customers_tax_ids_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_customers_tax_ids_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.list_tax_ids_async( + "cus_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/tax_ids", + query_string="limit=3", + ) + def test_customers_tax_ids_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3759,6 +5211,20 @@ def test_customers_tax_ids_get_2( query_string="", ) + @pytest.mark.anyio + async def test_customers_tax_ids_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.retrieve_tax_id_async( + "cus_xxxxxxxxxxxxx", + "txi_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/customers/cus_xxxxxxxxxxxxx/tax_ids/txi_xxxxxxxxxxxxx", + query_string="", + ) + def test_customers_tax_ids_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3797,6 +5263,22 @@ def test_customers_tax_ids_post( post_data="type=eu_vat&value=DE123456789", ) + @pytest.mark.anyio + async def test_customers_tax_ids_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.create_tax_id_async( + "cus_xxxxxxxxxxxxx", + type="eu_vat", + value="DE123456789", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/customers/cus_xxxxxxxxxxxxx/tax_ids", + query_string="", + post_data="type=eu_vat&value=DE123456789", + ) + def test_customers_tax_ids_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3831,6 +5313,17 @@ def test_disputes_close_post( query_string="", ) + @pytest.mark.anyio + async def test_disputes_close_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Dispute.close_async("dp_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/disputes/dp_xxxxxxxxxxxxx/close", + query_string="", + ) + def test_disputes_close_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3859,6 +5352,17 @@ def test_disputes_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_disputes_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Dispute.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/disputes", + query_string="limit=3", + ) + def test_disputes_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3888,6 +5392,17 @@ def test_disputes_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_disputes_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Dispute.retrieve_async("dp_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/disputes/dp_xxxxxxxxxxxxx", + query_string="", + ) + def test_disputes_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3920,6 +5435,21 @@ def test_disputes_post(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_disputes_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Dispute.modify_async( + "dp_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/disputes/dp_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_disputes_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3952,6 +5482,17 @@ def test_events_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_events_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Event.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/events", + query_string="limit=3", + ) + def test_events_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -3981,6 +5522,17 @@ def test_events_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_events_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Event.retrieve_async("evt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/events/evt_xxxxxxxxxxxxx", + query_string="", + ) + def test_events_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4009,6 +5561,17 @@ def test_file_links_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_file_links_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.FileLink.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/file_links", + query_string="limit=3", + ) + def test_file_links_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4038,6 +5601,17 @@ def test_file_links_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_file_links_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.FileLink.retrieve_async("link_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/file_links/link_xxxxxxxxxxxxx", + query_string="", + ) + def test_file_links_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4067,7 +5641,19 @@ def test_file_links_post(self, http_client_mock: HTTPClientMock) -> None: post_data="file=file_xxxxxxxxxxxxx", ) - def test_file_links_post_service( + @pytest.mark.anyio + async def test_file_links_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.FileLink.create_async(file="file_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/file_links", + query_string="", + post_data="file=file_xxxxxxxxxxxxx", + ) + + def test_file_links_post_service( self, http_client_mock: HTTPClientMock ) -> None: http_client_mock.stub_request( @@ -4100,6 +5686,21 @@ def test_file_links_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_file_links_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.FileLink.modify_async( + "link_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/file_links/link_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_file_links_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4132,6 +5733,17 @@ def test_files_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_files_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.File.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/files", + query_string="limit=3", + ) + def test_files_get_service(self, http_client_mock: HTTPClientMock) -> None: http_client_mock.stub_request( "get", @@ -4159,6 +5771,17 @@ def test_files_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_files_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.File.retrieve_async("file_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/files/file_xxxxxxxxxxxxx", + query_string="", + ) + def test_files_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4190,6 +5813,20 @@ def test_files_post(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_files_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.File.create_async( + purpose="account_requirement", + file=io.StringIO("foo"), + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/files", + query_string="", + ) + def test_files_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4225,6 +5862,17 @@ def test_financial_connections_accounts_disconnect_post( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_disconnect_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.disconnect_async("fca_xyz") + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/accounts/fca_xyz/disconnect", + query_string="", + ) + def test_financial_connections_accounts_disconnect_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4255,6 +5903,19 @@ def test_financial_connections_accounts_disconnect_post_2( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_disconnect_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.disconnect_async( + "fca_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/accounts/fca_xxxxxxxxxxxxx/disconnect", + query_string="", + ) + def test_financial_connections_accounts_disconnect_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4285,6 +5946,17 @@ def test_financial_connections_accounts_get( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.list_async() + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/accounts", + query_string="", + ) + def test_financial_connections_accounts_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4315,6 +5987,17 @@ def test_financial_connections_accounts_get_2( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.retrieve_async("fca_xyz") + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/accounts/fca_xyz", + query_string="", + ) + def test_financial_connections_accounts_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4347,6 +6030,19 @@ def test_financial_connections_accounts_get_3( query_string="account_holder[customer]=cus_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.list_async( + account_holder={"customer": "cus_xxxxxxxxxxxxx"}, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/accounts", + query_string="account_holder[customer]=cus_xxxxxxxxxxxxx", + ) + def test_financial_connections_accounts_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4382,6 +6078,19 @@ def test_financial_connections_accounts_get_4( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_get_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.retrieve_async( + "fca_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/accounts/fca_xxxxxxxxxxxxx", + query_string="", + ) + def test_financial_connections_accounts_get_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4415,6 +6124,20 @@ def test_financial_connections_accounts_owners_get( query_string="ownership=fcaowns_xyz", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_owners_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.list_owners_async( + "fca_xyz", + ownership="fcaowns_xyz", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/accounts/fca_xyz/owners", + query_string="ownership=fcaowns_xyz", + ) + def test_financial_connections_accounts_owners_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4453,6 +6176,21 @@ def test_financial_connections_accounts_owners_get_2( query_string="limit=3&ownership=fcaowns_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_owners_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.list_owners_async( + "fca_xxxxxxxxxxxxx", + limit=3, + ownership="fcaowns_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/accounts/fca_xxxxxxxxxxxxx/owners", + query_string="limit=3&ownership=fcaowns_xxxxxxxxxxxxx", + ) + def test_financial_connections_accounts_owners_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4491,6 +6229,21 @@ def test_financial_connections_accounts_refresh_post( post_data="features[0]=balance", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_refresh_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.refresh_account_async( + "fca_xyz", + features=["balance"], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/accounts/fca_xyz/refresh", + query_string="", + post_data="features[0]=balance", + ) + def test_financial_connections_accounts_refresh_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4529,6 +6282,21 @@ def test_financial_connections_accounts_subscribe_post( post_data="features[0]=transactions", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_subscribe_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.subscribe_async( + "fa_123", + features=["transactions"], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/accounts/fa_123/subscribe", + query_string="", + post_data="features[0]=transactions", + ) + def test_financial_connections_accounts_subscribe_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4567,6 +6335,21 @@ def test_financial_connections_accounts_unsubscribe_post( post_data="features[0]=transactions", ) + @pytest.mark.anyio + async def test_financial_connections_accounts_unsubscribe_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Account.unsubscribe_async( + "fa_123", + features=["transactions"], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/accounts/fa_123/unsubscribe", + query_string="", + post_data="features[0]=transactions", + ) + def test_financial_connections_accounts_unsubscribe_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4601,6 +6384,17 @@ def test_financial_connections_sessions_get( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_sessions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Session.retrieve_async("fcsess_xyz") + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/sessions/fcsess_xyz", + query_string="", + ) + def test_financial_connections_sessions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4631,6 +6425,19 @@ def test_financial_connections_sessions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_sessions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Session.retrieve_async( + "fcsess_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/sessions/fcsess_xxxxxxxxxxxxx", + query_string="", + ) + def test_financial_connections_sessions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4665,6 +6472,21 @@ def test_financial_connections_sessions_post( post_data="account_holder[type]=customer&account_holder[customer]=cus_123&permissions[0]=balances", ) + @pytest.mark.anyio + async def test_financial_connections_sessions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Session.create_async( + account_holder={"type": "customer", "customer": "cus_123"}, + permissions=["balances"], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/sessions", + query_string="", + post_data="account_holder[type]=customer&account_holder[customer]=cus_123&permissions[0]=balances", + ) + def test_financial_connections_sessions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4709,6 +6531,25 @@ def test_financial_connections_sessions_post_2( post_data="account_holder[type]=customer&account_holder[customer]=cus_xxxxxxxxxxxxx&permissions[0]=payment_method&permissions[1]=balances&filters[countries][0]=US", ) + @pytest.mark.anyio + async def test_financial_connections_sessions_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Session.create_async( + account_holder={ + "type": "customer", + "customer": "cus_xxxxxxxxxxxxx", + }, + permissions=["payment_method", "balances"], + filters={"countries": ["US"]}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/financial_connections/sessions", + query_string="", + post_data="account_holder[type]=customer&account_holder[customer]=cus_xxxxxxxxxxxxx&permissions[0]=payment_method&permissions[1]=balances&filters[countries][0]=US", + ) + def test_financial_connections_sessions_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4749,6 +6590,17 @@ def test_financial_connections_transactions_get( query_string="", ) + @pytest.mark.anyio + async def test_financial_connections_transactions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Transaction.retrieve_async("tr_123") + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/transactions/tr_123", + query_string="", + ) + def test_financial_connections_transactions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4779,6 +6631,19 @@ def test_financial_connections_transactions_get_2( query_string="account=fca_xyz", ) + @pytest.mark.anyio + async def test_financial_connections_transactions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.financial_connections.Transaction.list_async( + account="fca_xyz", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/financial_connections/transactions", + query_string="account=fca_xyz", + ) + def test_financial_connections_transactions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4810,6 +6675,17 @@ def test_identity_verification_reports_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_identity_verification_reports_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationReport.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/identity/verification_reports", + query_string="limit=3", + ) + def test_identity_verification_reports_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4841,6 +6717,19 @@ def test_identity_verification_reports_get_2( query_string="", ) + @pytest.mark.anyio + async def test_identity_verification_reports_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationReport.retrieve_async( + "vr_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/identity/verification_reports/vr_xxxxxxxxxxxxx", + query_string="", + ) + def test_identity_verification_reports_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4871,6 +6760,19 @@ def test_identity_verification_sessions_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_identity_verification_sessions_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationSession.cancel_async( + "vs_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_identity_verification_sessions_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4901,6 +6803,17 @@ def test_identity_verification_sessions_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_identity_verification_sessions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationSession.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/identity/verification_sessions", + query_string="limit=3", + ) + def test_identity_verification_sessions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4932,6 +6845,19 @@ def test_identity_verification_sessions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_identity_verification_sessions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationSession.retrieve_async( + "vs_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx", + query_string="", + ) + def test_identity_verification_sessions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4963,6 +6889,18 @@ def test_identity_verification_sessions_post( post_data="type=document", ) + @pytest.mark.anyio + async def test_identity_verification_sessions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationSession.create_async(type="document") + http_client_mock_async.assert_requested( + "post", + path="/v1/identity/verification_sessions", + query_string="", + post_data="type=document", + ) + def test_identity_verification_sessions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -4998,6 +6936,21 @@ def test_identity_verification_sessions_post_2( post_data="type=id_number", ) + @pytest.mark.anyio + async def test_identity_verification_sessions_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationSession.modify_async( + "vs_xxxxxxxxxxxxx", + type="id_number", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx", + query_string="", + post_data="type=id_number", + ) + def test_identity_verification_sessions_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5032,6 +6985,19 @@ def test_identity_verification_sessions_redact_post( query_string="", ) + @pytest.mark.anyio + async def test_identity_verification_sessions_redact_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.identity.VerificationSession.redact_async( + "vs_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx/redact", + query_string="", + ) + def test_identity_verification_sessions_redact_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5062,6 +7028,17 @@ def test_invoiceitems_delete( query_string="", ) + @pytest.mark.anyio + async def test_invoiceitems_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.InvoiceItem.delete_async("ii_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/invoiceitems/ii_xxxxxxxxxxxxx", + query_string="", + ) + def test_invoiceitems_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5090,6 +7067,17 @@ def test_invoiceitems_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_invoiceitems_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.InvoiceItem.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/invoiceitems", + query_string="limit=3", + ) + def test_invoiceitems_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5121,12 +7109,23 @@ def test_invoiceitems_get_2( query_string="", ) - def test_invoiceitems_get_2_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_invoiceitems_get_2_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.InvoiceItem.retrieve_async("ii_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( "get", - "/v1/invoiceitems/ii_xxxxxxxxxxxxx", + path="/v1/invoiceitems/ii_xxxxxxxxxxxxx", + query_string="", + ) + + def test_invoiceitems_get_2_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "get", + "/v1/invoiceitems/ii_xxxxxxxxxxxxx", ) client = StripeClient( "sk_test_123", @@ -5153,6 +7152,21 @@ def test_invoiceitems_post(self, http_client_mock: HTTPClientMock) -> None: post_data="customer=cus_xxxxxxxxxxxxx&price=price_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_invoiceitems_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.InvoiceItem.create_async( + customer="cus_xxxxxxxxxxxxx", + price="price_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/invoiceitems", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx&price=price_xxxxxxxxxxxxx", + ) + def test_invoiceitems_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5193,6 +7207,21 @@ def test_invoiceitems_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_invoiceitems_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.InvoiceItem.modify_async( + "ii_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/invoiceitems/ii_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_invoiceitems_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5225,6 +7254,17 @@ def test_invoices_delete(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_invoices_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.delete_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/invoices/in_xxxxxxxxxxxxx", + query_string="", + ) + def test_invoices_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5255,6 +7295,17 @@ def test_invoices_finalize_post( query_string="", ) + @pytest.mark.anyio + async def test_invoices_finalize_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.finalize_invoice_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices/in_xxxxxxxxxxxxx/finalize", + query_string="", + ) + def test_invoices_finalize_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5283,6 +7334,17 @@ def test_invoices_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_invoices_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/invoices", + query_string="limit=3", + ) + def test_invoices_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5312,6 +7374,17 @@ def test_invoices_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_invoices_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.retrieve_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/invoices/in_xxxxxxxxxxxxx", + query_string="", + ) + def test_invoices_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5343,6 +7416,20 @@ def test_invoices_get_3(self, http_client_mock: HTTPClientMock) -> None: query_string="expand[0]=customer", ) + @pytest.mark.anyio + async def test_invoices_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.retrieve_async( + "in_xxxxxxxxxxxxx", + expand=["customer"], + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/invoices/in_xxxxxxxxxxxxx", + query_string="expand[0]=customer", + ) + def test_invoices_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5377,6 +7464,17 @@ def test_invoices_mark_uncollectible_post( query_string="", ) + @pytest.mark.anyio + async def test_invoices_mark_uncollectible_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.mark_uncollectible_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices/in_xxxxxxxxxxxxx/mark_uncollectible", + query_string="", + ) + def test_invoices_mark_uncollectible_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5405,6 +7503,17 @@ def test_invoices_pay_post(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_invoices_pay_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.pay_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices/in_xxxxxxxxxxxxx/pay", + query_string="", + ) + def test_invoices_pay_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5434,6 +7543,18 @@ def test_invoices_post(self, http_client_mock: HTTPClientMock) -> None: post_data="customer=cus_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_invoices_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.create_async(customer="cus_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx", + ) + def test_invoices_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5467,6 +7588,21 @@ def test_invoices_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_invoices_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.modify_async( + "in_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices/in_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_invoices_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5503,6 +7639,19 @@ def test_invoices_search_get( query_string="query=total%3E999%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", ) + @pytest.mark.anyio + async def test_invoices_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.search_async( + query="total>999 AND metadata['order_id']:'6735'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/invoices/search", + query_string="query=total%3E999%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", + ) + def test_invoices_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5538,6 +7687,17 @@ def test_invoices_send_post( query_string="", ) + @pytest.mark.anyio + async def test_invoices_send_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.send_invoice_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices/in_xxxxxxxxxxxxx/send", + query_string="", + ) + def test_invoices_send_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5568,6 +7728,17 @@ def test_invoices_upcoming_get( query_string="customer=cus_9utnxg47pWjV1e", ) + @pytest.mark.anyio + async def test_invoices_upcoming_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.upcoming_async(customer="cus_9utnxg47pWjV1e") + http_client_mock_async.assert_requested( + "get", + path="/v1/invoices/upcoming", + query_string="customer=cus_9utnxg47pWjV1e", + ) + def test_invoices_upcoming_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5599,6 +7770,17 @@ def test_invoices_void_post( query_string="", ) + @pytest.mark.anyio + async def test_invoices_void_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Invoice.void_invoice_async("in_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/invoices/in_xxxxxxxxxxxxx/void", + query_string="", + ) + def test_invoices_void_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5629,6 +7811,17 @@ def test_issuing_authorizations_approve_post( query_string="", ) + @pytest.mark.anyio + async def test_issuing_authorizations_approve_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.approve_async("iauth_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/authorizations/iauth_xxxxxxxxxxxxx/approve", + query_string="", + ) + def test_issuing_authorizations_approve_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5659,6 +7852,17 @@ def test_issuing_authorizations_decline_post( query_string="", ) + @pytest.mark.anyio + async def test_issuing_authorizations_decline_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.decline_async("iauth_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/authorizations/iauth_xxxxxxxxxxxxx/decline", + query_string="", + ) + def test_issuing_authorizations_decline_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5689,6 +7893,17 @@ def test_issuing_authorizations_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_issuing_authorizations_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/authorizations", + query_string="limit=3", + ) + def test_issuing_authorizations_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5720,6 +7935,19 @@ def test_issuing_authorizations_get_2( query_string="", ) + @pytest.mark.anyio + async def test_issuing_authorizations_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.retrieve_async( + "iauth_xxxxxxxxxxxxx" + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/authorizations/iauth_xxxxxxxxxxxxx", + query_string="", + ) + def test_issuing_authorizations_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5754,6 +7982,21 @@ def test_issuing_authorizations_post( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_issuing_authorizations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.modify_async( + "iauth_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/authorizations/iauth_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_issuing_authorizations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5788,6 +8031,17 @@ def test_issuing_cardholders_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_issuing_cardholders_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Cardholder.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/cardholders", + query_string="limit=3", + ) + def test_issuing_cardholders_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5819,6 +8073,17 @@ def test_issuing_cardholders_get_2( query_string="", ) + @pytest.mark.anyio + async def test_issuing_cardholders_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Cardholder.retrieve_async("ich_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/cardholders/ich_xxxxxxxxxxxxx", + query_string="", + ) + def test_issuing_cardholders_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5864,6 +8129,32 @@ def test_issuing_cardholders_post( post_data="type=individual&name=Jenny%20Rosen&email=jenny.rosen%40example.com&phone_number=%2B18888675309&billing[address][line1]=1234%20Main%20Street&billing[address][city]=San%20Francisco&billing[address][state]=CA&billing[address][country]=US&billing[address][postal_code]=94111", ) + @pytest.mark.anyio + async def test_issuing_cardholders_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Cardholder.create_async( + type="individual", + name="Jenny Rosen", + email="jenny.rosen@example.com", + phone_number="+18888675309", + billing={ + "address": { + "line1": "1234 Main Street", + "city": "San Francisco", + "state": "CA", + "country": "US", + "postal_code": "94111", + }, + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/cardholders", + query_string="", + post_data="type=individual&name=Jenny%20Rosen&email=jenny.rosen%40example.com&phone_number=%2B18888675309&billing[address][line1]=1234%20Main%20Street&billing[address][city]=San%20Francisco&billing[address][state]=CA&billing[address][country]=US&billing[address][postal_code]=94111", + ) + def test_issuing_cardholders_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5915,6 +8206,21 @@ def test_issuing_cardholders_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_issuing_cardholders_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Cardholder.modify_async( + "ich_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/cardholders/ich_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_issuing_cardholders_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5947,6 +8253,17 @@ def test_issuing_cards_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_issuing_cards_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/cards", + query_string="limit=3", + ) + def test_issuing_cards_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -5978,6 +8295,17 @@ def test_issuing_cards_get_2( query_string="", ) + @pytest.mark.anyio + async def test_issuing_cards_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.retrieve_async("ic_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/cards/ic_xxxxxxxxxxxxx", + query_string="", + ) + def test_issuing_cards_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6013,6 +8341,22 @@ def test_issuing_cards_post( post_data="cardholder=ich_xxxxxxxxxxxxx¤cy=usd&type=virtual", ) + @pytest.mark.anyio + async def test_issuing_cards_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.create_async( + cardholder="ich_xxxxxxxxxxxxx", + currency="usd", + type="virtual", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/cards", + query_string="", + post_data="cardholder=ich_xxxxxxxxxxxxx¤cy=usd&type=virtual", + ) + def test_issuing_cards_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6054,6 +8398,21 @@ def test_issuing_cards_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_issuing_cards_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.modify_async( + "ic_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/cards/ic_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_issuing_cards_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6088,6 +8447,17 @@ def test_issuing_disputes_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_issuing_disputes_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Dispute.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/disputes", + query_string="limit=3", + ) + def test_issuing_disputes_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6119,6 +8489,17 @@ def test_issuing_disputes_get_2( query_string="", ) + @pytest.mark.anyio + async def test_issuing_disputes_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Dispute.retrieve_async("idp_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/disputes/idp_xxxxxxxxxxxxx", + query_string="", + ) + def test_issuing_disputes_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6156,6 +8537,24 @@ def test_issuing_disputes_post( post_data="transaction=ipi_xxxxxxxxxxxxx&evidence[reason]=fraudulent&evidence[fraudulent][explanation]=Purchase%20was%20unrecognized.", ) + @pytest.mark.anyio + async def test_issuing_disputes_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Dispute.create_async( + transaction="ipi_xxxxxxxxxxxxx", + evidence={ + "reason": "fraudulent", + "fraudulent": {"explanation": "Purchase was unrecognized."}, + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/disputes", + query_string="", + post_data="transaction=ipi_xxxxxxxxxxxxx&evidence[reason]=fraudulent&evidence[fraudulent][explanation]=Purchase%20was%20unrecognized.", + ) + def test_issuing_disputes_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6197,10 +8596,21 @@ def test_issuing_disputes_submit_post( query_string="", ) - def test_issuing_disputes_submit_post_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_issuing_disputes_submit_post_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.issuing.Dispute.submit_async("idp_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/disputes/idp_xxxxxxxxxxxxx/submit", + query_string="", + ) + + def test_issuing_disputes_submit_post_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( "post", "/v1/issuing/disputes/idp_xxxxxxxxxxxxx/submit", ) @@ -6227,6 +8637,17 @@ def test_issuing_transactions_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_issuing_transactions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Transaction.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/transactions", + query_string="limit=3", + ) + def test_issuing_transactions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6258,6 +8679,17 @@ def test_issuing_transactions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_issuing_transactions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Transaction.retrieve_async("ipi_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/issuing/transactions/ipi_xxxxxxxxxxxxx", + query_string="", + ) + def test_issuing_transactions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6292,6 +8724,21 @@ def test_issuing_transactions_post( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_issuing_transactions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Transaction.modify_async( + "ipi_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/issuing/transactions/ipi_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_issuing_transactions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6324,6 +8771,17 @@ def test_mandates_get(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_mandates_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Mandate.retrieve_async("mandate_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/mandates/mandate_xxxxxxxxxxxxx", + query_string="", + ) + def test_mandates_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6354,6 +8812,19 @@ def test_payment_intents_apply_customer_balance_post( query_string="", ) + @pytest.mark.anyio + async def test_payment_intents_apply_customer_balance_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.apply_customer_balance_async( + "pi_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/apply_customer_balance", + query_string="", + ) + def test_payment_intents_apply_customer_balance_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6384,6 +8855,17 @@ def test_payment_intents_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_payment_intents_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.cancel_async("pi_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_payment_intents_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6414,6 +8896,17 @@ def test_payment_intents_capture_post( query_string="", ) + @pytest.mark.anyio + async def test_payment_intents_capture_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.capture_async("pi_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/capture", + query_string="", + ) + def test_payment_intents_capture_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6448,6 +8941,21 @@ def test_payment_intents_confirm_post( post_data="payment_method=pm_card_visa", ) + @pytest.mark.anyio + async def test_payment_intents_confirm_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.confirm_async( + "pi_xxxxxxxxxxxxx", + payment_method="pm_card_visa", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/confirm", + query_string="", + post_data="payment_method=pm_card_visa", + ) + def test_payment_intents_confirm_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6482,6 +8990,17 @@ def test_payment_intents_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_payment_intents_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_intents", + query_string="limit=3", + ) + def test_payment_intents_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6513,6 +9032,17 @@ def test_payment_intents_get_2( query_string="", ) + @pytest.mark.anyio + async def test_payment_intents_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.retrieve_async("pi_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx", + query_string="", + ) + def test_payment_intents_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6547,6 +9077,21 @@ def test_payment_intents_increment_authorization_post( post_data="amount=2099", ) + @pytest.mark.anyio + async def test_payment_intents_increment_authorization_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.increment_authorization_async( + "pi_xxxxxxxxxxxxx", + amount=2099, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/increment_authorization", + query_string="", + post_data="amount=2099", + ) + def test_payment_intents_increment_authorization_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6586,6 +9131,22 @@ def test_payment_intents_post( post_data="amount=1099¤cy=eur&automatic_payment_methods[enabled]=True", ) + @pytest.mark.anyio + async def test_payment_intents_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.create_async( + amount=1099, + currency="eur", + automatic_payment_methods={"enabled": True}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents", + query_string="", + post_data="amount=1099¤cy=eur&automatic_payment_methods[enabled]=True", + ) + def test_payment_intents_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6628,6 +9189,22 @@ def test_payment_intents_post_2( post_data="amount=2000¤cy=usd&automatic_payment_methods[enabled]=True", ) + @pytest.mark.anyio + async def test_payment_intents_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.create_async( + amount=2000, + currency="usd", + automatic_payment_methods={"enabled": True}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents", + query_string="", + post_data="amount=2000¤cy=usd&automatic_payment_methods[enabled]=True", + ) + def test_payment_intents_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6669,6 +9246,21 @@ def test_payment_intents_post_3( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_payment_intents_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.modify_async( + "pi_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_payment_intents_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6708,6 +9300,22 @@ def test_payment_intents_post_4( post_data="amount=200¤cy=usd&payment_method_data[type]=p24&payment_method_data[p24][bank]=blik", ) + @pytest.mark.anyio + async def test_payment_intents_post_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.create_async( + amount=200, + currency="usd", + payment_method_data={"type": "p24", "p24": {"bank": "blik"}}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents", + query_string="", + post_data="amount=200¤cy=usd&payment_method_data[type]=p24&payment_method_data[p24][bank]=blik", + ) + def test_payment_intents_post_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6750,6 +9358,19 @@ def test_payment_intents_search_get( query_string="query=status%3A%27succeeded%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", ) + @pytest.mark.anyio + async def test_payment_intents_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.search_async( + query="status:'succeeded' AND metadata['order_id']:'6735'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_intents/search", + query_string="query=status%3A%27succeeded%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", + ) + def test_payment_intents_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6785,6 +9406,19 @@ def test_payment_intents_verify_microdeposits_post( query_string="", ) + @pytest.mark.anyio + async def test_payment_intents_verify_microdeposits_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.verify_microdeposits_async( + "pi_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits", + query_string="", + ) + def test_payment_intents_verify_microdeposits_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6819,6 +9453,21 @@ def test_payment_intents_verify_microdeposits_post_2( post_data="amounts[0]=32&amounts[1]=45", ) + @pytest.mark.anyio + async def test_payment_intents_verify_microdeposits_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentIntent.verify_microdeposits_async( + "pi_xxxxxxxxxxxxx", + amounts=[32, 45], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits", + query_string="", + post_data="amounts[0]=32&amounts[1]=45", + ) + def test_payment_intents_verify_microdeposits_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6851,6 +9500,17 @@ def test_payment_links_get(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_payment_links_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.retrieve_async("pl_xyz") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_links/pl_xyz", + query_string="", + ) + def test_payment_links_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6881,6 +9541,17 @@ def test_payment_links_get_2( query_string="limit=3", ) + @pytest.mark.anyio + async def test_payment_links_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_links", + query_string="limit=3", + ) + def test_payment_links_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6912,6 +9583,17 @@ def test_payment_links_get_3( query_string="", ) + @pytest.mark.anyio + async def test_payment_links_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.retrieve_async("plink_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_links/plink_xxxxxxxxxxxxx", + query_string="", + ) + def test_payment_links_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6942,6 +9624,17 @@ def test_payment_links_line_items_get( query_string="", ) + @pytest.mark.anyio + async def test_payment_links_line_items_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.list_line_items_async("pl_xyz") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_links/pl_xyz/line_items", + query_string="", + ) + def test_payment_links_line_items_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -6975,6 +9668,20 @@ def test_payment_links_post( post_data="line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=1", ) + @pytest.mark.anyio + async def test_payment_links_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.create_async( + line_items=[{"price": "price_xxxxxxxxxxxxx", "quantity": 1}], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_links", + query_string="", + post_data="line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=1", + ) + def test_payment_links_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7015,6 +9722,20 @@ def test_payment_links_post_2( post_data="line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=1", ) + @pytest.mark.anyio + async def test_payment_links_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.create_async( + line_items=[{"price": "price_xxxxxxxxxxxxx", "quantity": 1}], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_links", + query_string="", + post_data="line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=1", + ) + def test_payment_links_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7056,6 +9777,21 @@ def test_payment_links_post_3( post_data="active=False", ) + @pytest.mark.anyio + async def test_payment_links_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentLink.modify_async( + "plink_xxxxxxxxxxxxx", + active=False, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_links/plink_xxxxxxxxxxxxx", + query_string="", + post_data="active=False", + ) + def test_payment_links_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7090,6 +9826,17 @@ def test_payment_method_configurations_get( query_string="application=foo", ) + @pytest.mark.anyio + async def test_payment_method_configurations_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethodConfiguration.list_async(application="foo") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_method_configurations", + query_string="application=foo", + ) + def test_payment_method_configurations_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7121,6 +9868,17 @@ def test_payment_method_configurations_get_2( query_string="", ) + @pytest.mark.anyio + async def test_payment_method_configurations_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethodConfiguration.retrieve_async("foo") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_method_configurations/foo", + query_string="", + ) + def test_payment_method_configurations_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7155,6 +9913,21 @@ def test_payment_method_configurations_post( post_data="acss_debit[display_preference][preference]=none&affirm[display_preference][preference]=none", ) + @pytest.mark.anyio + async def test_payment_method_configurations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethodConfiguration.create_async( + acss_debit={"display_preference": {"preference": "none"}}, + affirm={"display_preference": {"preference": "none"}}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_method_configurations", + query_string="", + post_data="acss_debit[display_preference][preference]=none&affirm[display_preference][preference]=none", + ) + def test_payment_method_configurations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7195,6 +9968,21 @@ def test_payment_method_configurations_post_2( post_data="acss_debit[display_preference][preference]=on", ) + @pytest.mark.anyio + async def test_payment_method_configurations_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethodConfiguration.modify_async( + "foo", + acss_debit={"display_preference": {"preference": "on"}}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_method_configurations/foo", + query_string="", + post_data="acss_debit[display_preference][preference]=on", + ) + def test_payment_method_configurations_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7233,6 +10021,21 @@ def test_payment_methods_attach_post( post_data="customer=cus_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_payment_methods_attach_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethod.attach_async( + "pm_xxxxxxxxxxxxx", + customer="cus_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_methods/pm_xxxxxxxxxxxxx/attach", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx", + ) + def test_payment_methods_attach_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7267,12 +10070,23 @@ def test_payment_methods_detach_post( query_string="", ) - def test_payment_methods_detach_post_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_payment_methods_detach_post_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.PaymentMethod.detach_async("pm_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( "post", - "/v1/payment_methods/pm_xxxxxxxxxxxxx/detach", + path="/v1/payment_methods/pm_xxxxxxxxxxxxx/detach", + query_string="", + ) + + def test_payment_methods_detach_post_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "post", + "/v1/payment_methods/pm_xxxxxxxxxxxxx/detach", ) client = StripeClient( "sk_test_123", @@ -7300,6 +10114,20 @@ def test_payment_methods_get( query_string="customer=cus_xxxxxxxxxxxxx&type=card", ) + @pytest.mark.anyio + async def test_payment_methods_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethod.list_async( + customer="cus_xxxxxxxxxxxxx", + type="card", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_methods", + query_string="customer=cus_xxxxxxxxxxxxx&type=card", + ) + def test_payment_methods_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7336,6 +10164,17 @@ def test_payment_methods_get_2( query_string="", ) + @pytest.mark.anyio + async def test_payment_methods_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethod.retrieve_async("pm_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/payment_methods/pm_xxxxxxxxxxxxx", + query_string="", + ) + def test_payment_methods_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7375,6 +10214,26 @@ def test_payment_methods_post( post_data="type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2024&card[cvc]=314", ) + @pytest.mark.anyio + async def test_payment_methods_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethod.create_async( + type="card", + card={ + "number": "4242424242424242", + "exp_month": 8, + "exp_year": 2024, + "cvc": "314", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_methods", + query_string="", + post_data="type=card&card[number]=4242424242424242&card[exp_month]=8&card[exp_year]=2024&card[cvc]=314", + ) + def test_payment_methods_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7420,6 +10279,21 @@ def test_payment_methods_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_payment_methods_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PaymentMethod.modify_async( + "pm_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payment_methods/pm_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_payment_methods_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7454,6 +10328,17 @@ def test_payouts_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_payouts_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Payout.cancel_async("po_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/payouts/po_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_payouts_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7482,6 +10367,17 @@ def test_payouts_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_payouts_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Payout.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/payouts", + query_string="limit=3", + ) + def test_payouts_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7511,6 +10407,17 @@ def test_payouts_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_payouts_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Payout.retrieve_async("po_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/payouts/po_xxxxxxxxxxxxx", + query_string="", + ) + def test_payouts_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7543,6 +10450,21 @@ def test_payouts_post(self, http_client_mock: HTTPClientMock) -> None: post_data="amount=1100¤cy=usd", ) + @pytest.mark.anyio + async def test_payouts_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Payout.create_async( + amount=1100, + currency="usd", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payouts", + query_string="", + post_data="amount=1100¤cy=usd", + ) + def test_payouts_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7576,6 +10498,21 @@ def test_payouts_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_payouts_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Payout.modify_async( + "po_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/payouts/po_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_payouts_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7610,6 +10547,17 @@ def test_payouts_reverse_post( query_string="", ) + @pytest.mark.anyio + async def test_payouts_reverse_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Payout.reverse_async("po_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/payouts/po_xxxxxxxxxxxxx/reverse", + query_string="", + ) + def test_payouts_reverse_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7638,6 +10586,17 @@ def test_plans_delete(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_plans_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Plan.delete_async("price_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/plans/price_xxxxxxxxxxxxx", + query_string="", + ) + def test_plans_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7666,6 +10625,17 @@ def test_plans_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_plans_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Plan.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/plans", + query_string="limit=3", + ) + def test_plans_get_service(self, http_client_mock: HTTPClientMock) -> None: http_client_mock.stub_request( "get", @@ -7693,6 +10663,17 @@ def test_plans_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_plans_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Plan.retrieve_async("price_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/plans/price_xxxxxxxxxxxxx", + query_string="", + ) + def test_plans_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7727,6 +10708,23 @@ def test_plans_post(self, http_client_mock: HTTPClientMock) -> None: post_data="amount=2000¤cy=usd&interval=month&product=prod_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_plans_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Plan.create_async( + amount=2000, + currency="usd", + interval="month", + product="prod_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/plans", + query_string="", + post_data="amount=2000¤cy=usd&interval=month&product=prod_xxxxxxxxxxxxx", + ) + def test_plans_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7769,6 +10767,23 @@ def test_plans_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="amount=2000¤cy=usd&interval=month&product[name]=My%20product", ) + @pytest.mark.anyio + async def test_plans_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Plan.create_async( + amount=2000, + currency="usd", + interval="month", + product={"name": "My product"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/plans", + query_string="", + post_data="amount=2000¤cy=usd&interval=month&product[name]=My%20product", + ) + def test_plans_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7809,6 +10824,21 @@ def test_plans_post_3(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_plans_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Plan.modify_async( + "price_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/plans/price_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_plans_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7841,6 +10871,17 @@ def test_prices_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_prices_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Price.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/prices", + query_string="limit=3", + ) + def test_prices_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7870,6 +10911,17 @@ def test_prices_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_prices_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Price.retrieve_async("price_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/prices/price_xxxxxxxxxxxxx", + query_string="", + ) + def test_prices_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7908,6 +10960,27 @@ def test_prices_post(self, http_client_mock: HTTPClientMock) -> None: post_data="unit_amount=2000¤cy=usd¤cy_options[uah][unit_amount]=5000¤cy_options[eur][unit_amount]=1800&recurring[interval]=month&product=prod_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_prices_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Price.create_async( + unit_amount=2000, + currency="usd", + currency_options={ + "uah": {"unit_amount": 5000}, + "eur": {"unit_amount": 1800}, + }, + recurring={"interval": "month"}, + product="prod_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/prices", + query_string="", + post_data="unit_amount=2000¤cy=usd¤cy_options[uah][unit_amount]=5000¤cy_options[eur][unit_amount]=1800&recurring[interval]=month&product=prod_xxxxxxxxxxxxx", + ) + def test_prices_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7954,6 +11027,23 @@ def test_prices_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="unit_amount=2000¤cy=usd&recurring[interval]=month&product=prod_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_prices_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Price.create_async( + unit_amount=2000, + currency="usd", + recurring={"interval": "month"}, + product="prod_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/prices", + query_string="", + post_data="unit_amount=2000¤cy=usd&recurring[interval]=month&product=prod_xxxxxxxxxxxxx", + ) + def test_prices_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -7994,6 +11084,21 @@ def test_prices_post_3(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_prices_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Price.modify_async( + "price_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/prices/price_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_prices_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8028,6 +11133,19 @@ def test_prices_search_get(self, http_client_mock: HTTPClientMock) -> None: query_string="query=active%3A%27true%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", ) + @pytest.mark.anyio + async def test_prices_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Price.search_async( + query="active:'true' AND metadata['order_id']:'6735'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/prices/search", + query_string="query=active%3A%27true%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", + ) + def test_prices_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8061,6 +11179,17 @@ def test_products_delete(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_products_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Product.delete_async("prod_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/products/prod_xxxxxxxxxxxxx", + query_string="", + ) + def test_products_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8089,6 +11218,17 @@ def test_products_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_products_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Product.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/products", + query_string="limit=3", + ) + def test_products_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8118,6 +11258,17 @@ def test_products_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_products_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Product.retrieve_async("prod_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/products/prod_xxxxxxxxxxxxx", + query_string="", + ) + def test_products_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8147,6 +11298,18 @@ def test_products_post(self, http_client_mock: HTTPClientMock) -> None: post_data="name=Gold%20Special", ) + @pytest.mark.anyio + async def test_products_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Product.create_async(name="Gold Special") + http_client_mock_async.assert_requested( + "post", + path="/v1/products", + query_string="", + post_data="name=Gold%20Special", + ) + def test_products_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8180,6 +11343,21 @@ def test_products_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_products_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Product.modify_async( + "prod_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/products/prod_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_products_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8216,6 +11394,19 @@ def test_products_search_get( query_string="query=active%3A%27true%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", ) + @pytest.mark.anyio + async def test_products_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Product.search_async( + query="active:'true' AND metadata['order_id']:'6735'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/products/search", + query_string="query=active%3A%27true%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", + ) + def test_products_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8251,6 +11442,17 @@ def test_promotion_codes_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_promotion_codes_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PromotionCode.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/promotion_codes", + query_string="limit=3", + ) + def test_promotion_codes_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8282,10 +11484,21 @@ def test_promotion_codes_get_2( query_string="", ) - def test_promotion_codes_get_2_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_promotion_codes_get_2_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.PromotionCode.retrieve_async("promo_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/promotion_codes/promo_xxxxxxxxxxxxx", + query_string="", + ) + + def test_promotion_codes_get_2_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( "get", "/v1/promotion_codes/promo_xxxxxxxxxxxxx", ) @@ -8313,6 +11526,18 @@ def test_promotion_codes_post( post_data="coupon=Z4OV52SU", ) + @pytest.mark.anyio + async def test_promotion_codes_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PromotionCode.create_async(coupon="Z4OV52SU") + http_client_mock_async.assert_requested( + "post", + path="/v1/promotion_codes", + query_string="", + post_data="coupon=Z4OV52SU", + ) + def test_promotion_codes_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8348,6 +11573,21 @@ def test_promotion_codes_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_promotion_codes_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.PromotionCode.modify_async( + "promo_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/promotion_codes/promo_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_promotion_codes_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8382,6 +11622,17 @@ def test_quotes_accept_post( query_string="", ) + @pytest.mark.anyio + async def test_quotes_accept_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.accept_async("qt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/quotes/qt_xxxxxxxxxxxxx/accept", + query_string="", + ) + def test_quotes_accept_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8412,6 +11663,17 @@ def test_quotes_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_quotes_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.cancel_async("qt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/quotes/qt_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_quotes_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8442,6 +11704,17 @@ def test_quotes_finalize_post( query_string="", ) + @pytest.mark.anyio + async def test_quotes_finalize_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.finalize_quote_async("qt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/quotes/qt_xxxxxxxxxxxxx/finalize", + query_string="", + ) + def test_quotes_finalize_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8470,6 +11743,17 @@ def test_quotes_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_quotes_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/quotes", + query_string="limit=3", + ) + def test_quotes_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8499,6 +11783,17 @@ def test_quotes_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_quotes_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.retrieve_async("qt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/quotes/qt_xxxxxxxxxxxxx", + query_string="", + ) + def test_quotes_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8529,6 +11824,17 @@ def test_quotes_line_items_get( query_string="", ) + @pytest.mark.anyio + async def test_quotes_line_items_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.list_line_items_async("qt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/quotes/qt_xxxxxxxxxxxxx/line_items", + query_string="", + ) + def test_quotes_line_items_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8591,6 +11897,21 @@ def test_quotes_post(self, http_client_mock: HTTPClientMock) -> None: post_data="customer=cus_xxxxxxxxxxxxx&line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=2", ) + @pytest.mark.anyio + async def test_quotes_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.create_async( + customer="cus_xxxxxxxxxxxxx", + line_items=[{"price": "price_xxxxxxxxxxxxx", "quantity": 2}], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/quotes", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx&line_items[0][price]=price_xxxxxxxxxxxxx&line_items[0][quantity]=2", + ) + def test_quotes_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8631,6 +11952,21 @@ def test_quotes_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_quotes_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.modify_async( + "qt_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/quotes/qt_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_quotes_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8668,6 +12004,20 @@ def test_quotes_preview_invoices_lines_get( query_string="", ) + @pytest.mark.anyio + async def test_quotes_preview_invoices_lines_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Quote.list_preview_invoice_lines_async( + "qt_xyz", + "in_xyz", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/quotes/qt_xyz/preview_invoices/in_xyz/lines", + query_string="", + ) + def test_quotes_preview_invoices_lines_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8701,6 +12051,17 @@ def test_radar_early_fraud_warnings_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_radar_early_fraud_warnings_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.EarlyFraudWarning.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/radar/early_fraud_warnings", + query_string="limit=3", + ) + def test_radar_early_fraud_warnings_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8732,6 +12093,19 @@ def test_radar_early_fraud_warnings_get_2( query_string="", ) + @pytest.mark.anyio + async def test_radar_early_fraud_warnings_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.EarlyFraudWarning.retrieve_async( + "issfr_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/radar/early_fraud_warnings/issfr_xxxxxxxxxxxxx", + query_string="", + ) + def test_radar_early_fraud_warnings_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8762,6 +12136,17 @@ def test_radar_value_list_items_delete( query_string="", ) + @pytest.mark.anyio + async def test_radar_value_list_items_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueListItem.delete_async("rsli_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/radar/value_list_items/rsli_xxxxxxxxxxxxx", + query_string="", + ) + def test_radar_value_list_items_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8795,6 +12180,20 @@ def test_radar_value_list_items_get( query_string="limit=3&value_list=rsl_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_radar_value_list_items_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueListItem.list_async( + limit=3, + value_list="rsl_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/radar/value_list_items", + query_string="limit=3&value_list=rsl_xxxxxxxxxxxxx", + ) + def test_radar_value_list_items_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8831,6 +12230,17 @@ def test_radar_value_list_items_get_2( query_string="", ) + @pytest.mark.anyio + async def test_radar_value_list_items_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueListItem.retrieve_async("rsli_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/radar/value_list_items/rsli_xxxxxxxxxxxxx", + query_string="", + ) + def test_radar_value_list_items_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8865,6 +12275,21 @@ def test_radar_value_list_items_post( post_data="value_list=rsl_xxxxxxxxxxxxx&value=1.2.3.4", ) + @pytest.mark.anyio + async def test_radar_value_list_items_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueListItem.create_async( + value_list="rsl_xxxxxxxxxxxxx", + value="1.2.3.4", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/radar/value_list_items", + query_string="", + post_data="value_list=rsl_xxxxxxxxxxxxx&value=1.2.3.4", + ) + def test_radar_value_list_items_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8901,6 +12326,17 @@ def test_radar_value_lists_delete( query_string="", ) + @pytest.mark.anyio + async def test_radar_value_lists_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueList.delete_async("rsl_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/radar/value_lists/rsl_xxxxxxxxxxxxx", + query_string="", + ) + def test_radar_value_lists_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8931,6 +12367,17 @@ def test_radar_value_lists_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_radar_value_lists_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueList.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/radar/value_lists", + query_string="limit=3", + ) + def test_radar_value_lists_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8962,6 +12409,17 @@ def test_radar_value_lists_get_2( query_string="", ) + @pytest.mark.anyio + async def test_radar_value_lists_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueList.retrieve_async("rsl_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/radar/value_lists/rsl_xxxxxxxxxxxxx", + query_string="", + ) + def test_radar_value_lists_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -8997,6 +12455,22 @@ def test_radar_value_lists_post( post_data="alias=custom_ip_xxxxxxxxxxxxx&name=Custom%20IP%20Blocklist&item_type=ip_address", ) + @pytest.mark.anyio + async def test_radar_value_lists_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueList.create_async( + alias="custom_ip_xxxxxxxxxxxxx", + name="Custom IP Blocklist", + item_type="ip_address", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/radar/value_lists", + query_string="", + post_data="alias=custom_ip_xxxxxxxxxxxxx&name=Custom%20IP%20Blocklist&item_type=ip_address", + ) + def test_radar_value_lists_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9038,6 +12512,21 @@ def test_radar_value_lists_post_2( post_data="name=Updated%20IP%20Block%20List", ) + @pytest.mark.anyio + async def test_radar_value_lists_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.radar.ValueList.modify_async( + "rsl_xxxxxxxxxxxxx", + name="Updated IP Block List", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/radar/value_lists/rsl_xxxxxxxxxxxxx", + query_string="", + post_data="name=Updated%20IP%20Block%20List", + ) + def test_radar_value_lists_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9072,6 +12561,17 @@ def test_refunds_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_refunds_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Refund.cancel_async("re_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/refunds/re_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_refunds_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9100,6 +12600,17 @@ def test_refunds_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_refunds_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Refund.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/refunds", + query_string="limit=3", + ) + def test_refunds_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9129,6 +12640,17 @@ def test_refunds_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_refunds_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Refund.retrieve_async("re_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/refunds/re_xxxxxxxxxxxxx", + query_string="", + ) + def test_refunds_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9158,6 +12680,18 @@ def test_refunds_post(self, http_client_mock: HTTPClientMock) -> None: post_data="charge=ch_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_refunds_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Refund.create_async(charge="ch_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/refunds", + query_string="", + post_data="charge=ch_xxxxxxxxxxxxx", + ) + def test_refunds_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9191,6 +12725,21 @@ def test_refunds_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_refunds_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Refund.modify_async( + "re_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/refunds/re_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_refunds_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9225,6 +12774,17 @@ def test_reporting_report_runs_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_reporting_report_runs_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.reporting.ReportRun.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/reporting/report_runs", + query_string="limit=3", + ) + def test_reporting_report_runs_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9256,6 +12816,17 @@ def test_reporting_report_runs_get_2( query_string="", ) + @pytest.mark.anyio + async def test_reporting_report_runs_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.reporting.ReportRun.retrieve_async("frr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/reporting/report_runs/frr_xxxxxxxxxxxxx", + query_string="", + ) + def test_reporting_report_runs_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9293,6 +12864,24 @@ def test_reporting_report_runs_post( post_data="report_type=balance.summary.1¶meters[interval_start]=1522540800¶meters[interval_end]=1525132800", ) + @pytest.mark.anyio + async def test_reporting_report_runs_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.reporting.ReportRun.create_async( + report_type="balance.summary.1", + parameters={ + "interval_start": 1522540800, + "interval_end": 1525132800, + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/reporting/report_runs", + query_string="", + post_data="report_type=balance.summary.1¶meters[interval_start]=1522540800¶meters[interval_end]=1525132800", + ) + def test_reporting_report_runs_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9332,6 +12921,17 @@ def test_reporting_report_types_get( query_string="", ) + @pytest.mark.anyio + async def test_reporting_report_types_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.reporting.ReportType.list_async() + http_client_mock_async.assert_requested( + "get", + path="/v1/reporting/report_types", + query_string="", + ) + def test_reporting_report_types_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9362,6 +12962,17 @@ def test_reporting_report_types_get_2( query_string="", ) + @pytest.mark.anyio + async def test_reporting_report_types_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.reporting.ReportType.retrieve_async("balance.summary.1") + http_client_mock_async.assert_requested( + "get", + path="/v1/reporting/report_types/balance.summary.1", + query_string="", + ) + def test_reporting_report_types_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9392,6 +13003,17 @@ def test_reviews_approve_post( query_string="", ) + @pytest.mark.anyio + async def test_reviews_approve_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Review.approve_async("prv_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/reviews/prv_xxxxxxxxxxxxx/approve", + query_string="", + ) + def test_reviews_approve_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9420,12 +13042,23 @@ def test_reviews_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) - def test_reviews_get_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_reviews_get_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.Review.list_async(limit=3) + http_client_mock_async.assert_requested( "get", - "/v1/reviews", + path="/v1/reviews", + query_string="limit=3", + ) + + def test_reviews_get_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( + "get", + "/v1/reviews", "limit=3", ) client = StripeClient( @@ -9449,6 +13082,17 @@ def test_reviews_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_reviews_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Review.retrieve_async("prv_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/reviews/prv_xxxxxxxxxxxxx", + query_string="", + ) + def test_reviews_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9482,6 +13126,20 @@ def test_setup_attempts_get( query_string="limit=3&setup_intent=si_xyz", ) + @pytest.mark.anyio + async def test_setup_attempts_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupAttempt.list_async( + limit=3, + setup_intent="si_xyz", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/setup_attempts", + query_string="limit=3&setup_intent=si_xyz", + ) + def test_setup_attempts_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9513,6 +13171,17 @@ def test_setup_intents_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_setup_intents_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.cancel_async("seti_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/setup_intents/seti_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_setup_intents_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9547,6 +13216,21 @@ def test_setup_intents_confirm_post( post_data="payment_method=pm_card_visa", ) + @pytest.mark.anyio + async def test_setup_intents_confirm_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.confirm_async( + "seti_xxxxxxxxxxxxx", + payment_method="pm_card_visa", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/setup_intents/seti_xxxxxxxxxxxxx/confirm", + query_string="", + post_data="payment_method=pm_card_visa", + ) + def test_setup_intents_confirm_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9579,6 +13263,17 @@ def test_setup_intents_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_setup_intents_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/setup_intents", + query_string="limit=3", + ) + def test_setup_intents_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9610,6 +13305,17 @@ def test_setup_intents_get_2( query_string="", ) + @pytest.mark.anyio + async def test_setup_intents_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.retrieve_async("seti_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/setup_intents/seti_xxxxxxxxxxxxx", + query_string="", + ) + def test_setup_intents_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9641,6 +13347,18 @@ def test_setup_intents_post( post_data="payment_method_types[0]=card", ) + @pytest.mark.anyio + async def test_setup_intents_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.create_async(payment_method_types=["card"]) + http_client_mock_async.assert_requested( + "post", + path="/v1/setup_intents", + query_string="", + post_data="payment_method_types[0]=card", + ) + def test_setup_intents_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9676,6 +13394,21 @@ def test_setup_intents_post_2( post_data="metadata[user_id]=3435453", ) + @pytest.mark.anyio + async def test_setup_intents_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.modify_async( + "seti_xxxxxxxxxxxxx", + metadata={"user_id": "3435453"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/setup_intents/seti_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[user_id]=3435453", + ) + def test_setup_intents_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9710,6 +13443,19 @@ def test_setup_intents_verify_microdeposits_post( query_string="", ) + @pytest.mark.anyio + async def test_setup_intents_verify_microdeposits_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.verify_microdeposits_async( + "seti_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits", + query_string="", + ) + def test_setup_intents_verify_microdeposits_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9744,6 +13490,21 @@ def test_setup_intents_verify_microdeposits_post_2( post_data="amounts[0]=32&amounts[1]=45", ) + @pytest.mark.anyio + async def test_setup_intents_verify_microdeposits_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SetupIntent.verify_microdeposits_async( + "seti_xxxxxxxxxxxxx", + amounts=[32, 45], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits", + query_string="", + post_data="amounts[0]=32&amounts[1]=45", + ) + def test_setup_intents_verify_microdeposits_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9778,6 +13539,17 @@ def test_shipping_rates_get( query_string="", ) + @pytest.mark.anyio + async def test_shipping_rates_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ShippingRate.list_async() + http_client_mock_async.assert_requested( + "get", + path="/v1/shipping_rates", + query_string="", + ) + def test_shipping_rates_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9808,6 +13580,17 @@ def test_shipping_rates_get_2( query_string="limit=3", ) + @pytest.mark.anyio + async def test_shipping_rates_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ShippingRate.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/shipping_rates", + query_string="limit=3", + ) + def test_shipping_rates_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9839,6 +13622,17 @@ def test_shipping_rates_get_3( query_string="", ) + @pytest.mark.anyio + async def test_shipping_rates_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ShippingRate.retrieve_async("shr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/shipping_rates/shr_xxxxxxxxxxxxx", + query_string="", + ) + def test_shipping_rates_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9874,6 +13668,22 @@ def test_shipping_rates_post( post_data="display_name=Sample%20Shipper&fixed_amount[currency]=usd&fixed_amount[amount]=400&type=fixed_amount", ) + @pytest.mark.anyio + async def test_shipping_rates_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ShippingRate.create_async( + display_name="Sample Shipper", + fixed_amount={"currency": "usd", "amount": 400}, + type="fixed_amount", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/shipping_rates", + query_string="", + post_data="display_name=Sample%20Shipper&fixed_amount[currency]=usd&fixed_amount[amount]=400&type=fixed_amount", + ) + def test_shipping_rates_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9916,6 +13726,22 @@ def test_shipping_rates_post_2( post_data="display_name=Ground%20shipping&type=fixed_amount&fixed_amount[amount]=500&fixed_amount[currency]=usd", ) + @pytest.mark.anyio + async def test_shipping_rates_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ShippingRate.create_async( + display_name="Ground shipping", + type="fixed_amount", + fixed_amount={"amount": 500, "currency": "usd"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/shipping_rates", + query_string="", + post_data="display_name=Ground%20shipping&type=fixed_amount&fixed_amount[amount]=500&fixed_amount[currency]=usd", + ) + def test_shipping_rates_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9957,6 +13783,21 @@ def test_shipping_rates_post_3( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_shipping_rates_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.ShippingRate.modify_async( + "shr_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/shipping_rates/shr_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_shipping_rates_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -9991,6 +13832,17 @@ def test_sigma_scheduled_query_runs_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_sigma_scheduled_query_runs_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.sigma.ScheduledQueryRun.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/sigma/scheduled_query_runs", + query_string="limit=3", + ) + def test_sigma_scheduled_query_runs_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10022,6 +13874,19 @@ def test_sigma_scheduled_query_runs_get_2( query_string="", ) + @pytest.mark.anyio + async def test_sigma_scheduled_query_runs_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.sigma.ScheduledQueryRun.retrieve_async( + "sqr_xxxxxxxxxxxxx" + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/sigma/scheduled_query_runs/sqr_xxxxxxxxxxxxx", + query_string="", + ) + def test_sigma_scheduled_query_runs_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10050,6 +13915,17 @@ def test_sources_get(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_sources_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Source.retrieve_async("src_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/sources/src_xxxxxxxxxxxxx", + query_string="", + ) + def test_sources_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10078,6 +13954,17 @@ def test_sources_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_sources_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Source.retrieve_async("src_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/sources/src_xxxxxxxxxxxxx", + query_string="", + ) + def test_sources_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10110,6 +13997,21 @@ def test_sources_post(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_sources_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Source.modify_async( + "src_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/sources/src_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_sources_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10144,6 +14046,17 @@ def test_subscription_items_delete( query_string="", ) + @pytest.mark.anyio + async def test_subscription_items_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.delete_async("si_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/subscription_items/si_xxxxxxxxxxxxx", + query_string="", + ) + def test_subscription_items_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10174,6 +14087,19 @@ def test_subscription_items_get( query_string="subscription=sub_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_subscription_items_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.list_async( + subscription="sub_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/subscription_items", + query_string="subscription=sub_xxxxxxxxxxxxx", + ) + def test_subscription_items_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10205,6 +14131,17 @@ def test_subscription_items_get_2( query_string="", ) + @pytest.mark.anyio + async def test_subscription_items_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.retrieve_async("si_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/subscription_items/si_xxxxxxxxxxxxx", + query_string="", + ) + def test_subscription_items_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10240,6 +14177,22 @@ def test_subscription_items_post( post_data="subscription=sub_xxxxxxxxxxxxx&price=price_xxxxxxxxxxxxx&quantity=2", ) + @pytest.mark.anyio + async def test_subscription_items_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.create_async( + subscription="sub_xxxxxxxxxxxxx", + price="price_xxxxxxxxxxxxx", + quantity=2, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_items", + query_string="", + post_data="subscription=sub_xxxxxxxxxxxxx&price=price_xxxxxxxxxxxxx&quantity=2", + ) + def test_subscription_items_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10281,6 +14234,21 @@ def test_subscription_items_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_subscription_items_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.modify_async( + "si_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_items/si_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_subscription_items_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10318,6 +14286,20 @@ def test_subscription_items_usage_record_summaries_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_subscription_items_usage_record_summaries_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.list_usage_record_summaries_async( + "si_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/subscription_items/si_xxxxxxxxxxxxx/usage_record_summaries", + query_string="limit=3", + ) + def test_subscription_items_usage_record_summaries_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10357,6 +14339,22 @@ def test_subscription_items_usage_records_post( post_data="quantity=100×tamp=1571252444", ) + @pytest.mark.anyio + async def test_subscription_items_usage_records_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionItem.create_usage_record_async( + "si_xxxxxxxxxxxxx", + quantity=100, + timestamp=1571252444, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_items/si_xxxxxxxxxxxxx/usage_records", + query_string="", + post_data="quantity=100×tamp=1571252444", + ) + def test_subscription_items_usage_records_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10391,6 +14389,19 @@ def test_subscription_schedules_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_subscription_schedules_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionSchedule.cancel_async( + "sub_sched_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_schedules/sub_sched_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_subscription_schedules_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10421,6 +14432,17 @@ def test_subscription_schedules_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_subscription_schedules_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionSchedule.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/subscription_schedules", + query_string="limit=3", + ) + def test_subscription_schedules_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10452,6 +14474,19 @@ def test_subscription_schedules_get_2( query_string="", ) + @pytest.mark.anyio + async def test_subscription_schedules_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionSchedule.retrieve_async( + "sub_sched_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/subscription_schedules/sub_sched_xxxxxxxxxxxxx", + query_string="", + ) + def test_subscription_schedules_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10493,6 +14528,28 @@ def test_subscription_schedules_post( post_data="customer=cus_xxxxxxxxxxxxx&start_date=1676070661&end_behavior=release&phases[0][items][0][price]=price_xxxxxxxxxxxxx&phases[0][items][0][quantity]=1&phases[0][iterations]=12", ) + @pytest.mark.anyio + async def test_subscription_schedules_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionSchedule.create_async( + customer="cus_xxxxxxxxxxxxx", + start_date=1676070661, + end_behavior="release", + phases=[ + { + "items": [{"price": "price_xxxxxxxxxxxxx", "quantity": 1}], + "iterations": 12, + }, + ], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_schedules", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx&start_date=1676070661&end_behavior=release&phases[0][items][0][price]=price_xxxxxxxxxxxxx&phases[0][items][0][quantity]=1&phases[0][iterations]=12", + ) + def test_subscription_schedules_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10542,6 +14599,21 @@ def test_subscription_schedules_post_2( post_data="end_behavior=release", ) + @pytest.mark.anyio + async def test_subscription_schedules_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionSchedule.modify_async( + "sub_sched_xxxxxxxxxxxxx", + end_behavior="release", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_schedules/sub_sched_xxxxxxxxxxxxx", + query_string="", + post_data="end_behavior=release", + ) + def test_subscription_schedules_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10576,6 +14648,19 @@ def test_subscription_schedules_release_post( query_string="", ) + @pytest.mark.anyio + async def test_subscription_schedules_release_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.SubscriptionSchedule.release_async( + "sub_sched_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscription_schedules/sub_sched_xxxxxxxxxxxxx/release", + query_string="", + ) + def test_subscription_schedules_release_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10606,6 +14691,17 @@ def test_subscriptions_delete( query_string="", ) + @pytest.mark.anyio + async def test_subscriptions_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.cancel_async("sub_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/subscriptions/sub_xxxxxxxxxxxxx", + query_string="", + ) + def test_subscriptions_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10636,6 +14732,17 @@ def test_subscriptions_discount_delete( query_string="", ) + @pytest.mark.anyio + async def test_subscriptions_discount_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.delete_discount_async("sub_xyz") + http_client_mock_async.assert_requested( + "delete", + path="/v1/subscriptions/sub_xyz/discount", + query_string="", + ) + def test_subscriptions_discount_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10664,6 +14771,17 @@ def test_subscriptions_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_subscriptions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/subscriptions", + query_string="limit=3", + ) + def test_subscriptions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10695,6 +14813,17 @@ def test_subscriptions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_subscriptions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.retrieve_async("sub_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/subscriptions/sub_xxxxxxxxxxxxx", + query_string="", + ) + def test_subscriptions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10729,6 +14858,21 @@ def test_subscriptions_post( post_data="customer=cus_xxxxxxxxxxxxx&items[0][price]=price_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_subscriptions_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.create_async( + customer="cus_xxxxxxxxxxxxx", + items=[{"price": "price_xxxxxxxxxxxxx"}], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscriptions", + query_string="", + post_data="customer=cus_xxxxxxxxxxxxx&items[0][price]=price_xxxxxxxxxxxxx", + ) + def test_subscriptions_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10769,6 +14913,21 @@ def test_subscriptions_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_subscriptions_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.modify_async( + "sub_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/subscriptions/sub_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_subscriptions_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10805,6 +14964,19 @@ def test_subscriptions_search_get( query_string="query=status%3A%27active%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", ) + @pytest.mark.anyio + async def test_subscriptions_search_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Subscription.search_async( + query="status:'active' AND metadata['order_id']:'6735'", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/subscriptions/search", + query_string="query=status%3A%27active%27%20AND%20metadata%5B%27order_id%27%5D%3A%276735%27", + ) + def test_subscriptions_search_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10840,6 +15012,17 @@ def test_tax_calculations_line_items_get( query_string="", ) + @pytest.mark.anyio + async def test_tax_calculations_line_items_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Calculation.list_line_items_async("xxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/tax/calculations/xxx/line_items", + query_string="", + ) + def test_tax_calculations_line_items_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10884,6 +15067,31 @@ def test_tax_calculations_post( post_data="currency=usd&line_items[0][amount]=1000&line_items[0][reference]=L1&customer_details[address][line1]=354%20Oyster%20Point%20Blvd&customer_details[address][city]=South%20San%20Francisco&customer_details[address][state]=CA&customer_details[address][postal_code]=94080&customer_details[address][country]=US&customer_details[address_source]=shipping", ) + @pytest.mark.anyio + async def test_tax_calculations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Calculation.create_async( + currency="usd", + line_items=[{"amount": 1000, "reference": "L1"}], + customer_details={ + "address": { + "line1": "354 Oyster Point Blvd", + "city": "South San Francisco", + "state": "CA", + "postal_code": "94080", + "country": "US", + }, + "address_source": "shipping", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax/calculations", + query_string="", + post_data="currency=usd&line_items[0][amount]=1000&line_items[0][reference]=L1&customer_details[address][line1]=354%20Oyster%20Point%20Blvd&customer_details[address][city]=South%20San%20Francisco&customer_details[address][state]=CA&customer_details[address][postal_code]=94080&customer_details[address][country]=US&customer_details[address_source]=shipping", + ) + def test_tax_calculations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10928,6 +15136,17 @@ def test_tax_codes_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_tax_codes_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.TaxCode.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/tax_codes", + query_string="limit=3", + ) + def test_tax_codes_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -10957,6 +15176,17 @@ def test_tax_codes_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_tax_codes_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.TaxCode.retrieve_async("txcd_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/tax_codes/txcd_xxxxxxxxxxxxx", + query_string="", + ) + def test_tax_codes_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11015,6 +15245,17 @@ def test_tax_rates_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_tax_rates_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.TaxRate.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/tax_rates", + query_string="limit=3", + ) + def test_tax_rates_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11044,6 +15285,17 @@ def test_tax_rates_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_tax_rates_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.TaxRate.retrieve_async("txr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/tax_rates/txr_xxxxxxxxxxxxx", + query_string="", + ) + def test_tax_rates_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11079,6 +15331,24 @@ def test_tax_rates_post(self, http_client_mock: HTTPClientMock) -> None: post_data="display_name=VAT&description=VAT%20Germany&jurisdiction=DE&percentage=16&inclusive=False", ) + @pytest.mark.anyio + async def test_tax_rates_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.TaxRate.create_async( + display_name="VAT", + description="VAT Germany", + jurisdiction="DE", + percentage=16, + inclusive=False, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax_rates", + query_string="", + post_data="display_name=VAT&description=VAT%20Germany&jurisdiction=DE&percentage=16&inclusive=False", + ) + def test_tax_rates_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11120,6 +15390,21 @@ def test_tax_rates_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="active=False", ) + @pytest.mark.anyio + async def test_tax_rates_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.TaxRate.modify_async( + "txr_xxxxxxxxxxxxx", + active=False, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax_rates/txr_xxxxxxxxxxxxx", + query_string="", + post_data="active=False", + ) + def test_tax_rates_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11154,6 +15439,17 @@ def test_tax_registrations_get( query_string="status=all", ) + @pytest.mark.anyio + async def test_tax_registrations_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Registration.list_async(status="all") + http_client_mock_async.assert_requested( + "get", + path="/v1/tax/registrations", + query_string="status=all", + ) + def test_tax_registrations_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11190,6 +15486,22 @@ def test_tax_registrations_post( post_data="country=IE&country_options[ie][type]=oss_union&active_from=now", ) + @pytest.mark.anyio + async def test_tax_registrations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Registration.create_async( + country="IE", + country_options={"ie": {"type": "oss_union"}}, + active_from="now", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax/registrations", + query_string="", + post_data="country=IE&country_options[ie][type]=oss_union&active_from=now", + ) + def test_tax_registrations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11231,6 +15543,21 @@ def test_tax_registrations_post_2( post_data="expires_at=now", ) + @pytest.mark.anyio + async def test_tax_registrations_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Registration.modify_async( + "taxreg_xxxxxxxxxxxxx", + expires_at="now", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax/registrations/taxreg_xxxxxxxxxxxxx", + query_string="", + post_data="expires_at=now", + ) + def test_tax_registrations_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11263,6 +15590,17 @@ def test_tax_settings_get(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_tax_settings_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Settings.retrieve_async() + http_client_mock_async.assert_requested( + "get", + path="/v1/tax/settings", + query_string="", + ) + def test_tax_settings_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11292,6 +15630,20 @@ def test_tax_settings_post(self, http_client_mock: HTTPClientMock) -> None: post_data="defaults[tax_code]=txcd_10000000", ) + @pytest.mark.anyio + async def test_tax_settings_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Settings.modify_async( + defaults={"tax_code": "txcd_10000000"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax/settings", + query_string="", + post_data="defaults[tax_code]=txcd_10000000", + ) + def test_tax_settings_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11327,6 +15679,21 @@ def test_tax_transactions_create_from_calculation_post( post_data="calculation=xxx&reference=yyy", ) + @pytest.mark.anyio + async def test_tax_transactions_create_from_calculation_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.tax.Transaction.create_from_calculation_async( + calculation="xxx", + reference="yyy", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tax/transactions/create_from_calculation", + query_string="", + post_data="calculation=xxx&reference=yyy", + ) + def test_tax_transactions_create_from_calculation_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11363,6 +15730,17 @@ def test_terminal_configurations_delete( query_string="", ) + @pytest.mark.anyio + async def test_terminal_configurations_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.delete_async("uc_123") + http_client_mock_async.assert_requested( + "delete", + path="/v1/terminal/configurations/uc_123", + query_string="", + ) + def test_terminal_configurations_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11393,6 +15771,17 @@ def test_terminal_configurations_delete_2( query_string="", ) + @pytest.mark.anyio + async def test_terminal_configurations_delete_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.delete_async("tmc_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/terminal/configurations/tmc_xxxxxxxxxxxxx", + query_string="", + ) + def test_terminal_configurations_delete_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11423,6 +15812,17 @@ def test_terminal_configurations_get( query_string="", ) + @pytest.mark.anyio + async def test_terminal_configurations_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.list_async() + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/configurations", + query_string="", + ) + def test_terminal_configurations_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11453,6 +15853,17 @@ def test_terminal_configurations_get_2( query_string="", ) + @pytest.mark.anyio + async def test_terminal_configurations_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.retrieve_async("uc_123") + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/configurations/uc_123", + query_string="", + ) + def test_terminal_configurations_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11483,6 +15894,17 @@ def test_terminal_configurations_get_3( query_string="limit=3", ) + @pytest.mark.anyio + async def test_terminal_configurations_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/configurations", + query_string="limit=3", + ) + def test_terminal_configurations_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11514,6 +15936,17 @@ def test_terminal_configurations_get_4( query_string="", ) + @pytest.mark.anyio + async def test_terminal_configurations_get_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.retrieve_async("tmc_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/configurations/tmc_xxxxxxxxxxxxx", + query_string="", + ) + def test_terminal_configurations_get_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11544,6 +15977,17 @@ def test_terminal_configurations_post( query_string="", ) + @pytest.mark.anyio + async def test_terminal_configurations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.create_async() + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/configurations", + query_string="", + ) + def test_terminal_configurations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11578,10 +16022,25 @@ def test_terminal_configurations_post_2( post_data="tipping[usd][fixed_amounts][0]=10", ) - def test_terminal_configurations_post_2_service( - self, http_client_mock: HTTPClientMock + @pytest.mark.anyio + async def test_terminal_configurations_post_2_async( + self, http_client_mock_async: HTTPClientMock ) -> None: - http_client_mock.stub_request( + await stripe.terminal.Configuration.modify_async( + "uc_123", + tipping={"usd": {"fixed_amounts": [10]}}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/configurations/uc_123", + query_string="", + post_data="tipping[usd][fixed_amounts][0]=10", + ) + + def test_terminal_configurations_post_2_service( + self, http_client_mock: HTTPClientMock + ) -> None: + http_client_mock.stub_request( "post", "/v1/terminal/configurations/uc_123", ) @@ -11615,6 +16074,20 @@ def test_terminal_configurations_post_3( post_data="bbpos_wisepos_e[splashscreen]=file_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_terminal_configurations_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.create_async( + bbpos_wisepos_e={"splashscreen": "file_xxxxxxxxxxxxx"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/configurations", + query_string="", + post_data="bbpos_wisepos_e[splashscreen]=file_xxxxxxxxxxxxx", + ) + def test_terminal_configurations_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11654,6 +16127,21 @@ def test_terminal_configurations_post_4( post_data="bbpos_wisepos_e[splashscreen]=file_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_terminal_configurations_post_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Configuration.modify_async( + "tmc_xxxxxxxxxxxxx", + bbpos_wisepos_e={"splashscreen": "file_xxxxxxxxxxxxx"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/configurations/tmc_xxxxxxxxxxxxx", + query_string="", + post_data="bbpos_wisepos_e[splashscreen]=file_xxxxxxxxxxxxx", + ) + def test_terminal_configurations_post_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11688,6 +16176,17 @@ def test_terminal_connection_tokens_post( query_string="", ) + @pytest.mark.anyio + async def test_terminal_connection_tokens_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.ConnectionToken.create_async() + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/connection_tokens", + query_string="", + ) + def test_terminal_connection_tokens_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11718,6 +16217,17 @@ def test_terminal_locations_delete( query_string="", ) + @pytest.mark.anyio + async def test_terminal_locations_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Location.delete_async("tml_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/terminal/locations/tml_xxxxxxxxxxxxx", + query_string="", + ) + def test_terminal_locations_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11748,6 +16258,17 @@ def test_terminal_locations_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_terminal_locations_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Location.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/locations", + query_string="limit=3", + ) + def test_terminal_locations_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11779,6 +16300,17 @@ def test_terminal_locations_get_2( query_string="", ) + @pytest.mark.anyio + async def test_terminal_locations_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Location.retrieve_async("tml_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/locations/tml_xxxxxxxxxxxxx", + query_string="", + ) + def test_terminal_locations_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11819,6 +16351,27 @@ def test_terminal_locations_post( post_data="display_name=My%20First%20Store&address[line1]=1234%20Main%20Street&address[city]=San%20Francisco&address[postal_code]=94111&address[state]=CA&address[country]=US", ) + @pytest.mark.anyio + async def test_terminal_locations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Location.create_async( + display_name="My First Store", + address={ + "line1": "1234 Main Street", + "city": "San Francisco", + "postal_code": "94111", + "state": "CA", + "country": "US", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/locations", + query_string="", + post_data="display_name=My%20First%20Store&address[line1]=1234%20Main%20Street&address[city]=San%20Francisco&address[postal_code]=94111&address[state]=CA&address[country]=US", + ) + def test_terminal_locations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11865,6 +16418,21 @@ def test_terminal_locations_post_2( post_data="display_name=My%20First%20Store", ) + @pytest.mark.anyio + async def test_terminal_locations_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Location.modify_async( + "tml_xxxxxxxxxxxxx", + display_name="My First Store", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/locations/tml_xxxxxxxxxxxxx", + query_string="", + post_data="display_name=My%20First%20Store", + ) + def test_terminal_locations_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11899,6 +16467,17 @@ def test_terminal_readers_cancel_action_post( query_string="", ) + @pytest.mark.anyio + async def test_terminal_readers_cancel_action_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.cancel_action_async("tmr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx/cancel_action", + query_string="", + ) + def test_terminal_readers_cancel_action_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11929,6 +16508,17 @@ def test_terminal_readers_delete( query_string="", ) + @pytest.mark.anyio + async def test_terminal_readers_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.delete_async("tmr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx", + query_string="", + ) + def test_terminal_readers_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11959,6 +16549,17 @@ def test_terminal_readers_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_terminal_readers_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/readers", + query_string="limit=3", + ) + def test_terminal_readers_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -11990,6 +16591,17 @@ def test_terminal_readers_get_2( query_string="", ) + @pytest.mark.anyio + async def test_terminal_readers_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.retrieve_async("tmr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx", + query_string="", + ) + def test_terminal_readers_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12025,6 +16637,22 @@ def test_terminal_readers_post( post_data="registration_code=puppies-plug-could&label=Blue%20Rabbit&location=tml_1234", ) + @pytest.mark.anyio + async def test_terminal_readers_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.create_async( + registration_code="puppies-plug-could", + label="Blue Rabbit", + location="tml_1234", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/readers", + query_string="", + post_data="registration_code=puppies-plug-could&label=Blue%20Rabbit&location=tml_1234", + ) + def test_terminal_readers_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12066,6 +16694,21 @@ def test_terminal_readers_post_2( post_data="label=Blue%20Rabbit", ) + @pytest.mark.anyio + async def test_terminal_readers_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.modify_async( + "tmr_xxxxxxxxxxxxx", + label="Blue Rabbit", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx", + query_string="", + post_data="label=Blue%20Rabbit", + ) + def test_terminal_readers_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12104,6 +16747,21 @@ def test_terminal_readers_process_payment_intent_post( post_data="payment_intent=pi_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_terminal_readers_process_payment_intent_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.process_payment_intent_async( + "tmr_xxxxxxxxxxxxx", + payment_intent="pi_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_payment_intent", + query_string="", + post_data="payment_intent=pi_xxxxxxxxxxxxx", + ) + def test_terminal_readers_process_payment_intent_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12143,6 +16801,22 @@ def test_terminal_readers_process_setup_intent_post( 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_async: HTTPClientMock + ) -> None: + await stripe.terminal.Reader.process_setup_intent_async( + "tmr_xxxxxxxxxxxxx", + setup_intent="seti_xxxxxxxxxxxxx", + customer_consent_collected=True, + ) + http_client_mock_async.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: @@ -12185,6 +16859,22 @@ def test_test_helpers_customers_fund_cash_balance_post( post_data="amount=30¤cy=eur", ) + @pytest.mark.anyio + async def test_test_helpers_customers_fund_cash_balance_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Customer.TestHelpers.fund_cash_balance_async( + "cus_123", + amount=30, + currency="eur", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/customers/cus_123/fund_cash_balance", + query_string="", + post_data="amount=30¤cy=eur", + ) + def test_test_helpers_customers_fund_cash_balance_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12258,6 +16948,56 @@ def test_test_helpers_issuing_authorizations_capture_post( post_data="capture_amount=100&close_authorization=True&purchase_details[flight][departure_at]=1633651200&purchase_details[flight][passenger_name]=John%20Doe&purchase_details[flight][refundable]=True&purchase_details[flight][segments][0][arrival_airport_code]=SFO&purchase_details[flight][segments][0][carrier]=Delta&purchase_details[flight][segments][0][departure_airport_code]=LAX&purchase_details[flight][segments][0][flight_number]=DL100&purchase_details[flight][segments][0][service_class]=Economy&purchase_details[flight][segments][0][stopover_allowed]=True&purchase_details[flight][travel_agency]=Orbitz&purchase_details[fuel][type]=diesel&purchase_details[fuel][unit]=liter&purchase_details[fuel][unit_cost_decimal]=3.5&purchase_details[fuel][volume_decimal]=10&purchase_details[lodging][check_in_at]=1633651200&purchase_details[lodging][nights]=2&purchase_details[receipt][0][description]=Room%20charge&purchase_details[receipt][0][quantity]=1&purchase_details[receipt][0][total]=200&purchase_details[receipt][0][unit_cost]=200&purchase_details[reference]=foo", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_authorizations_capture_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.TestHelpers.capture_async( + "example_authorization", + capture_amount=100, + close_authorization=True, + purchase_details={ + "flight": { + "departure_at": 1633651200, + "passenger_name": "John Doe", + "refundable": True, + "segments": [ + { + "arrival_airport_code": "SFO", + "carrier": "Delta", + "departure_airport_code": "LAX", + "flight_number": "DL100", + "service_class": "Economy", + "stopover_allowed": True, + }, + ], + "travel_agency": "Orbitz", + }, + "fuel": { + "type": "diesel", + "unit": "liter", + "unit_cost_decimal": "3.5", + "volume_decimal": "10", + }, + "lodging": {"check_in_at": 1633651200, "nights": 2}, + "receipt": [ + { + "description": "Room charge", + "quantity": "1", + "total": 200, + "unit_cost": 200, + }, + ], + "reference": "foo", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/authorizations/example_authorization/capture", + query_string="", + post_data="capture_amount=100&close_authorization=True&purchase_details[flight][departure_at]=1633651200&purchase_details[flight][passenger_name]=John%20Doe&purchase_details[flight][refundable]=True&purchase_details[flight][segments][0][arrival_airport_code]=SFO&purchase_details[flight][segments][0][carrier]=Delta&purchase_details[flight][segments][0][departure_airport_code]=LAX&purchase_details[flight][segments][0][flight_number]=DL100&purchase_details[flight][segments][0][service_class]=Economy&purchase_details[flight][segments][0][stopover_allowed]=True&purchase_details[flight][travel_agency]=Orbitz&purchase_details[fuel][type]=diesel&purchase_details[fuel][unit]=liter&purchase_details[fuel][unit_cost_decimal]=3.5&purchase_details[fuel][volume_decimal]=10&purchase_details[lodging][check_in_at]=1633651200&purchase_details[lodging][nights]=2&purchase_details[receipt][0][description]=Room%20charge&purchase_details[receipt][0][quantity]=1&purchase_details[receipt][0][total]=200&purchase_details[receipt][0][unit_cost]=200&purchase_details[reference]=foo", + ) + def test_test_helpers_issuing_authorizations_capture_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12331,6 +17071,19 @@ def test_test_helpers_issuing_authorizations_expire_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_authorizations_expire_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.TestHelpers.expire_async( + "example_authorization", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/authorizations/example_authorization/expire", + query_string="", + ) + def test_test_helpers_issuing_authorizations_expire_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12368,6 +17121,22 @@ def test_test_helpers_issuing_authorizations_increment_post( post_data="increment_amount=50&is_amount_controllable=True", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_authorizations_increment_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.TestHelpers.increment_async( + "example_authorization", + increment_amount=50, + is_amount_controllable=True, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/authorizations/example_authorization/increment", + query_string="", + post_data="increment_amount=50&is_amount_controllable=True", + ) + def test_test_helpers_issuing_authorizations_increment_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12428,6 +17197,43 @@ def test_test_helpers_issuing_authorizations_post( post_data="amount=100&amount_details[atm_fee]=10&amount_details[cashback_amount]=5&authorization_method=chip&card=foo¤cy=usd&is_amount_controllable=True&merchant_data[category]=ac_refrigeration_repair&merchant_data[city]=foo&merchant_data[country]=bar&merchant_data[name]=foo&merchant_data[network_id]=bar&merchant_data[postal_code]=foo&merchant_data[state]=bar&merchant_data[terminal_id]=foo&network_data[acquiring_institution_id]=foo&verification_data[address_line1_check]=mismatch&verification_data[address_postal_code_check]=match&verification_data[cvc_check]=match&verification_data[expiry_check]=mismatch&wallet=apple_pay", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_authorizations_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.TestHelpers.create_async( + amount=100, + amount_details={"atm_fee": 10, "cashback_amount": 5}, + authorization_method="chip", + card="foo", + currency="usd", + is_amount_controllable=True, + merchant_data={ + "category": "ac_refrigeration_repair", + "city": "foo", + "country": "bar", + "name": "foo", + "network_id": "bar", + "postal_code": "foo", + "state": "bar", + "terminal_id": "foo", + }, + network_data={"acquiring_institution_id": "foo"}, + verification_data={ + "address_line1_check": "mismatch", + "address_postal_code_check": "match", + "cvc_check": "match", + "expiry_check": "mismatch", + }, + wallet="apple_pay", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/authorizations", + query_string="", + post_data="amount=100&amount_details[atm_fee]=10&amount_details[cashback_amount]=5&authorization_method=chip&card=foo¤cy=usd&is_amount_controllable=True&merchant_data[category]=ac_refrigeration_repair&merchant_data[city]=foo&merchant_data[country]=bar&merchant_data[name]=foo&merchant_data[network_id]=bar&merchant_data[postal_code]=foo&merchant_data[state]=bar&merchant_data[terminal_id]=foo&network_data[acquiring_institution_id]=foo&verification_data[address_line1_check]=mismatch&verification_data[address_postal_code_check]=match&verification_data[cvc_check]=match&verification_data[expiry_check]=mismatch&wallet=apple_pay", + ) + def test_test_helpers_issuing_authorizations_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12490,7 +17296,22 @@ def test_test_helpers_issuing_authorizations_reverse_post( post_data="reverse_amount=20", ) - def test_test_helpers_issuing_authorizations_reverse_post_service( + @pytest.mark.anyio + async def test_test_helpers_issuing_authorizations_reverse_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Authorization.TestHelpers.reverse_async( + "example_authorization", + reverse_amount=20, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/authorizations/example_authorization/reverse", + query_string="", + post_data="reverse_amount=20", + ) + + def test_test_helpers_issuing_authorizations_reverse_post_service( self, http_client_mock: HTTPClientMock ) -> None: http_client_mock.stub_request( @@ -12524,6 +17345,17 @@ def test_test_helpers_issuing_cards_shipping_deliver_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_cards_shipping_deliver_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.TestHelpers.deliver_card_async("card_123") + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/cards/card_123/shipping/deliver", + query_string="", + ) + def test_test_helpers_issuing_cards_shipping_deliver_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12554,6 +17386,17 @@ def test_test_helpers_issuing_cards_shipping_fail_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_cards_shipping_fail_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.TestHelpers.fail_card_async("card_123") + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/cards/card_123/shipping/fail", + query_string="", + ) + def test_test_helpers_issuing_cards_shipping_fail_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12584,6 +17427,17 @@ def test_test_helpers_issuing_cards_shipping_return_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_cards_shipping_return_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.TestHelpers.return_card_async("card_123") + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/cards/card_123/shipping/return", + query_string="", + ) + def test_test_helpers_issuing_cards_shipping_return_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12614,6 +17468,17 @@ def test_test_helpers_issuing_cards_shipping_ship_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_cards_shipping_ship_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Card.TestHelpers.ship_card_async("card_123") + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/cards/card_123/shipping/ship", + query_string="", + ) + def test_test_helpers_issuing_cards_shipping_ship_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12693,6 +17558,66 @@ def test_test_helpers_issuing_transactions_create_force_capture_post( post_data="amount=100&card=foo¤cy=usd&merchant_data[category]=ac_refrigeration_repair&merchant_data[city]=foo&merchant_data[country]=US&merchant_data[name]=foo&merchant_data[network_id]=bar&merchant_data[postal_code]=10001&merchant_data[state]=NY&merchant_data[terminal_id]=foo&purchase_details[flight][departure_at]=1633651200&purchase_details[flight][passenger_name]=John%20Doe&purchase_details[flight][refundable]=True&purchase_details[flight][segments][0][arrival_airport_code]=SFO&purchase_details[flight][segments][0][carrier]=Delta&purchase_details[flight][segments][0][departure_airport_code]=LAX&purchase_details[flight][segments][0][flight_number]=DL100&purchase_details[flight][segments][0][service_class]=Economy&purchase_details[flight][segments][0][stopover_allowed]=True&purchase_details[flight][travel_agency]=Orbitz&purchase_details[fuel][type]=diesel&purchase_details[fuel][unit]=liter&purchase_details[fuel][unit_cost_decimal]=3.5&purchase_details[fuel][volume_decimal]=10&purchase_details[lodging][check_in_at]=1533651200&purchase_details[lodging][nights]=2&purchase_details[receipt][0][description]=Room%20charge&purchase_details[receipt][0][quantity]=1&purchase_details[receipt][0][total]=200&purchase_details[receipt][0][unit_cost]=200&purchase_details[reference]=foo", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_transactions_create_force_capture_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Transaction.TestHelpers.create_force_capture_async( + amount=100, + card="foo", + currency="usd", + merchant_data={ + "category": "ac_refrigeration_repair", + "city": "foo", + "country": "US", + "name": "foo", + "network_id": "bar", + "postal_code": "10001", + "state": "NY", + "terminal_id": "foo", + }, + purchase_details={ + "flight": { + "departure_at": 1633651200, + "passenger_name": "John Doe", + "refundable": True, + "segments": [ + { + "arrival_airport_code": "SFO", + "carrier": "Delta", + "departure_airport_code": "LAX", + "flight_number": "DL100", + "service_class": "Economy", + "stopover_allowed": True, + }, + ], + "travel_agency": "Orbitz", + }, + "fuel": { + "type": "diesel", + "unit": "liter", + "unit_cost_decimal": "3.5", + "volume_decimal": "10", + }, + "lodging": {"check_in_at": 1533651200, "nights": 2}, + "receipt": [ + { + "description": "Room charge", + "quantity": "1", + "total": 200, + "unit_cost": 200, + }, + ], + "reference": "foo", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/transactions/create_force_capture", + query_string="", + post_data="amount=100&card=foo¤cy=usd&merchant_data[category]=ac_refrigeration_repair&merchant_data[city]=foo&merchant_data[country]=US&merchant_data[name]=foo&merchant_data[network_id]=bar&merchant_data[postal_code]=10001&merchant_data[state]=NY&merchant_data[terminal_id]=foo&purchase_details[flight][departure_at]=1633651200&purchase_details[flight][passenger_name]=John%20Doe&purchase_details[flight][refundable]=True&purchase_details[flight][segments][0][arrival_airport_code]=SFO&purchase_details[flight][segments][0][carrier]=Delta&purchase_details[flight][segments][0][departure_airport_code]=LAX&purchase_details[flight][segments][0][flight_number]=DL100&purchase_details[flight][segments][0][service_class]=Economy&purchase_details[flight][segments][0][stopover_allowed]=True&purchase_details[flight][travel_agency]=Orbitz&purchase_details[fuel][type]=diesel&purchase_details[fuel][unit]=liter&purchase_details[fuel][unit_cost_decimal]=3.5&purchase_details[fuel][volume_decimal]=10&purchase_details[lodging][check_in_at]=1533651200&purchase_details[lodging][nights]=2&purchase_details[receipt][0][description]=Room%20charge&purchase_details[receipt][0][quantity]=1&purchase_details[receipt][0][total]=200&purchase_details[receipt][0][unit_cost]=200&purchase_details[reference]=foo", + ) + def test_test_helpers_issuing_transactions_create_force_capture_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12823,6 +17748,66 @@ def test_test_helpers_issuing_transactions_create_unlinked_refund_post( post_data="amount=100&card=foo¤cy=usd&merchant_data[category]=ac_refrigeration_repair&merchant_data[city]=foo&merchant_data[country]=bar&merchant_data[name]=foo&merchant_data[network_id]=bar&merchant_data[postal_code]=foo&merchant_data[state]=bar&merchant_data[terminal_id]=foo&purchase_details[flight][departure_at]=1533651200&purchase_details[flight][passenger_name]=John%20Doe&purchase_details[flight][refundable]=True&purchase_details[flight][segments][0][arrival_airport_code]=SFO&purchase_details[flight][segments][0][carrier]=Delta&purchase_details[flight][segments][0][departure_airport_code]=LAX&purchase_details[flight][segments][0][flight_number]=DL100&purchase_details[flight][segments][0][service_class]=Economy&purchase_details[flight][segments][0][stopover_allowed]=True&purchase_details[flight][travel_agency]=Orbitz&purchase_details[fuel][type]=diesel&purchase_details[fuel][unit]=liter&purchase_details[fuel][unit_cost_decimal]=3.5&purchase_details[fuel][volume_decimal]=10&purchase_details[lodging][check_in_at]=1533651200&purchase_details[lodging][nights]=2&purchase_details[receipt][0][description]=Room%20charge&purchase_details[receipt][0][quantity]=1&purchase_details[receipt][0][total]=200&purchase_details[receipt][0][unit_cost]=200&purchase_details[reference]=foo", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_transactions_create_unlinked_refund_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Transaction.TestHelpers.create_unlinked_refund_async( + amount=100, + card="foo", + currency="usd", + merchant_data={ + "category": "ac_refrigeration_repair", + "city": "foo", + "country": "bar", + "name": "foo", + "network_id": "bar", + "postal_code": "foo", + "state": "bar", + "terminal_id": "foo", + }, + purchase_details={ + "flight": { + "departure_at": 1533651200, + "passenger_name": "John Doe", + "refundable": True, + "segments": [ + { + "arrival_airport_code": "SFO", + "carrier": "Delta", + "departure_airport_code": "LAX", + "flight_number": "DL100", + "service_class": "Economy", + "stopover_allowed": True, + }, + ], + "travel_agency": "Orbitz", + }, + "fuel": { + "type": "diesel", + "unit": "liter", + "unit_cost_decimal": "3.5", + "volume_decimal": "10", + }, + "lodging": {"check_in_at": 1533651200, "nights": 2}, + "receipt": [ + { + "description": "Room charge", + "quantity": "1", + "total": 200, + "unit_cost": 200, + }, + ], + "reference": "foo", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/transactions/create_unlinked_refund", + query_string="", + post_data="amount=100&card=foo¤cy=usd&merchant_data[category]=ac_refrigeration_repair&merchant_data[city]=foo&merchant_data[country]=bar&merchant_data[name]=foo&merchant_data[network_id]=bar&merchant_data[postal_code]=foo&merchant_data[state]=bar&merchant_data[terminal_id]=foo&purchase_details[flight][departure_at]=1533651200&purchase_details[flight][passenger_name]=John%20Doe&purchase_details[flight][refundable]=True&purchase_details[flight][segments][0][arrival_airport_code]=SFO&purchase_details[flight][segments][0][carrier]=Delta&purchase_details[flight][segments][0][departure_airport_code]=LAX&purchase_details[flight][segments][0][flight_number]=DL100&purchase_details[flight][segments][0][service_class]=Economy&purchase_details[flight][segments][0][stopover_allowed]=True&purchase_details[flight][travel_agency]=Orbitz&purchase_details[fuel][type]=diesel&purchase_details[fuel][unit]=liter&purchase_details[fuel][unit_cost_decimal]=3.5&purchase_details[fuel][volume_decimal]=10&purchase_details[lodging][check_in_at]=1533651200&purchase_details[lodging][nights]=2&purchase_details[receipt][0][description]=Room%20charge&purchase_details[receipt][0][quantity]=1&purchase_details[receipt][0][total]=200&purchase_details[receipt][0][unit_cost]=200&purchase_details[reference]=foo", + ) + def test_test_helpers_issuing_transactions_create_unlinked_refund_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12908,6 +17893,21 @@ def test_test_helpers_issuing_transactions_refund_post( post_data="refund_amount=50", ) + @pytest.mark.anyio + async def test_test_helpers_issuing_transactions_refund_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.issuing.Transaction.TestHelpers.refund_async( + "example_transaction", + refund_amount=50, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/issuing/transactions/example_transaction/refund", + query_string="", + post_data="refund_amount=50", + ) + def test_test_helpers_issuing_transactions_refund_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12942,6 +17942,17 @@ def test_test_helpers_refunds_expire_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_refunds_expire_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Refund.TestHelpers.expire_async("re_123") + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/refunds/re_123/expire", + query_string="", + ) + def test_test_helpers_refunds_expire_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -12976,6 +17987,21 @@ def test_test_helpers_test_clocks_advance_post( post_data="frozen_time=142", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_advance_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.advance_async( + "clock_xyz", + frozen_time=142, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/test_clocks/clock_xyz/advance", + query_string="", + post_data="frozen_time=142", + ) + def test_test_helpers_test_clocks_advance_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13014,6 +18040,21 @@ def test_test_helpers_test_clocks_advance_post_2( post_data="frozen_time=1675552261", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_advance_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.advance_async( + "clock_xxxxxxxxxxxxx", + frozen_time=1675552261, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx/advance", + query_string="", + post_data="frozen_time=1675552261", + ) + def test_test_helpers_test_clocks_advance_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13048,6 +18089,17 @@ def test_test_helpers_test_clocks_delete( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.delete_async("clock_xyz") + http_client_mock_async.assert_requested( + "delete", + path="/v1/test_helpers/test_clocks/clock_xyz", + query_string="", + ) + def test_test_helpers_test_clocks_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13078,6 +18130,17 @@ def test_test_helpers_test_clocks_delete_2( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_delete_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.delete_async("clock_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx", + query_string="", + ) + def test_test_helpers_test_clocks_delete_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13108,6 +18171,17 @@ def test_test_helpers_test_clocks_get( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.list_async() + http_client_mock_async.assert_requested( + "get", + path="/v1/test_helpers/test_clocks", + query_string="", + ) + def test_test_helpers_test_clocks_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13138,6 +18212,17 @@ def test_test_helpers_test_clocks_get_2( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.retrieve_async("clock_xyz") + http_client_mock_async.assert_requested( + "get", + path="/v1/test_helpers/test_clocks/clock_xyz", + query_string="", + ) + def test_test_helpers_test_clocks_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13168,6 +18253,17 @@ def test_test_helpers_test_clocks_get_3( query_string="limit=3", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_get_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/test_helpers/test_clocks", + query_string="limit=3", + ) + def test_test_helpers_test_clocks_get_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13199,6 +18295,19 @@ def test_test_helpers_test_clocks_get_4( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_get_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.retrieve_async( + "clock_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx", + query_string="", + ) + def test_test_helpers_test_clocks_get_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13233,6 +18342,21 @@ def test_test_helpers_test_clocks_post( post_data="frozen_time=123&name=cogsworth", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.create_async( + frozen_time=123, + name="cogsworth", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/test_clocks", + query_string="", + post_data="frozen_time=123&name=cogsworth", + ) + def test_test_helpers_test_clocks_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13270,6 +18394,20 @@ def test_test_helpers_test_clocks_post_2( post_data="frozen_time=1577836800", ) + @pytest.mark.anyio + async def test_test_helpers_test_clocks_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.test_helpers.TestClock.create_async( + frozen_time=1577836800 + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/test_clocks", + query_string="", + post_data="frozen_time=1577836800", + ) + def test_test_helpers_test_clocks_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13305,6 +18443,21 @@ def test_test_helpers_treasury_inbound_transfers_fail_post( post_data="failure_details[code]=account_closed", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_inbound_transfers_fail_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.TestHelpers.fail_async( + "ibt_123", + failure_details={"code": "account_closed"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/inbound_transfers/ibt_123/fail", + query_string="", + post_data="failure_details[code]=account_closed", + ) + def test_test_helpers_treasury_inbound_transfers_fail_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13341,6 +18494,19 @@ def test_test_helpers_treasury_inbound_transfers_return_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_inbound_transfers_return_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.TestHelpers.return_inbound_transfer_async( + "ibt_123", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/inbound_transfers/ibt_123/return", + query_string="", + ) + def test_test_helpers_treasury_inbound_transfers_return_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13373,6 +18539,19 @@ def test_test_helpers_treasury_inbound_transfers_succeed_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_inbound_transfers_succeed_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.TestHelpers.succeed_async( + "ibt_123", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/inbound_transfers/ibt_123/succeed", + query_string="", + ) + def test_test_helpers_treasury_inbound_transfers_succeed_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13403,6 +18582,19 @@ def test_test_helpers_treasury_outbound_transfers_fail_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_outbound_transfers_fail_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.TestHelpers.fail_async( + "obt_123" + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/outbound_transfers/obt_123/fail", + query_string="", + ) + def test_test_helpers_treasury_outbound_transfers_fail_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13433,6 +18625,19 @@ def test_test_helpers_treasury_outbound_transfers_post_post( query_string="", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_outbound_transfers_post_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.TestHelpers.post_async( + "obt_123" + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/outbound_transfers/obt_123/post", + query_string="", + ) + def test_test_helpers_treasury_outbound_transfers_post_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13456,11 +18661,26 @@ def test_test_helpers_treasury_outbound_transfers_post_post_service( def test_test_helpers_treasury_outbound_transfers_return_post( self, http_client_mock: HTTPClientMock ) -> None: - stripe.treasury.OutboundTransfer.TestHelpers.return_outbound_transfer( + stripe.treasury.OutboundTransfer.TestHelpers.return_outbound_transfer( + "obt_123", + returned_details={"code": "account_closed"}, + ) + http_client_mock.assert_requested( + "post", + path="/v1/test_helpers/treasury/outbound_transfers/obt_123/return", + query_string="", + post_data="returned_details[code]=account_closed", + ) + + @pytest.mark.anyio + async def test_test_helpers_treasury_outbound_transfers_return_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.TestHelpers.return_outbound_transfer_async( "obt_123", returned_details={"code": "account_closed"}, ) - http_client_mock.assert_requested( + http_client_mock_async.assert_requested( "post", path="/v1/test_helpers/treasury/outbound_transfers/obt_123/return", query_string="", @@ -13507,6 +18727,23 @@ def test_test_helpers_treasury_received_credits_post( post_data="financial_account=fa_123&network=ach&amount=1234¤cy=usd", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_received_credits_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.ReceivedCredit.TestHelpers.create_async( + financial_account="fa_123", + network="ach", + amount=1234, + currency="usd", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/received_credits", + query_string="", + post_data="financial_account=fa_123&network=ach&amount=1234¤cy=usd", + ) + def test_test_helpers_treasury_received_credits_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13551,6 +18788,23 @@ def test_test_helpers_treasury_received_debits_post( post_data="financial_account=fa_123&network=ach&amount=1234¤cy=usd", ) + @pytest.mark.anyio + async def test_test_helpers_treasury_received_debits_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.ReceivedDebit.TestHelpers.create_async( + financial_account="fa_123", + network="ach", + amount=1234, + currency="usd", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/test_helpers/treasury/received_debits", + query_string="", + post_data="financial_account=fa_123&network=ach&amount=1234¤cy=usd", + ) + def test_test_helpers_treasury_received_debits_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13587,6 +18841,17 @@ def test_tokens_get(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_tokens_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.retrieve_async("tok_xxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/tokens/tok_xxxx", + query_string="", + ) + def test_tokens_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13623,6 +18888,25 @@ def test_tokens_post(self, http_client_mock: HTTPClientMock) -> None: post_data="card[number]=4242424242424242&card[exp_month]=5&card[exp_year]=2023&card[cvc]=314", ) + @pytest.mark.anyio + async def test_tokens_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.create_async( + card={ + "number": "4242424242424242", + "exp_month": "5", + "exp_year": "2023", + "cvc": "314", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tokens", + query_string="", + post_data="card[number]=4242424242424242&card[exp_month]=5&card[exp_year]=2023&card[cvc]=314", + ) + def test_tokens_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13671,6 +18955,27 @@ def test_tokens_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="bank_account[country]=US&bank_account[currency]=usd&bank_account[account_holder_name]=Jenny%20Rosen&bank_account[account_holder_type]=individual&bank_account[routing_number]=110000000&bank_account[account_number]=000123456789", ) + @pytest.mark.anyio + async def test_tokens_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.create_async( + bank_account={ + "country": "US", + "currency": "usd", + "account_holder_name": "Jenny Rosen", + "account_holder_type": "individual", + "routing_number": "110000000", + "account_number": "000123456789", + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tokens", + query_string="", + post_data="bank_account[country]=US&bank_account[currency]=usd&bank_account[account_holder_name]=Jenny%20Rosen&bank_account[account_holder_type]=individual&bank_account[routing_number]=110000000&bank_account[account_number]=000123456789", + ) + def test_tokens_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13712,6 +19017,18 @@ def test_tokens_post_3(self, http_client_mock: HTTPClientMock) -> None: post_data="pii[id_number]=000000000", ) + @pytest.mark.anyio + async def test_tokens_post_3_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.create_async(pii={"id_number": "000000000"}) + http_client_mock_async.assert_requested( + "post", + path="/v1/tokens", + query_string="", + post_data="pii[id_number]=000000000", + ) + def test_tokens_post_3_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13747,6 +19064,23 @@ def test_tokens_post_4(self, http_client_mock: HTTPClientMock) -> None: post_data="account[individual][first_name]=Jane&account[individual][last_name]=Doe&account[tos_shown_and_accepted]=True", ) + @pytest.mark.anyio + async def test_tokens_post_4_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.create_async( + account={ + "individual": {"first_name": "Jane", "last_name": "Doe"}, + "tos_shown_and_accepted": True, + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tokens", + query_string="", + post_data="account[individual][first_name]=Jane&account[individual][last_name]=Doe&account[tos_shown_and_accepted]=True", + ) + def test_tokens_post_4_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13790,6 +19124,24 @@ def test_tokens_post_5(self, http_client_mock: HTTPClientMock) -> None: post_data="person[first_name]=Jane&person[last_name]=Doe&person[relationship][owner]=True", ) + @pytest.mark.anyio + async def test_tokens_post_5_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.create_async( + person={ + "first_name": "Jane", + "last_name": "Doe", + "relationship": {"owner": True}, + }, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/tokens", + query_string="", + post_data="person[first_name]=Jane&person[last_name]=Doe&person[relationship][owner]=True", + ) + def test_tokens_post_5_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13828,6 +19180,18 @@ def test_tokens_post_6(self, http_client_mock: HTTPClientMock) -> None: post_data="cvc_update[cvc]=123", ) + @pytest.mark.anyio + async def test_tokens_post_6_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Token.create_async(cvc_update={"cvc": "123"}) + http_client_mock_async.assert_requested( + "post", + path="/v1/tokens", + query_string="", + post_data="cvc_update[cvc]=123", + ) + def test_tokens_post_6_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13859,6 +19223,17 @@ def test_topups_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_topups_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Topup.cancel_async("tu_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/topups/tu_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_topups_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13887,6 +19262,17 @@ def test_topups_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_topups_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Topup.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/topups", + query_string="limit=3", + ) + def test_topups_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13916,6 +19302,17 @@ def test_topups_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_topups_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Topup.retrieve_async("tu_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/topups/tu_xxxxxxxxxxxxx", + query_string="", + ) + def test_topups_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13950,6 +19347,23 @@ def test_topups_post(self, http_client_mock: HTTPClientMock) -> None: post_data="amount=2000¤cy=usd&description=Top-up%20for%20Jenny%20Rosen&statement_descriptor=Top-up", ) + @pytest.mark.anyio + async def test_topups_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Topup.create_async( + amount=2000, + currency="usd", + description="Top-up for Jenny Rosen", + statement_descriptor="Top-up", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/topups", + query_string="", + post_data="amount=2000¤cy=usd&description=Top-up%20for%20Jenny%20Rosen&statement_descriptor=Top-up", + ) + def test_topups_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -13990,6 +19404,21 @@ def test_topups_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_topups_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Topup.modify_async( + "tu_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/topups/tu_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_topups_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14022,6 +19451,17 @@ def test_transfers_get(self, http_client_mock: HTTPClientMock) -> None: query_string="limit=3", ) + @pytest.mark.anyio + async def test_transfers_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/transfers", + query_string="limit=3", + ) + def test_transfers_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14051,6 +19491,17 @@ def test_transfers_get_2(self, http_client_mock: HTTPClientMock) -> None: query_string="", ) + @pytest.mark.anyio + async def test_transfers_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.retrieve_async("tr_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/transfers/tr_xxxxxxxxxxxxx", + query_string="", + ) + def test_transfers_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14085,6 +19536,23 @@ def test_transfers_post(self, http_client_mock: HTTPClientMock) -> None: post_data="amount=400¤cy=usd&destination=acct_xxxxxxxxxxxxx&transfer_group=ORDER_95", ) + @pytest.mark.anyio + async def test_transfers_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.create_async( + amount=400, + currency="usd", + destination="acct_xxxxxxxxxxxxx", + transfer_group="ORDER_95", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/transfers", + query_string="", + post_data="amount=400¤cy=usd&destination=acct_xxxxxxxxxxxxx&transfer_group=ORDER_95", + ) + def test_transfers_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14125,6 +19593,21 @@ def test_transfers_post_2(self, http_client_mock: HTTPClientMock) -> None: post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_transfers_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.modify_async( + "tr_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/transfers/tr_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_transfers_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14162,6 +19645,20 @@ def test_transfers_reversals_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_transfers_reversals_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.list_reversals_async( + "tr_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/transfers/tr_xxxxxxxxxxxxx/reversals", + query_string="limit=3", + ) + def test_transfers_reversals_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14199,6 +19696,20 @@ def test_transfers_reversals_get_2( query_string="", ) + @pytest.mark.anyio + async def test_transfers_reversals_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.retrieve_reversal_async( + "tr_xxxxxxxxxxxxx", + "trr_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/transfers/tr_xxxxxxxxxxxxx/reversals/trr_xxxxxxxxxxxxx", + query_string="", + ) + def test_transfers_reversals_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14236,6 +19747,21 @@ def test_transfers_reversals_post( post_data="amount=100", ) + @pytest.mark.anyio + async def test_transfers_reversals_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.create_reversal_async( + "tr_xxxxxxxxxxxxx", + amount=100, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/transfers/tr_xxxxxxxxxxxxx/reversals", + query_string="", + post_data="amount=100", + ) + def test_transfers_reversals_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14275,6 +19801,22 @@ def test_transfers_reversals_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_transfers_reversals_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.Transfer.modify_reversal_async( + "tr_xxxxxxxxxxxxx", + "trr_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/transfers/tr_xxxxxxxxxxxxx/reversals/trr_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_transfers_reversals_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14313,6 +19855,20 @@ def test_treasury_credit_reversals_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_credit_reversals_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.CreditReversal.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/credit_reversals", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_credit_reversals_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14349,6 +19905,19 @@ def test_treasury_credit_reversals_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_credit_reversals_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.CreditReversal.retrieve_async( + "credrev_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/credit_reversals/credrev_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_credit_reversals_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14382,6 +19951,20 @@ def test_treasury_credit_reversals_post( post_data="received_credit=rc_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_treasury_credit_reversals_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.CreditReversal.create_async( + received_credit="rc_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/credit_reversals", + query_string="", + post_data="received_credit=rc_xxxxxxxxxxxxx", + ) + def test_treasury_credit_reversals_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14420,6 +20003,20 @@ def test_treasury_debit_reversals_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_debit_reversals_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.DebitReversal.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/debit_reversals", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_debit_reversals_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14456,6 +20053,19 @@ def test_treasury_debit_reversals_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_debit_reversals_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.DebitReversal.retrieve_async( + "debrev_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/debit_reversals/debrev_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_debit_reversals_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14487,6 +20097,20 @@ def test_treasury_debit_reversals_post( post_data="received_debit=rd_xxxxxxxxxxxxx", ) + @pytest.mark.anyio + async def test_treasury_debit_reversals_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.DebitReversal.create_async( + received_debit="rd_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/debit_reversals", + query_string="", + post_data="received_debit=rd_xxxxxxxxxxxxx", + ) + def test_treasury_debit_reversals_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14522,6 +20146,19 @@ def test_treasury_financial_accounts_features_get( query_string="", ) + @pytest.mark.anyio + async def test_treasury_financial_accounts_features_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.FinancialAccount.retrieve_features_async( + "fa_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx/features", + query_string="", + ) + def test_treasury_financial_accounts_features_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14552,6 +20189,17 @@ def test_treasury_financial_accounts_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_treasury_financial_accounts_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.FinancialAccount.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/financial_accounts", + query_string="limit=3", + ) + def test_treasury_financial_accounts_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14583,6 +20231,19 @@ def test_treasury_financial_accounts_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_financial_accounts_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.FinancialAccount.retrieve_async( + "fa_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_financial_accounts_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14617,6 +20278,21 @@ def test_treasury_financial_accounts_post( post_data="supported_currencies[0]=usd", ) + @pytest.mark.anyio + async def test_treasury_financial_accounts_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.FinancialAccount.create_async( + supported_currencies=["usd"], + features={}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/financial_accounts", + query_string="", + post_data="supported_currencies[0]=usd", + ) + def test_treasury_financial_accounts_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14657,6 +20333,21 @@ def test_treasury_financial_accounts_post_2( post_data="metadata[order_id]=6735", ) + @pytest.mark.anyio + async def test_treasury_financial_accounts_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.FinancialAccount.modify_async( + "fa_xxxxxxxxxxxxx", + metadata={"order_id": "6735"}, + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx", + query_string="", + post_data="metadata[order_id]=6735", + ) + def test_treasury_financial_accounts_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14691,6 +20382,17 @@ def test_treasury_inbound_transfers_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_treasury_inbound_transfers_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.cancel_async("ibt_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/inbound_transfers/ibt_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_treasury_inbound_transfers_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14724,6 +20426,20 @@ def test_treasury_inbound_transfers_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_inbound_transfers_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/inbound_transfers", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_inbound_transfers_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14760,6 +20476,19 @@ def test_treasury_inbound_transfers_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_inbound_transfers_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.retrieve_async( + "ibt_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/inbound_transfers/ibt_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_inbound_transfers_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14797,6 +20526,24 @@ def test_treasury_inbound_transfers_post( post_data="financial_account=fa_xxxxxxxxxxxxx&amount=10000¤cy=usd&origin_payment_method=pm_xxxxxxxxxxxxx&description=InboundTransfer%20from%20my%20bank%20account", ) + @pytest.mark.anyio + async def test_treasury_inbound_transfers_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.InboundTransfer.create_async( + financial_account="fa_xxxxxxxxxxxxx", + amount=10000, + currency="usd", + origin_payment_method="pm_xxxxxxxxxxxxx", + description="InboundTransfer from my bank account", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/inbound_transfers", + query_string="", + post_data="financial_account=fa_xxxxxxxxxxxxx&amount=10000¤cy=usd&origin_payment_method=pm_xxxxxxxxxxxxx&description=InboundTransfer%20from%20my%20bank%20account", + ) + def test_treasury_inbound_transfers_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14836,6 +20583,17 @@ def test_treasury_outbound_payments_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_treasury_outbound_payments_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundPayment.cancel_async("bot_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/outbound_payments/bot_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_treasury_outbound_payments_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14869,6 +20627,20 @@ def test_treasury_outbound_payments_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_outbound_payments_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundPayment.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/outbound_payments", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_outbound_payments_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14905,6 +20677,19 @@ def test_treasury_outbound_payments_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_outbound_payments_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundPayment.retrieve_async( + "bot_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/outbound_payments/bot_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_outbound_payments_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14943,6 +20728,25 @@ def test_treasury_outbound_payments_post( post_data="financial_account=fa_xxxxxxxxxxxxx&amount=10000¤cy=usd&customer=cus_xxxxxxxxxxxxx&destination_payment_method=pm_xxxxxxxxxxxxx&description=OutboundPayment%20to%20a%203rd%20party", ) + @pytest.mark.anyio + async def test_treasury_outbound_payments_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundPayment.create_async( + financial_account="fa_xxxxxxxxxxxxx", + amount=10000, + currency="usd", + customer="cus_xxxxxxxxxxxxx", + destination_payment_method="pm_xxxxxxxxxxxxx", + description="OutboundPayment to a 3rd party", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/outbound_payments", + query_string="", + post_data="financial_account=fa_xxxxxxxxxxxxx&amount=10000¤cy=usd&customer=cus_xxxxxxxxxxxxx&destination_payment_method=pm_xxxxxxxxxxxxx&description=OutboundPayment%20to%20a%203rd%20party", + ) + def test_treasury_outbound_payments_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -14983,6 +20787,19 @@ def test_treasury_outbound_transfers_cancel_post( query_string="", ) + @pytest.mark.anyio + async def test_treasury_outbound_transfers_cancel_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.cancel_async( + "obt_xxxxxxxxxxxxx" + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/outbound_transfers/obt_xxxxxxxxxxxxx/cancel", + query_string="", + ) + def test_treasury_outbound_transfers_cancel_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15016,6 +20833,20 @@ def test_treasury_outbound_transfers_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_outbound_transfers_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/outbound_transfers", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_outbound_transfers_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15052,6 +20883,19 @@ def test_treasury_outbound_transfers_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_outbound_transfers_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.retrieve_async( + "obt_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/outbound_transfers/obt_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_outbound_transfers_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15089,6 +20933,24 @@ def test_treasury_outbound_transfers_post( post_data="financial_account=fa_xxxxxxxxxxxxx&destination_payment_method=pm_xxxxxxxxxxxxx&amount=500¤cy=usd&description=OutboundTransfer%20to%20my%20external%20bank%20account", ) + @pytest.mark.anyio + async def test_treasury_outbound_transfers_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.OutboundTransfer.create_async( + financial_account="fa_xxxxxxxxxxxxx", + destination_payment_method="pm_xxxxxxxxxxxxx", + amount=500, + currency="usd", + description="OutboundTransfer to my external bank account", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/treasury/outbound_transfers", + query_string="", + post_data="financial_account=fa_xxxxxxxxxxxxx&destination_payment_method=pm_xxxxxxxxxxxxx&amount=500¤cy=usd&description=OutboundTransfer%20to%20my%20external%20bank%20account", + ) + def test_treasury_outbound_transfers_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15131,6 +20993,20 @@ def test_treasury_received_credits_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_received_credits_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.ReceivedCredit.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/received_credits", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_received_credits_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15167,6 +21043,17 @@ def test_treasury_received_credits_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_received_credits_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.ReceivedCredit.retrieve_async("rc_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/received_credits/rc_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_received_credits_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15200,6 +21087,20 @@ def test_treasury_received_debits_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_received_debits_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.ReceivedDebit.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/received_debits", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_received_debits_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15236,6 +21137,17 @@ def test_treasury_received_debits_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_received_debits_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.ReceivedDebit.retrieve_async("rd_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/received_debits/rd_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_received_debits_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15269,6 +21181,20 @@ def test_treasury_transaction_entries_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_transaction_entries_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.TransactionEntry.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/transaction_entries", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_transaction_entries_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15305,6 +21231,19 @@ def test_treasury_transaction_entries_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_transaction_entries_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.TransactionEntry.retrieve_async( + "trxne_xxxxxxxxxxxxx", + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/transaction_entries/trxne_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_transaction_entries_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15338,6 +21277,20 @@ def test_treasury_transactions_get( query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", ) + @pytest.mark.anyio + async def test_treasury_transactions_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.Transaction.list_async( + financial_account="fa_xxxxxxxxxxxxx", + limit=3, + ) + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/transactions", + query_string="financial_account=fa_xxxxxxxxxxxxx&limit=3", + ) + def test_treasury_transactions_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15374,6 +21327,17 @@ def test_treasury_transactions_get_2( query_string="", ) + @pytest.mark.anyio + async def test_treasury_transactions_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.treasury.Transaction.retrieve_async("trxn_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/treasury/transactions/trxn_xxxxxxxxxxxxx", + query_string="", + ) + def test_treasury_transactions_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15404,6 +21368,17 @@ def test_webhook_endpoints_delete( query_string="", ) + @pytest.mark.anyio + async def test_webhook_endpoints_delete_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.WebhookEndpoint.delete_async("we_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "delete", + path="/v1/webhook_endpoints/we_xxxxxxxxxxxxx", + query_string="", + ) + def test_webhook_endpoints_delete_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15434,6 +21409,17 @@ def test_webhook_endpoints_get( query_string="limit=3", ) + @pytest.mark.anyio + async def test_webhook_endpoints_get_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.WebhookEndpoint.list_async(limit=3) + http_client_mock_async.assert_requested( + "get", + path="/v1/webhook_endpoints", + query_string="limit=3", + ) + def test_webhook_endpoints_get_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15465,6 +21451,17 @@ def test_webhook_endpoints_get_2( query_string="", ) + @pytest.mark.anyio + async def test_webhook_endpoints_get_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.WebhookEndpoint.retrieve_async("we_xxxxxxxxxxxxx") + http_client_mock_async.assert_requested( + "get", + path="/v1/webhook_endpoints/we_xxxxxxxxxxxxx", + query_string="", + ) + def test_webhook_endpoints_get_2_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15499,6 +21496,21 @@ def test_webhook_endpoints_post( post_data="url=https%3A%2F%2Fexample.com%2Fmy%2Fwebhook%2Fendpoint&enabled_events[0]=charge.failed&enabled_events[1]=charge.succeeded", ) + @pytest.mark.anyio + async def test_webhook_endpoints_post_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.WebhookEndpoint.create_async( + url="https://example.com/my/webhook/endpoint", + enabled_events=["charge.failed", "charge.succeeded"], + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/webhook_endpoints", + query_string="", + post_data="url=https%3A%2F%2Fexample.com%2Fmy%2Fwebhook%2Fendpoint&enabled_events[0]=charge.failed&enabled_events[1]=charge.succeeded", + ) + def test_webhook_endpoints_post_service( self, http_client_mock: HTTPClientMock ) -> None: @@ -15539,6 +21551,21 @@ def test_webhook_endpoints_post_2( post_data="url=https%3A%2F%2Fexample.com%2Fnew_endpoint", ) + @pytest.mark.anyio + async def test_webhook_endpoints_post_2_async( + self, http_client_mock_async: HTTPClientMock + ) -> None: + await stripe.WebhookEndpoint.modify_async( + "we_xxxxxxxxxxxxx", + url="https://example.com/new_endpoint", + ) + http_client_mock_async.assert_requested( + "post", + path="/v1/webhook_endpoints/we_xxxxxxxxxxxxx", + query_string="", + post_data="url=https%3A%2F%2Fexample.com%2Fnew_endpoint", + ) + def test_webhook_endpoints_post_2_service( self, http_client_mock: HTTPClientMock ) -> None: diff --git a/tests/test_integration.py b/tests/test_integration.py index 24db28f06..3187ec67c 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -4,6 +4,8 @@ import warnings import time +import httpx + import stripe import pytest from queue import Queue @@ -325,7 +327,11 @@ def do_request(self, n): self.setup_mock_server(MockServerRequestHandler) stripe.api_base = "http://localhost:%s" % self.mock_server_port stripe.default_http_client_async = stripe.HTTPXClient() - stripe.default_http_client_async._timeout = 0.01 + # If we set HTTPX's generic timeout the test is flaky (sometimes it's a ReadTimeout, sometimes its a ConnectTimeout) + # so we set only the read timeout specifically. + stripe.default_http_client_async._timeout = httpx.Timeout( + None, read=0.01 + ) stripe.max_network_retries = 0 exception = None