对于我尝试从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());
}
?>
答案 0 :(得分:0)
item_number
仅在您将订单中的商品编号传递给Paypal时才存在。将其视为产品ID或SKU。
如果您不需要产品的标识符,请跳过它。