0
我一直在遇到問題,當我嘗試從貝寶獲取返回數據。 我在我的Paypal帳戶和表單上設置了Retrun Url。這是表單,這僅用於測試目的。如何獲得貝寶Chekout返回數據
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="_xclick">
<div align="center">
<input type="hidden" name="return" value="http://{host}/paypal/tnk.php" />
<input type="hidden" name="cancel_return" value="http://{host}/paypal/tnk.php" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" value="_xclick" name="cmd">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="Paypal 2015">
<input type="hidden" name="item_number" value="123">
<input type="hidden" name="amount" value="10">
<input type="hidden" name="first_name" value="Test">
<input type="hidden" name="last_name" value="Last Name">
<input type="hidden" name="city" value="">
<input type="hidden" name="state" value="">
<input type="hidden" name="email" value="">
<input type="hidden" name="image_url"">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="notify_url" value="http://{host}/paypal/tnk.php">
<input type="submit" value="Proceed To Pay">
</div>
</form>
當我點擊「繼續付款」,我重定向到貝寶,我可以支付價格。 在返回頁面上,我已經把一個文件寫入了Paypal的所有返回數據。
$post = array('cmd' => '_notify-validate');
foreach($_POST as $key=>$value){
$post[$key] = $value;
$file = fopen("test.txt","w+");
echo fwrite($file,print_r($_POST));
fclose($file);
}
$c = curl_init();
curl_setopt_array($c, array(
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_CONNECTTIMEOUT => 15,
CURLOPT_MAXREDIRS => 15,
CURLOPT_TIMEOUT => 15,
CURLOPT_URL => 'https://www.paypal.com/cgi-bin/webscr',
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $post,
));
$res = curl_exec($c);
curl_close($c);
$res = trim($res);
if($res != 'VERIFIED') {
exit();
}
但它只在文本文件上寫入值1。 這意味着返回的網址是owrking,但貝寶沒有返回任何關於$_REQUEST
的數據。
我做錯了什麼?有點困惑,並嘗試了幾種方法。 希望我已經提供了足夠的細節。
請幫我解決這個問題。 在此先感謝。
我已經將錯過的字段添加到文件,但仍在文本文件上打印1。我用最新的代碼編輯了我的問題。你能幫我解決嗎? –
只需使用我的表單發佈!在你的表單中,你有無效的字段,如first_name和last_name! – Pavel