From a89cbb000402f593eee260d10b30cbbf7358f2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 21 Jun 2024 14:16:32 +0200 Subject: [PATCH] Add property to retrieve stripe charge object (grafted from 9115d7e49c6c4cdb60a2d9c6b72da1dcd6452b7e) --HG-- branch : 6.0 --- modules/account_payment_stripe/payment.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/account_payment_stripe/payment.py b/modules/account_payment_stripe/payment.py index fe8eb6dbeb..4aa1322c75 100644 --- a/modules/account_payment_stripe/payment.py +++ b/modules/account_payment_stripe/payment.py @@ -742,6 +742,19 @@ class Payment(CheckoutMixin, metaclass=PoolMeta): def stripe_intent_update(cls, payments=None): pass + @property + def stripe_charge_(self): + if not self.stripe_charge_id: + return + try: + return stripe.Charge.retrieve( + self.stripe_charge_id, + api_key=self.journal.stripe_account.secret_key, + stripe_version=STRIPE_VERSION) + except (stripe.error.RateLimitError, + stripe.error.APIConnectionError) as e: + logger.warning(str(e)) + class Refund(Workflow, ModelSQL, ModelView): "Stripe Payment Refund"