Fix #248 -- Failed Payment error handling (#333)

* [WIP] Failed Payment error handling

When finished, this should fix #248

* rename PaymentFailedException to PaymentException\nimported Exception where neccessary

* comments fixed

* minor style fixes

* Fixed a name error
This commit is contained in:
Jakob Schnell
2017-02-24 14:11:41 +01:00
committed by Raphael Michel
parent 8e4b71eb19
commit c251a48e31
5 changed files with 43 additions and 26 deletions

View File

@@ -337,9 +337,7 @@ class BasePaymentProvider:
The default implementation just returns ``None`` and therefore leaves the
order unpaid. The user will be redirected to the order's detail page by default.
On errors, you should use Django's message framework to display an error message
to the user.
On errors, you should raise a ``PaymentException``.
:param order: The order object
"""
return None
@@ -483,6 +481,10 @@ class BasePaymentProvider:
'back to the buyer manually.'))
class PaymentException(Exception):
pass
class FreeOrderProvider(BasePaymentProvider):
@property
@@ -511,7 +513,7 @@ class FreeOrderProvider(BasePaymentProvider):
try:
mark_order_paid(order, 'free', send_mail=False)
except Quota.QuotaExceededException as e:
messages.error(request, str(e))
raise PaymentException(str(e))
@property
def settings_form_fields(self) -> dict: