0

对于我尝试从 Paypal 表单字段中分配给变量的任何帖子,我都会返回“未定义索引”,例如: $item_number = $_POST['item_number'];

如果我对其进行硬编码 $item_number = 1; 然后它工作。

我在下面使用 Micah Carrick 脚本:任何想法为什么会发生这种情况?

<?php
/*
ipn.php - example code used for the tutorial:

PayPal IPN with PHP
How To Implement an Instant Payment Notification listener script in PHP
http://www.micahcarrick.com/paypal-ipn-with-php.html

(c) 2011 - Micah Carrick
*/

// tell PHP to log errors to ipn_errors.log in this directory
ini_set('log_errors', true);
ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');

// intantiate the IPN listener
include('ipnlistener.php');
$listener = new IpnListener();

// tell the IPN listener to use the PayPal test sandbox
$listener->use_sandbox = true;

// try to process the IPN POST
try {
    $listener->requirePostMethod();
    $verified = $listener->processIpn();
} catch (Exception $e) {
    error_log($e->getMessage());
    exit(0);
}

if ($verified) {


$item_number = $_POST['item_number'];
$to = "myEmail@blah.com";
$subject = "Paypal IPN Test";
$message = "Email sent successfully";
$message .= $item_number;
mail($to,$subject,$message,$listener->getTextReport());


} 
else {
// manually investigate the invalid IPN
mail('myEmail@blah.com', 'Invalid IPN', $listener->getTextReport());
}

?>
4

1 回答 1

0

item_number仅当您在订单中将项目编号传递给 Paypal 时才存在。将其视为产品 ID 或 SKU。

如果您不需要产品标识符,请跳过它。

于 2013-05-17T15:20:45.623 回答