diff --git a/src/pretix/plugins/stripe/payment.py b/src/pretix/plugins/stripe/payment.py index 89ef28a39f..76cabb68eb 100644 --- a/src/pretix/plugins/stripe/payment.py +++ b/src/pretix/plugins/stripe/payment.py @@ -604,6 +604,17 @@ class StripeMethod(BasePaymentProvider): self._init_api() try: source = self._create_source(request, payment) + + except stripe.error.IdempotencyError as e: + # Same thing happening twice – we don't want to record a failure, as that might prevent the + # other thread from succeeding. + 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 'err' in e.json_body: err = e.json_body['error'] @@ -807,6 +818,16 @@ class StripeCC(StripeMethod): }) raise PaymentException(_('Stripe reported an error with your card: %s') % err['message']) + except stripe.error.IdempotencyError as e: + # Same thing happening twice – we don't want to record a failure, as that might prevent the + # other thread from succeeding. + 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'] @@ -1473,6 +1494,17 @@ class StripeWeChatPay(StripeMethod): self._init_api() try: source = self._create_source(request, payment) + + except stripe.error.IdempotencyError as e: + # Same thing happening twice – we don't want to record a failure, as that might prevent the + # other thread from succeeding. + 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 'err' in e.json_body: err = e.json_body['error']