【发布时间】:2015-01-21 08:16:32
【问题描述】:
我可以使用 IPN 从贝宝获得已验证的答案 我通过 notify_url 从 PayPal 接收 POST 数据。然后我在数据前面使用 cmd=_notify-validate 将其发送回 PayPal。
使用 PayPals 记录的代码,我正在使用它向 PayPal 发送消息
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Host: www.sandbox.paypal.com\r\n";
$header.= "Content-Length: " . strlen($req) . "\r\n";
$header.= "Connection: Close\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
那我就用这个
if (!$fp) {
// HTTP ERROR;
} else {
var_dump(fputs($fp, $header . $req));
while (!feof($fp)) {
$res = stream_get_contents($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
//Transaction verified
}
}
}
事实上,我有两个 $res(由于 while 循环)。第一个似乎不感兴趣,第二个是
55 GMT
Connection: close
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dslingshot%26TIME%3D1273590100; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: Apache=10.72.128.11.1416751435364358; path=/; expires=Tue, 15-Nov-44 14:03:55 GMT
Vary: Accept-Encoding
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
8
VERIFIED
0
似乎第一部分是标题,第二部分(8 VERIFIED 0)是真正的响应,但为什么我有这个 0 和 8 ?通常人们使用
if (strcmp ($res, "VERIFIED") == 0) {
要检查 $res 是否已验证...所以我可以认为响应是“已验证”,使用类似
if(strstr($res,'VERIFIED')) {
请帮忙?!?
谢谢
【问题讨论】: