Skip to content

Commit

Permalink
Stripe: Fix compatibility with old payments
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Jan 12, 2024
1 parent 33ace85 commit 367a4fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pretix/plugins/stripe/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def payment_control_render(self, request, payment) -> str:
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", {})
Expand Down Expand Up @@ -693,7 +693,7 @@ def execute_refund(self, refund: OrderRefund):

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']
Expand Down Expand Up @@ -1247,7 +1247,7 @@ def is_moto(self, request, payment=None) -> bool:
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"]
Expand Down

0 comments on commit 367a4fc

Please sign in to comment.