Add OrderPayment.fail() to prevent race conditions (#1572)

This commit is contained in:
Raphael Michel
2020-02-07 09:00:35 +01:00
committed by GitHub
parent 242dd24caa
commit 9984fe97ba
4 changed files with 45 additions and 113 deletions

View File

@@ -359,12 +359,7 @@ class Paypal(BasePaymentProvider):
return
if payment.state != 'approved':
payment_obj.state = OrderPayment.PAYMENT_STATE_FAILED
payment_obj.save()
payment_obj.order.log_action('pretix.event.order.payment.failed', {
'local_id': payment.local_id,
'provider': payment.provider,
})
payment_obj.fail(info=str(payment))
logger.error('Invalid state: %s' % str(payment))
raise PaymentException(_('We were unable to process your payment. See below for details on how to '
'proceed.'))