0001-lingo-raise-a-404-if-regie-or-payment-backend-is-not.patch
combo/apps/lingo/views.py | ||
---|---|---|
36 | 36 |
from django.contrib import messages |
37 | 37 |
from django.utils.translation import ugettext_lazy as _ |
38 | 38 |
from django.db.transaction import atomic |
39 |
from django.shortcuts import get_object_or_404 |
|
39 | 40 |
from django.utils.encoding import smart_text |
40 | 41 | |
41 | 42 |
import eopayment |
... | ... | |
525 | 526 |
class PaymentView(View): |
526 | 527 |
def handle_response(self, request, backend_response, **kwargs): |
527 | 528 |
if 'regie_pk' in kwargs: |
528 |
payment_backend = Regie.objects.get(id=kwargs['regie_pk']).payment_backend |
|
529 |
payment_backend = get_object_or_404( |
|
530 |
Regie, |
|
531 |
pk=kwargs['regie_pk'] |
|
532 |
).payment_backend |
|
529 | 533 |
elif 'payment_backend_pk' in kwargs: |
530 |
payment_backend = PaymentBackend.objects.get(id=kwargs['payment_backend_pk']) |
|
534 |
payment_backend = get_object_or_404( |
|
535 |
PaymentBackend, |
|
536 |
pk=kwargs['payment_backend_pk']) |
|
531 | 537 |
else: |
532 | 538 |
return HttpResponseBadRequest("A payment backend or regie primary key must be specified") |
533 | 539 |
tests/test_lingo_payment.py | ||
---|---|---|
1058 | 1058 |
assert BasketItem.objects.get(id=item.id).notification_date |
1059 | 1059 | |
1060 | 1060 | |
1061 |
def test_payment_callback_not_found(app, user, regie): |
|
1062 |
data = {'transaction_id': 42, 'signed': True, |
|
1063 |
'amount': 42, 'ok': True} |
|
1064 | ||
1065 |
callback_url = reverse('lingo-callback', kwargs={'regie_pk': 0}) |
|
1066 |
app.get(callback_url, params=data, status=404) |
|
1067 | ||
1068 |
callback_url = reverse('lingo-callback-payment-backend', kwargs={'payment_backend_pk': 0}) |
|
1069 |
app.get(callback_url, params=data, status=404) |
|
1070 | ||
1071 | ||
1061 | 1072 |
@pytest.mark.parametrize("authenticated", [True, False]) |
1062 | 1073 |
def test_payment_no_basket(app, user, regie, authenticated): |
1063 | 1074 |
url = reverse('api-add-basket-item') |
1064 |
- |