0002-lingo-add-callback-through-payment-backend-s-slug-49.patch
combo/apps/lingo/views.py | ||
---|---|---|
25 | 25 |
from django.contrib.auth.models import User |
26 | 26 |
from django.core import signing |
27 | 27 |
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied |
28 |
from django.db.models.query import Q |
|
28 | 29 |
from django.db.transaction import atomic |
29 | 30 |
from django.http import ( |
30 | 31 |
Http404, |
... | ... | |
618 | 619 |
class PaymentView(View): |
619 | 620 |
def handle_response(self, request, backend_response, **kwargs): |
620 | 621 |
if 'regie_pk' in kwargs: |
621 |
payment_backend = get_object_or_404(Regie, pk=kwargs['regie_pk']).payment_backend |
|
622 |
try: |
|
623 |
regie_pk = int(kwargs['regie_pk']) |
|
624 |
except ValueError: |
|
625 |
regie_pk = None |
|
626 |
payment_backend = PaymentBackend.objects.filter(regie__pk=regie_pk).first() |
|
622 | 627 |
elif 'payment_backend_pk' in kwargs: |
623 |
payment_backend = get_object_or_404(PaymentBackend, pk=kwargs['payment_backend_pk']) |
|
628 |
payment_backend_slug = kwargs['payment_backend_pk'] |
|
629 |
try: |
|
630 |
payment_backend_pk = int(kwargs['payment_backend_pk']) |
|
631 |
except ValueError: |
|
632 |
payment_backend_pk = None |
|
633 |
payment_backend = PaymentBackend.objects.filter( |
|
634 |
Q(pk=payment_backend_pk) | Q(slug=payment_backend_slug) |
|
635 |
).first() |
|
624 | 636 |
else: |
625 |
return HttpResponseBadRequest("A payment backend or regie primary key must be specified") |
|
637 |
payment_backend = None |
|
638 | ||
639 |
if not payment_backend: |
|
640 |
logger.warning('lingo: payment backend not found on callback kwargs=%r', kwargs) |
|
641 |
raise Http404("A payment backend or regie primary key or slug must be specified") |
|
626 | 642 | |
627 | 643 |
payment = get_eopayment_object(request, payment_backend) |
628 | 644 |
logger.info(u'received payment response: %r', backend_response) |
629 |
- |