据我所知,截至2018年5月15日,PayPal网络系统已经发生了一些变化。我碰巧正在实现我的第一个IPN侦听器;而我不确定我是否因为我的资源(包括这样的帖子,一些可以追溯到2009年关于这个主题的帖子)被贝宝的变化所淘汰,或者仅仅因为我在这个领域缺乏经验。
我怀疑我指的是不正确的PayPal地址:
$fh = fsockopen('ssl://www.paypal.com',443,$errno,$errstr,30);
//$fh = fsockopen('https://www.sandbox.paypal.com',80,$errno,$errstr,30);
//$fh = fsockopen('https://ipnpb.sandbox.paypal.com/cgi-bin/webscr',80,$errno,$errstr,30);第一个地址在与PayPal的成功握手中完成,但返回无效的IPN响应。第二次握手,但不要通过if (!$fh)测试。
我尝试了以下两种代码,以及Chris的答案中的CURL代码:PayPal IPN returns invalid in sandbox
<?php
// Paypal IPN code
header('HTTP/1.1 200 OK'); // send header
$resp = 'cmd=_notify-validate';
foreach ($_POST as $parm => $var){
$var = urlencode(stripslashes($var));
$resp .= "&$parm=$var";
}
$httphead = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$httphead .= "Content-Type: application/x-www-form-urlencoded\r\n";
$httphead .= "Content-Length: " . strlen($resp) . "\r\n\r\n";
// create a ="file handle" for writing to a URL to paypal.com on Port 443 (the IPN port)
$errno ='';
$errstr='';
$fh = fsockopen('ssl://www.paypal.com',443,$errno,$errstr,30);
//$fh = fsockopen('https://www.sandbox.paypal.com',443,$errno,$errstr,30);
//$fh = fsockopen('https://ipnpb.sandbox.paypal.com/cgi-bin/webscr',443,$errno,$errstr,30);
if (!$fh) {
// if-fh does not work - cnxn FAILED
}
else{
// Connection opened, so spit back the response and get PayPal's view whether it was an authentic notification
fputs ($fh,$httphead.$resp);
while (!feof($fh)){
$readresp = fgets ($fh, 1024);
if (strcmp(trim($readresp),"VERIFIED") == 0){
// if-fh works - cnxn OPEN';
// WE ALL WIN!!
}
else if(strcmp(trim($readresp),"INVALID") == 0){
// A possible hacking attempt, or
// In my case, a possible hacking false-positive
}
}
fclose ($fh);
}
?>我正在使用我的沙箱帐户中的IPN模拟器进行测试。
这些建议的解决办法都没有奏效。
请帮帮我!
发布于 2018-06-21 10:29:54
为了记录在案,这个url似乎运行良好:https://www.paypal.com/cgi-bin/webscr
https://stackoverflow.com/questions/50415114
复制相似问题