【发布时间】:2012-09-29 08:59:49
【问题描述】:
我刚刚意识到我在 php 中的 paypal ipn 处理程序不再工作(我什么也没做),我使用 the sample php script provided by paypal.
我尝试通过多次测试来隔离问题,此时我可以说问题不是“VERIFIED”或“INVALID”,而是来自以下几行:
[...]
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
// check the payment_status is Completed
[...]
有人知道paypal是否改变了某些东西或为什么它不起作用?
谢谢'
ps:如果我将代码放在所有 paypal 测试之前(“if (!$fp)”行之前),它就可以正常工作
这是我的代码,我评论了“数据库进程”在哪里工作,哪里不工作。
<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$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.sandbox.paypal.com', 443, $errno, $errstr, 30);
// assign posted variables to local variables
$payment_status = $_POST['payment_status'];
// DATABASE PROCESS WORKS (BEFORE THE PAYPAL TESTS)
if (!$fp)
{
// HTTP ERROR
}
else
{
// DATABASE PROCESS WORKS
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
// DATABASE PROCESS NOT WORKING
}
else if (strcmp ($res, "INVALID") == 0)
{
// log for manual investigation
// DATABASE PROCESS NOT WORKING
}
}
fclose ($fp);
}
?>
【问题讨论】:
-
你检查过关于这个问题的error_log吗?
-
请问如何查看error_log?
标签: php paypal handler paypal-ipn