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

@@ -8,6 +8,7 @@ from django.utils.timezone import now
from stripe import APIConnectionError, CardError, StripeError
from pretix.base.models import Event, Order, Organizer
from pretix.base.payment import PaymentException
from pretix.plugins.stripe.payment import Stripe
@@ -92,7 +93,8 @@ def test_perform_card_error(env, factory, monkeypatch):
req.session = {}
prov.checkout_prepare(req, {})
assert 'payment_stripe_token' in req.session
prov.payment_perform(req, order)
with pytest.raises(PaymentException):
prov.payment_perform(req, order)
order.refresh_from_db()
assert order.status == Order.STATUS_PENDING
@@ -114,7 +116,8 @@ def test_perform_stripe_error(env, factory, monkeypatch):
req.session = {}
prov.checkout_prepare(req, {})
assert 'payment_stripe_token' in req.session
prov.payment_perform(req, order)
with pytest.raises(PaymentException):
prov.payment_perform(req, order)
order.refresh_from_db()
assert order.status == Order.STATUS_PENDING
@@ -140,7 +143,8 @@ def test_perform_failed(env, factory, monkeypatch):
req.session = {}
prov.checkout_prepare(req, {})
assert 'payment_stripe_token' in req.session
prov.payment_perform(req, order)
with pytest.raises(PaymentException):
prov.payment_perform(req, order)
order.refresh_from_db()
assert order.status == Order.STATUS_PENDING