I read PayPal IPN & amp; PDT After some headache & amp; Time in the sandbox, the IPN is working well and PDT gives the correct $ _GET data.
Everything works well, it is incomparable that using PHP code ready for PDT If there has been a return post, hung page. The user never goes back to my site. I can not find a failed situation, just nothing. The strange thing is that after an unknown error, my test domain becomes unresponsive for a short period.
Code (PHP):
If I comment back to the post, then all works fine until the code enters the loop { Unfortunately, I have not had enough experience to write a replacement from scratch for the PayPal code, so any idea about what is actually going to be wrong will be appreciated.
The post goes back to the SSL: //www.sandbox .paypal.com, and I am using the button code and an authorization token that are created through all the sandbox test accounts.
Thanks in advance.
Update:
I have narrowed this problem down to this line: $ line = fgets ($ fp, 1024);
And I'm not sure why.
Resolved:
switch to curl The problem solves all problems here, when it comes to someone and it is as frustrating as I was:
// create the data $ req = 'cmd = _notify -synch '; $ Tx_token = $ _GET ['tx']; $ Auth_token = '& lt; - Your token (sandbox or live) - & gt; '; $ Req. = '& Amp; Tx = '. $ Tx_token '& Amp; At = '. $ Auth_token; To validate $ // c = curl_init, post back to PayPal ('https://www.sandbox.paypal.com/cgi-bin/webscr'); // SANDBOX curl_setopt ($ c, CURLOPT_POST, true); Curl_setopt ($ c, CURLOPT_POSTFIELDS, $ req); Curl_setopt ($ c, CURLOPT_RETURNTRANSFER, true); $ Content = curl_xac ($ c); $ Response_code = curl_getinfo ($ c, CURLINFO_HTTP_CODE); Curl_close ($ c); If (! $ Contents || $ response_code! = 200) {// HTTP error or poor response, do something} Other {// Check PayPal verification (unsuccessful or successful) $ status = substr ($ contents, 0, 4); {$ Status == 'FAIL'} {// Do fail stuff} elseif ($ status == 'SUCC') {// success}}
Technically, Substr () is not checking "success", but "SUCC" does not make any difference, however, given that there are only possible "success" or "unsuccessful" possible values.
This same code also works for the IPN, as well as with a slight modification.
Comments
Post a Comment