I’m struggling with a weird issue in my React and Django project hosted on Render. When I try to start a PayPal payment, I get a 404 error. Here’s what I’ve checked:
The URL for the payment is set up correctly in Django
No syntax errors in the React code
CORS policy is fine
Frontend URL is in the allowed origins
REACT_BASE_URL is set correctly in settings.py and views.py
I’m using PayPal’s Sandbox mode. The client ID and secret are stored as environment variables on Render. Here’s a snippet of how I’m accessing them:
hmm, have u checked the network tab in your dev tools? it might show why you’re getting a 404. also, ensure your paypal endpoint is hit, and maybe add console.logs. curious, does it fail with another gateway too?
Have you double-checked your Django URL patterns? Sometimes, a 404 error can occur if the URL routing isn’t set up correctly. It might be worth reviewing your urls.py file to ensure the payment endpoint is properly defined and matches what you’re calling from the React app.
Another potential issue could be with how the PayPal SDK is integrated. Make sure you’re using the latest version and that it’s properly initialized in your React component. Also, verify that the PayPal button is rendering correctly and that you’re handling the onApprove callback appropriately.
Lastly, have you tried testing the Django endpoint separately using a tool like Postman? This could help isolate whether the issue is on the frontend or backend. If it works in Postman but not in your app, it might point to a problem with how the request is being sent from React.
hey, have u tried checking ur server logs? sometimes they can show more details about the 404 error. also, make sure ur django view for handling paypal requests is actually being called. u could add some print statements or logging to confirm. might be worth double-checking ur render deployment settings too, just in case something’s off there.