New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RawPostDataException when trying to test IPN #79
Comments
You'll need to paste the complete traceback. Thanks! I suspect you have something (e.g. middleware or custom view logic) that is reading the request data, instead of letting the ipn view do that. You can use the PayPal sandbox and something like ngrok to test locally. |
I can't do anything without a traceback, so closing. Please reopen if you can provide more information. |
I just encountered the same issue and would like to share my insights and the workaround. tl;dr client = django.test.Client()
client.post(reverse('paypal-ipn'), data=ipn_data, content_type='application/x-www-form-urlencoded') I found the issue encode/django-rest-framework#2774 extremely useful when debugging. It is mentioned by Preston Holmes in a comment that Django prevents reading a body of a request with the While I'm fairly happy with the workaround, I'd hate to waste other users' time. So I would suggest we either:
@spookylukey please let me know if you'd like to see a PR for either. On a side note, it would be very helpful if Django docs mention the above behavior. I could not find mention of this anywhere besides this related middleware warning. Though the docstring added in this commit is very informative; I would go ahead and copy paste this directly to a warning in |
Given that the PayPal docs explicitly show x-www-form-urlencoded (see https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#a-sample-ipn-message-and-response ) I think the best option here is to first check that the Content-Type matches that, and raise an exception otherwise. This avoids using internals like |
@spookylukey thanks for the quick response. I honestly couldn't find any mention (in quoted docs or any others) of the headers paypal sends. Right now however, the value of |
Is there a possibility this was changes recently? The server is getting many errors on the live server: |
@jTiKey If PayPal changed the data to no longer match what their docs show - https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/#a-sample-ipn-message-and-response - then you should take it up with them. I don't know if they have changed anything recently. |
I am using the chrome plugin Postman to try and test the IPN callback on my localhost. When posting to the callback URL I am getting a RawPostDataException error "You cannot access body after reading from request's data stream"
Am I doing something wrong here or is there a better why to test the IPN callback locally? Thanks
The text was updated successfully, but these errors were encountered: