lingo: add callback through payment backend's slug (#49145)
This commit is contained in:
parent
2bfb96ea95
commit
a8676ab897
|
@ -25,6 +25,7 @@ from django.contrib import messages
|
|||
from django.contrib.auth.models import User
|
||||
from django.core import signing
|
||||
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
from django.db.models.query import Q
|
||||
from django.db.transaction import atomic
|
||||
from django.http import (
|
||||
Http404,
|
||||
|
@ -611,11 +612,26 @@ class BasketItemPayView(PayMixin, View):
|
|||
class PaymentView(View):
|
||||
def handle_response(self, request, backend_response, *, callback=True, transaction=None, **kwargs):
|
||||
if 'regie_pk' in kwargs:
|
||||
payment_backend = get_object_or_404(Regie, pk=kwargs['regie_pk']).payment_backend
|
||||
try:
|
||||
regie_pk = int(kwargs['regie_pk'])
|
||||
except ValueError:
|
||||
regie_pk = None
|
||||
payment_backend = PaymentBackend.objects.filter(regie__pk=regie_pk).first()
|
||||
elif 'payment_backend_pk' in kwargs:
|
||||
payment_backend = get_object_or_404(PaymentBackend, pk=kwargs['payment_backend_pk'])
|
||||
payment_backend_slug = kwargs['payment_backend_pk']
|
||||
try:
|
||||
payment_backend_pk = int(kwargs['payment_backend_pk'])
|
||||
except ValueError:
|
||||
payment_backend_pk = None
|
||||
payment_backend = PaymentBackend.objects.filter(
|
||||
Q(pk=payment_backend_pk) | Q(slug=payment_backend_slug)
|
||||
).first()
|
||||
else:
|
||||
return HttpResponseBadRequest("A payment backend or regie primary key must be specified")
|
||||
payment_backend = None
|
||||
|
||||
if not payment_backend:
|
||||
logger.warning('lingo: payment backend not found on callback kwargs=%r', kwargs)
|
||||
raise Http404("A payment backend or regie primary key or slug must be specified")
|
||||
|
||||
payment = payment_backend.make_eopayment(request=request)
|
||||
logger.info(u'received payment response: %r', backend_response)
|
||||
|
|
Loading…
Reference in New Issue