简体   繁体   English

贝宝IPN PHP API

[英]PayPal IPN PHP API

So, no matter what I try to do, I seem to always get INVALID from my PayPal IPN process. 因此,无论我尝试做什么,我似乎总是从我的PayPal IPN流程中获得无效信息。 I have found other pages that have similar issues, however either the solution has not worked for me or it was not solved. 我发现其他页面也存在类似问题,但是该解决方案对我而言不起作用或未解决。

Here is my current php code: 这是我当前的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();

The MySQL queries are working fine, and in the database it's posting a -1 and a 0. Where my desire is for it to be posting a 1 and a 0 (This way is just temporary for my testing, I will be handling the transaction differently). MySQL查询工作正常,并且在数据库中发布了-1和0。我希望在数据库中发布1和0(这种方式对于我的测试只是临时的,我将处理事务不同地)。

I am using the INP simulator here: https://developer.paypal.com/developer/ipnSimulator/ 我在这里使用INP模拟器: https//developer.paypal.com/developer/ipnSimulator/

And supplying the correct url to where my php file is, as it is executing, but posting a -1 and 0 to the DB. 并提供正确的url到我的php文件所在的位置(正在执行),但向数据库发布-1和0。

Thanks for your time! 谢谢你的时间!

So it appears to me that this is an issue with PayPal's simulator specifically. 因此在我看来,这特别是贝宝(PayPal)模拟器的问题。 I have done even more research and found this post , where they mention that it works on live servers, but not within sandbox. 我进行了更多研究,发现这篇文章 ,他们提到该文章可在实时服务器上运行,但不能在沙盒中运行。 I really hate to make assumptions and to just assume it works and to push it, but if anyone else can confirm this is true, please let me know! 我真的很讨厌做假设,只是想假设它行得通,并加以推动,但是如果其他人可以确认这是真的,请告诉我! (btw this has been an issue on that github for almost 2 months now... quite incredible) (顺便说一句,这已经是该github上近2个月的问题了...相当不可思议)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM