lingo: do not use assert to check important things (#19929)

This commit is contained in:
Frédéric Péters 2017-11-07 09:25:05 +01:00
parent 5c35c01baa
commit 9798ff4259
1 changed files with 6 additions and 4 deletions

View File

@ -394,11 +394,12 @@ class CallbackView(View):
}
for k, v in payment_response.bank_data.iteritems():
extra_info['eopayment_bank_data_' + k] = smart_text(v)
if not payment_response.result == eopayment.CANCELLED:
# cancellation are not signed...
if not payment_response.signed and not payment_response.result == eopayment.CANCELLED:
# we accept unsigned cancellation requests as some platforms do
# that :/
logger.warning(u'received unsigned payment response with id %s',
smart_text(payment_response.order_id), extra=extra_info)
assert payment_response.signed is True
return HttpResponseBadRequest('Unsigned payment response')
try:
transaction = Transaction.objects.get(order_id=payment_response.order_id)
@ -421,7 +422,8 @@ class CallbackView(View):
transaction.save()
# check if transaction belongs to right regie
assert transaction.regie == regie
if not transaction.regie == regie:
return HttpResponseBadRequest('Invalid payment regie')
if payment_response.result != eopayment.PAID:
return HttpResponse()