我有一个脚本,可以使用 BusinessID 和令牌通过表单向 PayPal 提交付款。显然它仍然适用于美国的 PayPal,但我在澳大利亚的一位客户表示,PayPal 告诉他们这种方法不再有效。在阅读文档时,我发现现在可能需要 BusinessID、密码和签名。使用 IPN 流程的 API 发生了什么变化,我的客户需要在他们的帐户中设置哪些步骤才能使其正常工作。感谢任何帮助以使我的代码适应新标准。
我的旧表格:
<? if ($test == "1"){ ?>
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<?} else {?>
<form action="https://www.paypal.com/us/cgi-bin/webscr" method="post" name="_xclick" id="_xclick">
<? } ?>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?=$businessid;?>">
<input type="hidden" name="notify_url" value="<?=$SITE_URL;?>/notify_payment.php?tx= <?=$test;?>">
<input type="hidden" name="return" value="<?=$SITE_URL;?>/thankyou.php?px=<?=base64_encode($bid);?>">
<input type="hidden" name="cancel_return" value="<?=$SITE_URL;?>/buybidsunsuccess.php">
<input type="hidden" name="currency_code" value="AUD" />
<input type="hidden" name="item_name" value="<?=$bidpackname;?>">
<input type="hidden" name="amount" value="<?=$amt;?>">
<input type="hidden" name="custom" value="<?=$bid."_".$uid;?>" >
还有我的 IPN 页面:
$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";
if ($test =="1") {
$fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
}
else
{
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
}
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
// custom varible
$invoice_id = $_POST['invoice_id'];
//retrieve payment status
$payment_status = $_POST['payment_status'];
$customvar = $_POST["custom"];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {