1

this is the call back URL which am getting from the payment gateway I am integrating with http://127.0.0.1:8000/checkout/mfsuccess/?paymentId=060630091021527961&Id=060630091021527961

I want to extract the paymentId int from this URL so I can use it in my function

this is the URL line am using

path('checkout/mfsuccess/?<str:paymentId>', gateway_Success, name='mf_success'),

and this is my function

def gateway_Success(request, id):
    payment_id = request.GET.get('id')
    print(payment_id)
    context = {
        "payment_id": payment_id
    }
    return render(request, "carts/checkout-mf-success.html")

How I do that since the way am doing not working I am getting the following error

Not Found: /checkout/mfsuccess/ [20/Nov/2020 03:38:59] "GET /checkout/mfsuccess/?paymentId=060630091121528060&Id=060630091121528060 HTTP/1.1" 404 4378

Fahd Mannaa
  • 295
  • 2
  • 7
  • Check if this answers your question - [multiple parameters url pattern django 2.0](https://stackoverflow.com/questions/51464131/multiple-parameters-url-pattern-django-2-0/56329703) – dmitryro Nov 20 '20 at 03:37

1 Answers1

1

You don't need to adjust your path() function to catch the URL query parameters

path('checkout/mfsuccess/', gateway_Success, name='mf_success'),

also, change your view as,


def gateway_Success(request):
    id_ = request.GET.get('Id') # retrieving the `Id`
    payment_id = request.GET.get('paymentId') # retrieving the `paymentId`
    context = {
        "payment_id": payment_id,
        "id_": id_
    }
    return render(request, "carts/checkout-mf-success.html", context=context)

This is enough to catch the redirection.

JPG
  • 82,442
  • 19
  • 127
  • 206