forked from CGM_Public/pretix_original
Stripe: Handle IdempotencyError in more places
This commit is contained in:
@@ -604,6 +604,17 @@ class StripeMethod(BasePaymentProvider):
|
|||||||
self._init_api()
|
self._init_api()
|
||||||
try:
|
try:
|
||||||
source = self._create_source(request, payment)
|
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:
|
except stripe.error.StripeError as e:
|
||||||
if e.json_body and 'err' in e.json_body:
|
if e.json_body and 'err' in e.json_body:
|
||||||
err = e.json_body['error']
|
err = e.json_body['error']
|
||||||
@@ -807,6 +818,16 @@ class StripeCC(StripeMethod):
|
|||||||
})
|
})
|
||||||
raise PaymentException(_('Stripe reported an error with your card: %s') % err['message'])
|
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:
|
except stripe.error.StripeError as e:
|
||||||
if e.json_body and 'error' in e.json_body:
|
if e.json_body and 'error' in e.json_body:
|
||||||
err = e.json_body['error']
|
err = e.json_body['error']
|
||||||
@@ -1473,6 +1494,17 @@ class StripeWeChatPay(StripeMethod):
|
|||||||
self._init_api()
|
self._init_api()
|
||||||
try:
|
try:
|
||||||
source = self._create_source(request, payment)
|
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:
|
except stripe.error.StripeError as e:
|
||||||
if e.json_body and 'err' in e.json_body:
|
if e.json_body and 'err' in e.json_body:
|
||||||
err = e.json_body['error']
|
err = e.json_body['error']
|
||||||
|
|||||||
Reference in New Issue
Block a user