我使用以下代码将PayPal支付系统集成到我的网站,付款后,即使一切顺利,我也收到以下通知和“付款失败”。PayPal付款请求通知:未定义索引
Notice: Undefined index: item_name in /Applications/XAMPP/xamppfiles/htdocs/payment/success.php on line 2
Notice: Undefined index: tx in /Applications/XAMPP/xamppfiles/htdocs/payment/success.php on line 3
Notice: Undefined index: amount in /Applications/XAMPP/xamppfiles/htdocs/payment/success.php on line 4
Notice: Undefined index: currency_code in /Applications/XAMPP/xamppfiles/htdocs/payment/success.php on line 5
Payment Failed
我使用下面的代码来创建付款按钮
<div class="btn">
<form action="<?php echo $paypal_url ?>" method="post" name="frmPayPal1">
<input type="hidden" name="business" value="<?php echo $paypal_id ?>">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_name" value="20Percents (12 Credits)">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="credits" value="12">
<input type="hidden" name="userid" value="1">
<input type="hidden" name="amount" value="10">
<input type="hidden" name="cpp_header_image" value="http://20percents.com/wp-content/uploads/2014/06/logo-1.png">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="handling" value="0">
<input type="hidden" name="cancel_return" value="http://localhost/payment/cancel.php">
<input type="hidden" name="return" value="http://localhost/payment/success.php">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
而且,下面的代码来验证支付:
<?php
$item_name = $_GET['item_name']; // I also tried $_REQUEST['item_name']; instead
$item_transaction = $_GET['tx']; // Paypal transaction ID
$item_price = $_GET['amount']; // Paypal received amount
$item_currency = $_GET['currency_code']; // Paypal received currency type
$price = '10.00';
$currency='USD';
//Rechecking the product price and currency details
if($item_price==$price && $item_currency==$currency)
{
$content = "<h1>Welcome, Guest</h1>";
$content .= "<h1>Payment Successful</h1>";
}
else
{
$content = "<h1>Payment Failed</h1>";
}
?>
我不知道为什么我收到这些通知,任何帮助,高度赞赏。谢谢
不,不工作。仍然是同样的问题。 – lock 2014-08-28 05:52:33
你改变了什么? – arunrc 2014-08-28 05:55:18
尝试了两种方法,尝试更改方法来使用get函数,没有工作,并尝试post方法,并试图使用$ _post ['item_name'],这也没有工作。同样的问题 – lock 2014-08-28 05:59:26