[英]PayPal IPN PHP API
因此,无论我尝试做什么,我似乎总是从我的PayPal IPN流程中获得无效信息。 我发现其他页面也存在类似问题,但是该解决方案对我而言不起作用或未解决。
这是我当前的php代码:
include_once($_SERVER['DOCUMENT_ROOT']."/api/static.php");
include_once($_SERVER['DOCUMENT_ROOT']."/api/api.php");
$req = 'cmd=_notify-validate';
foreach($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if(!$fp) {
//There was an error.
$mccubedConnection->query("replace into testing (result) values (-2);");
} else {
fputs($fp, $header . $req);
while(!feof($fp)) {
$res = fgets($fp, 1024);
if(strcmp($res, "VERIFIED") == 0) {
//Valid
$mccubedConnection->query("replace into testing (result) values (1);");
} else if(strcmp($res, "INVALID") == 0) {
//Invalid
$mccubedConnection->query("replace into testing (result) values (-1);");
}
} fclose($fp);
}
$mccubedConnection->query("replace into testing (result) values (0);");
$mccubedConnection->close();
MySQL查询工作正常,并且在数据库中发布了-1和0。我希望在数据库中发布1和0(这种方式对于我的测试只是临时的,我将处理事务不同地)。
我在这里使用INP模拟器: https : //developer.paypal.com/developer/ipnSimulator/
并提供正确的url到我的php文件所在的位置(正在执行),但向数据库发布-1和0。
谢谢你的时间!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.