From 8ea66bc05b85ecbf1365ffb50f305def100cfa24 Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Fri, 28 Aug 2020 23:21:35 +0200 Subject: [PATCH] First try at working around Stripe's iDEAL idempotency issues --- src/pretix/plugins/stripe/payment.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pretix/plugins/stripe/payment.py b/src/pretix/plugins/stripe/payment.py index c2616d0a93..c29db066af 100644 --- a/src/pretix/plugins/stripe/payment.py +++ b/src/pretix/plugins/stripe/payment.py @@ -406,6 +406,20 @@ class StripeMethod(BasePaymentProvider): }) raise PaymentException(_('Stripe reported an error with your card: %s') % err['message']) + # This is not an error we normally expect, however some payment methods like iDEAL will redirect + # the user back to our confirmation page at the same time from two devices: the web browser the + # purchase is executed from and the online banking app the payment is authorized from. + # In this case we will just log the idempotency error but not expose it to the user and just + # forward them back to their order page. There is a good chance that by the time the user hits + # the order page, the other request has gone through and the payment is confirmed. + except stripe.error.IdempotencyError as e: + if e.json_body and 'error' in e.json_body: + err = e.json_body['error'] + logger.exception('Stripe error: %s' % str(err)) + else: + logger.exception('Stripe error: %s' % str(e)) + return + except stripe.error.StripeError as e: if e.json_body and 'error' in e.json_body: err = e.json_body['error']