Django: unable to read POST parameters sent by payment gateway

前端 未结 2 1769
旧时难觅i
旧时难觅i 2021-01-28 05:33

I am unable to read POST parameters sent by payment gateway after payment was processed. Payment gateway redirects to returnUrl (I pass this to payment gateway befo

2条回答
  •  死守一世寂寞
    2021-01-28 05:56

    APPEND_SLASH shouldn't matter, as it only affects URLs that cannot be found, but you are explicitly specifying a URL pattern without a slash. So the issue is with your path definition.

    Assuming we are talking about the main, project-level urls.py, the correct setting would be:

    path('cashfreeresponse',views.cashfree_response, name='cashfree_response'),
    returnUrl = 'http://127.0.0.1:8000/cashfreeresponse'
    

    But my guess is that your path named cashfree_response is defined in an app (e.g. polls/urls.py) and that it is included at a subpath in the project-level (e.g. mysite/urls) like that:

    path('polls/', include('polls.urls')),
    

    In that case, the correct returnUrl would be http://127.0.0.1:8000/polls/cashfreeresponse.

    Instead of hard-coding the URL, you can use reverse together with request.

    from django.urls import reverse
    request.build_absolute_uri(reverse('cashfreeresponse')
    

    Note: You might have to use reverse(':cashfreeresponse') here, e.g. reverse('polls:cashfreeresponse')

    Edit: from your update, it seems like you still have a trailing slash in the path definition:

        path('cashfreeresponse/',views.cashfree_response, name='cashfree_response'),
    

    Change that to:

        path('cashfreeresponse',views.cashfree_response, name='cashfree_response'),
    

提交回复
热议问题