First try at working around Stripe's iDEAL idempotency issues

This commit is contained in:
Martin Gross
2020-08-28 23:21:35 +02:00
parent eba17e22fb
commit 8ea66bc05b

View File

@@ -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']