From 367a4fc64e989edd21f7847d51999313fc83ec03 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 12 Jan 2024 12:45:53 +0100 Subject: [PATCH] Stripe: Fix compatibility with old payments --- src/pretix/plugins/stripe/payment.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pretix/plugins/stripe/payment.py b/src/pretix/plugins/stripe/payment.py index 010a932166..5cf83a1802 100644 --- a/src/pretix/plugins/stripe/payment.py +++ b/src/pretix/plugins/stripe/payment.py @@ -644,7 +644,7 @@ class StripeMethod(BasePaymentProvider): payment_info = json.loads(payment.info) if 'amount' in payment_info: payment_info['amount'] /= 10 ** settings.CURRENCY_PLACES.get(self.event.currency, 2) - if payment_info.get("latest_charge"): + if isinstance(payment_info.get("latest_charge"), dict): details = payment_info["latest_charge"].get("payment_method_details", {}) elif payment_info.get("charges") and payment_info["charges"]["data"]: details = payment_info["charges"]["data"][0].get("payment_method_details", {}) @@ -693,7 +693,7 @@ class StripeMethod(BasePaymentProvider): try: if payment_info['id'].startswith('pi_'): - if 'latest_charge' in payment_info: + if 'latest_charge' in payment_info and isinstance(payment_info.get("latest_charge"), dict): chargeid = payment_info['latest_charge']['id'] else: chargeid = payment_info['charges']['data'][0]['id'] @@ -1247,7 +1247,7 @@ class StripeCC(StripeMethod): def payment_presale_render(self, payment: OrderPayment) -> str: pi = payment.info_data or {} try: - if "latest_charge" in pi: + if "latest_charge" in pi and isinstance(pi.get("latest_charge"), dict): card = pi["latest_charge"]["payment_method_details"]["card"] else: card = pi["source"]["card"]