I have a e-commerce Django application that automatically verifies all incoming POST
requests with CSRF token using the CSRFViewMiddleware
.
Now, for payments, I'm using a payment gateway where I pass the relevant details along with the csrfmiddlewaretoken
so that it is returned back to me when the transaction on 3rd party site is complete. So, when the user is re-directed back to my site, I get a
403 Forbidden
CSRF verification failed. Request aborted.
How do I fix this? Is there any way I can manually check csrftoken
using request.POST.get('csrfmiddlewaretoken')
or something like that.
I would prefer not to bypass csrf totally as I want it to be secure (atleast, as much as possible).
Edit I understand csrfmiddleware
token needs to be passed in the header but I cannot do that as there are only limited things I can do with a 3rd party payment gateway.