lingo: handle exceptions raised by backend.request (#40244)
This commit is contained in:
parent
72fe08ea5e
commit
271e13b680
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
2
setup.py
2
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',
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue