0

我正在使用 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 传递的,但即使尝试替换字符串也会返回相同的错误!

4

2 回答 2

0

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

于 2013-06-18T11:55:28.333 回答
0

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

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

它已在 master 分支中修复,但尚未在最后一个版本中修复

于 2015-08-07T14:26:27.033 回答