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

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

also here is one more typo miss. request.GET.get('Id') (id → Id)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.