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].mount は未定義のインデックス エラーを返します! それが 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 に答える