Paypal IPN读取变量- transaction[0].amount


Paypal IPN read variables - transaction[0].amount

我正在使用Paypal自适应支付,我正试图从我的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和send_email被正确读取,但是那个奇怪的事务[0]。金额返回未定义的索引错误!我知道这是作为事务%5B0%5D传递的。数量,但即使尝试替换字符串也会返回相同的错误!

PHP有数组数据的问题,参见https://github.com/paypal/sdk-core-php/blob/master/lib/ipn/PPIPNMessage.php#L45。请使用urldecode解码相应的数据

你必须在__construct的PPIPNMessage类中修复它。为两个参数添加urldecode

$this->ipnData[urldecode($keyValue[0])] = urldecode($keyValue[1]);

在master分支中已经修复了,但是在最后一个版本中还没有修复