diff --git a/combo/apps/lingo/views.py b/combo/apps/lingo/views.py index d9a21feb..f7a6e235 100644 --- a/combo/apps/lingo/views.py +++ b/combo/apps/lingo/views.py @@ -397,8 +397,13 @@ class PayMixin(object): kwargs['capture_date'] = capture_date if regie.transaction_options: kwargs.update(regie.transaction_options) - (order_id, kind, data) = payment.request(total_amount, **kwargs) logger = logging.getLogger(__name__) + try: + (order_id, kind, data) = payment.request(total_amount, **kwargs) + except eopayment.PaymentException as e: + logger.error('failed to initiate payment request: %s', e) + messages.error(request, _('Failed to initiate payment request')) + return HttpResponseRedirect(get_payment_status_view(next_url=next_url)) logger.info(u'emitted payment request with id %s', smart_text(order_id), extra={ 'eopayment_order_id': smart_text(order_id), 'eopayment_data': repr(data)}) transaction.order_id = order_id diff --git a/debian/control b/debian/control index 7b27f336..240e56fc 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,7 @@ Depends: ${misc:Depends}, ${python3:Depends}, python3-xstatic-leaflet-markercluster, python3-xstatic-opensans, python3-xstatic-roboto-fontface (>= 0.5.0.0), - python3-eopayment (>= 1.35), + python3-eopayment (>= 1.43), python3-django-ratelimit, python3-sorl-thumbnail, python3-pil, diff --git a/setup.py b/setup.py index 19b94544..403c8f47 100644 --- a/setup.py +++ b/setup.py @@ -160,7 +160,7 @@ setup( 'XStatic_JosefinSans', 'XStatic_OpenSans', 'XStatic_roboto-fontface>=0.5.0.0', - 'eopayment>=1.41', + 'eopayment>=1.43', 'python-dateutil', 'djangorestframework>=3.3, <3.7', 'django-ratelimit<3', diff --git a/tests/test_lingo_payment.py b/tests/test_lingo_payment.py index 4b54e638..3639996b 100644 --- a/tests/test_lingo_payment.py +++ b/tests/test_lingo_payment.py @@ -1269,3 +1269,15 @@ def test_transaction_status_api(app, regie, user): 'error': False, 'error_msg': '' } + + +def test_request_payment_exception(app, basket_page, regie, user): + item = BasketItem.objects.create(user=user, regie=regie, + subject='test_item', amount='10.5', + source_url='http://example.org/testitem/') + + with mock.patch('eopayment.dummy.Payment.request', autospec=True) as mock_request: + mock_request.side_effect = eopayment.PaymentException + resp = login(app).get(basket_page.get_online_url()) + resp = resp.form.submit().follow() + assert 'Failed to initiate payment request' in resp.text