From 290cba995bcd52cbcea30ea06b599668544d783a Mon Sep 17 00:00:00 2001 From: Bharat Chauhan Date: Wed, 24 Nov 2021 19:33:37 +0530 Subject: [PATCH] Add support for expire method on resource Checkout.Session --- .../api_resources/checkout/session.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/async_stripe/api_resources/checkout/session.py b/async_stripe/api_resources/checkout/session.py index f7be2bf..107a9c9 100644 --- a/async_stripe/api_resources/checkout/session.py +++ b/async_stripe/api_resources/checkout/session.py @@ -1,7 +1,23 @@ import stripe -from async_stripe.api_resources.abstract import patch_nested_resources +from stripe import util +from async_stripe.api_resources.abstract import patch_custom_methods, patch_nested_resources -nested_resources = ["line_item"] +async def expire_patch(self, idempotency_key=None, **params): + url = self.instance_url() + "/expire" + headers = util.populate_headers(idempotency_key) + self.refresh_from(await self.request("post", url, params, headers)) + return self + + +stripe.checkout.Session.expire = expire_patch + +custom_resources = [ + {"name": "expire", "http_verb": "post"}, +] +patch_custom_methods(stripe.checkout.Session, custom_resources) + + +nested_resources = ["line_item"] patch_nested_resources(stripe.checkout.Session, nested_resources) \ No newline at end of file