gpt4 book ai didi

php - Paypal IPN php脚本

转载 作者:太空宇宙 更新时间:2023-11-03 16:03:38 24 4
gpt4 key购买 nike

我刚刚意识到我在 php 中的 paypal ipn 处理程序不再工作(我什么也没改变),我使用 the sample php script provided by paypal.

我试图通过多次测试来隔离问题,此时我可以说问题不是“已验证”或“无效”,而是来自以下几行:

[...]

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);
}

?>

最佳答案

尝试在 x.xom 上使用更新后的脚本 https://www.x.com/instant-payment-notification-4

它使用 CURL 而不是 fsock

关于php - Paypal IPN php脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12651373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com