Bank transfer: Do not cause duplicate payments

This commit is contained in:
Raphael Michel
2019-11-21 17:22:11 +01:00
parent 808ccfee75
commit 2be49d8cab
+11 -15
View File
@@ -111,26 +111,22 @@ class ActionView(View):
} }
try: try:
p.confirm(user=self.request.user) p.confirm(user=self.request.user)
except Quota.QuotaExceededException as e: except Quota.QuotaExceededException:
return JsonResponse({ pass
'status': 'error',
'message': str(e)
})
except SendMailException: except SendMailException:
return JsonResponse({ return JsonResponse({
'status': 'error', 'status': 'error',
'message': _('Problem sending email.') 'message': _('Problem sending email.')
}) })
else: trans.state = BankTransaction.STATE_VALID
trans.state = BankTransaction.STATE_VALID trans.save()
trans.save() trans.order.payments.filter(
trans.order.payments.filter( provider='banktransfer',
provider='banktransfer', state__in=(OrderPayment.PAYMENT_STATE_CREATED, OrderPayment.PAYMENT_STATE_PENDING),
state__in=(OrderPayment.PAYMENT_STATE_CREATED, OrderPayment.PAYMENT_STATE_PENDING), ).update(state=OrderPayment.PAYMENT_STATE_CANCELED)
).update(state=OrderPayment.PAYMENT_STATE_CANCELED) return JsonResponse({
return JsonResponse({ 'status': 'ok',
'status': 'ok', })
})
def _assign(self, trans, code): def _assign(self, trans, code):
try: try: