From edd13a2b66dcda755fbb62476fd2b8b5c743bfe6 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Fri, 9 Oct 2020 10:38:14 +0200 Subject: [PATCH] lingo: return different message for cancelled transaction (#47497) --- combo/apps/lingo/views.py | 10 +++++++++- tests/test_lingo_payment.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/combo/apps/lingo/views.py b/combo/apps/lingo/views.py index f38e9c89..9a1b191c 100644 --- a/combo/apps/lingo/views.py +++ b/combo/apps/lingo/views.py @@ -958,7 +958,7 @@ class TransactionStatusApiView(View): return JsonResponse(data=data) if transaction.status in ( - eopayment.CANCELLED, eopayment.ERROR, eopayment.DENIED, EXPIRED + eopayment.ERROR, eopayment.DENIED, EXPIRED ): data = { 'wait': True, @@ -967,6 +967,14 @@ class TransactionStatusApiView(View): } return JsonResponse(data=data) + if transaction.status == eopayment.CANCELLED: + data = { + 'wait': True, + 'error': False, + 'error_msg': _('Payment cancelled, you can continue and make another payment') + } + return JsonResponse(data=data) + data = { 'wait': True, 'error': False, diff --git a/tests/test_lingo_payment.py b/tests/test_lingo_payment.py index ce653653..48c2645a 100644 --- a/tests/test_lingo_payment.py +++ b/tests/test_lingo_payment.py @@ -1443,6 +1443,21 @@ def test_transaction_status_api(app, regie, user): 'error_msg': '' } + # transaction cancelled + transaction = Transaction.objects.create( + amount=Decimal('10.0'), regie=regie, status=eopayment.CANCELLED + ) + url = reverse( + 'api-transaction-status', + kwargs={'transaction_signature': signing_dumps(transaction.pk)} + ) + resp = app.get(url) + assert resp.json == { + 'wait': True, + 'error': False, + 'error_msg': 'Payment cancelled, you can continue and make another payment' + } + def test_request_payment_exception(app, basket_page, regie, user): item = BasketItem.objects.create(user=user, regie=regie,