我正在使用 Paypal Adaptive Payments,并且正在尝试从 IPN 侦听器中读取参数,但这并不是很简单。首先这是我的 IPN 监听器:
<?php
/**
* This is a sample implementation of an IPN listener
* that uses the SDK's PPIPNMessage class to process IPNs
*
* This sample simply validates the incoming IPN message
* and logs IPN variables. In a real application, you will
* validate the IPN and initiate some action based on the
* incoming IPN variables.
*/
require_once("paypal/samples/PPBootStrap.php");
$ipnMessage = new PPIPNMessage();
foreach($ipnMessage->getRawData() as $key => $value) {
error_log("IPN: $key => $value");
}
if($ipnMessage->validate()) {
error_log("Success: Got valid IPN data");
$receiver_email = $_POST['transaction[0].amount']; //DOES NOT WORK
//THIS TWO PARAMETERS ARE OK
$payment_status = $_POST['status'];
$sender_email = $_POST['sender_email'];
} else {
error_log("Error: Got invalid IPN data");
}
?>
status 和 sender_email 被正确读取,但是那个奇怪的 transaction[0].amount 返回未定义的索引错误!我知道这是作为 transaction%5B0%5D.amount 传递的,但即使尝试替换字符串也会返回相同的错误!