piano0011 Posted July 4, 2018 Share Posted July 4, 2018 Hey guys! I have been following a video by passive code income on how to implement ipn simulator but I keep getting the message invalid from 000webhost.. Here is my code: <?php if ($_SERVER['REQUEST_METHOD'] != 'POST') { header("Location: index.php"); exit(); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST)); $response = curl_exec($ch); curl_close($ch); file_put_contents("test.txt", $response); Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/ Share on other sites More sharing options...
mac_gyver Posted July 4, 2018 Share Posted July 4, 2018 this is likely due to a + near the end of the payment date for the time zone, and when you use http_build_query() on the data, this gets treated as is (a space), rather than a literal + , which should end up being a %2B urlencoded value. you should log the received $_POST data so that you can see what it is. if the payment date looks like - Wed+Jul+4+2018+10%3A15%3A11+GMT+0000, you will need to handle the last + differently in the code. next, either use or examine the 'official' php paypal listener code, to see how the + near the end of the payment date gets treated - https://github.com/paypal/ipn-code-samples/tree/master/php Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/#findComment-1559236 Share on other sites More sharing options...
requinix Posted July 4, 2018 Share Posted July 4, 2018 Everything I remember about IPN says just to send them back the data verbatim. As in "cmd=_notify-validate&" . file_get_contents("php://input") I assume their code is so complicated (note that it urldecodes in one loop then urlencodes in the next) because it's trying to handle magic_quotes. Which doesn't exist anymore. Plus I can count at least four significant problems with it. Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/#findComment-1559237 Share on other sites More sharing options...
piano0011 Posted July 5, 2018 Author Share Posted July 5, 2018 Thanks for the reply. So, do you think that the code does not work? Maybe, I should try using a sandbox account instead? Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/#findComment-1559241 Share on other sites More sharing options...
piano0011 Posted July 5, 2018 Author Share Posted July 5, 2018 I am also wondering can someone try out the code on their server to check and see whether it is working or not? It must be an old video by passing income.. Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/#findComment-1559271 Share on other sites More sharing options...
requinix Posted July 5, 2018 Share Posted July 5, 2018 7 hours ago, piano0011 said: Thanks for the reply. So, do you think that the code does not work? Maybe, I should try using a sandbox account instead? You aren't already? Your code says you should be using the sandbox. The very fact that you're testing this means you should be using the sandbox. Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/#findComment-1559277 Share on other sites More sharing options...
piano0011 Posted July 6, 2018 Author Share Posted July 6, 2018 Ah... maybe that is why it didn't work! According to the video tutorial, he didn't say to use sandbox account.... I don't think he did.. Quote Link to comment https://forums.phpfreaks.com/topic/307438-ipn-simulator-not-working-on-000webhost/#findComment-1559287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.