2011-12-10 27 views
1

私は数日間立ち往生しました!私はPayPal IPNからの詳細を並行支払いで取得しようとしています。PayPal Parallel Payment IPN

お金が送られた2つのメールアドレスとその金額、ステータスも必要です。

私はここで探しています:

$Email1 = $_POST['transaction[0].receiver']; 
$Email2 = $_POST['transaction[1].receiver']; 

と量の部分:

$Amount1 = $_POST['transaction[0].amount']; 
$Amount2 = $_POST['transaction[1].amount']; 

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_APIPN

これらは私がしようとすると、電子メールや量を取得する私のコードの行は、

私はこのページのIPNコードを使用しています。

https://cms.paypal.com/cms_content/AU/en_AU/files/developer/IPN_PHP_41.txt

任意のヘルプ? POST変数が空白になりますか?


更新:

<source lang="php"> 
<?php 
error_reporting(E_ALL^E_NOTICE); 
// By Gleb Esman, [email protected], http://www.memberwing.com/ 
// 
// Pull raw POST data. 
// We need to pull raw data and build our own copy of $_POST in order to 
// workaround of invalid POST keys that Adaptive IPN request uses. 

$raw_post_data = file_get_contents('php://input'); 
$raw_post_array = explode('&', $raw_post_data); 
$_YOUR_POST = array(); 
foreach ($raw_post_array as $keyval) { 
    $keyval = explode('=', $keyval); 
    if (count($keyval) == 2) 
    $_YOUR_POST[$keyval[0]] = urldecode($keyval[1]); 
} 
if (count($_YOUR_POST) < 3) { 
    $_YOUR_POST = $_POST; 
    $original_post_used = TRUE; 
} 
else 
    $original_post_used = FALSE; 

// Build final $_req postback request 
// Paypal's IPN Sample 
// read the post from PayPal system and add 'cmd' 

if ($original_post_used) { 
    $_req = 'cmd=_notify-validate'; 
    foreach ($_YOUR_POST as $key => $value) { 
    $value = urlencode(stripslashes($value)); 
    $_req .= "&$key=$value"; 
    } 
} 
else 
    $_req = $raw_post_data . '&cmd=_notify-validate'; 
// $_req is ready for postback to Paypal here... 
$req = $_req; 

//////////////////////////////////////////////////////////////////////////////// 
//////////////////////////////////////////////////////////////////////////////// 
//////////////////////////////////////////////////////////////////////////////// 
//////////////////////////////////////////////////////////////////////////////// 



// PHP 4.1 
// read the post from PayPal system and add 'cmd' 
//$req = 'cmd=_notify-validate'; 
// 
//foreach ($_POST as $key => $value) { 
// $value = urlencode(stripslashes($value)); 
// $req .= "&$key=$value"; 
//} 

// post back to PayPal system to validate 
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; 
$header .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; 
$fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30); 

// throw all this junk into the local error log so we can see what happened! 
function log_arr($item, $key) { 
    $p .= "$key = $item"; 
    error_log(urldecode($p)); 
} 
array_walk_recursive($_YOUR_POST, 'log_arr'); 
error_log(urldecode($req)); 

// assign posted variables to local variables 
$item_name = $_POST['item_name']; 
$item_number = $_POST['item_number']; 
$payment_status = $_POST['payment_status']; 
$payment_amount = $_POST['mc_gross']; 
$payment_currency = $_POST['mc_currency']; 
$txn_id = $_POST['txn_id']; 
$receiver_email = $_POST['receiver_email']; 
$payer_email = $_POST['payer_email']; 

if (!$fp) { 
// HTTP ERROR 
} else { 
    fputs($fp, $header . $req); 
    while (!feof($fp)) { 
    $res = fgets($fp, 1024); 
    if (strcmp($res, "VERIFIED") == 0) { 
// check the payment_status is Completed 
// check that txn_id has not been previously processed 
// check that receiver_email is your Primary PayPal email 
// check that payment_amount/payment_currency are correct 
// process payment 
    } else if (strcmp($res, "INVALID") == 0) { 
// log for manual investigation 
    } 
    } 
    fclose($fp); 
} 
?> 
</source> 

ログファイルにこれを生成する:私はこの見つけました

[10-Dec-2011 07:13:50] transaction[0].id_for_sender_txn = xxxxx 
[10-Dec-2011 07:13:50] log_default_shipping_address_in_transaction = xxx 
[10-Dec-2011 07:13:50] transaction[0].receiver = xxxxx 
[10-Dec-2011 07:13:50] action_type = xxxx 

[10-Dec-2011 07:13:50] transaction[1].paymentType = xxx 
[10-Dec-2011 07:13:50] transaction[0].amount = xxxx 
[10-Dec-2011 07:13:50] charset = xxx 

を誰もこれが何であるかであるとして変数にこれらを取得する方法を教えてもらえますログファイルに出力されますか?

答えて

0

$_POST['transaction']['0']['receiver']などを試してください。また、E_ALLエラーメッセージを有効にして、このようなことに関する通知が表示されるようにしてください。これらが有効になっていて、エラーログを確認した場合、未定義のインデックス通知が表示されます。また、$_POST/$_GET/whateverのものをデバッグすることが必死なら、リクエストを制御するのではなく、いつでもファイルに内容を書き込んで調べることができます。

+0

はい、それ以前に試してみてうまくいかなかった。 URL: [10-Dec-2011 06:18:47] PHPの警告:urlencode()は、パラメータ1が文字列、array 22のxxxxxxxxの配列を期待しています。 – user1091108

+0

あなたは$ _YOUR_POSTを配列として構築しています数行先にして、それを文字列として使用しようとしています。私はhttp_build_queryが役に立つかもしれないと思っています。 – Corbin