我在我的网站上使用paypal标准代码但是在成功付款后我没有获得有关成功页面的任何信息。
以及如何从paypal页面获取交易ID,金额和其他详细信息。
我的代码是:
payment.php页面
<?php
$paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
$paypal_id='ankur.garg@trignodev.com'; // Business email ID
?>
<form action="<?php echo $paypal_url; ?>" method="post">
<input type='hidden' name='business' value='<?php echo $paypal_id; ?>'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='item_name' value='<?php echo $product_name;?>'>
<input type='hidden' name='amount' value='<?php echo $product_price;?>'>
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='cancel_return' value='<?php echo $base;?>'>
<input type='hidden' name='return' value='<?php echo $base;?>index.php?route=product/creditsuccess'>
<input type="submit" value="Buy Now">
</form>
和success.php
<?php
$item_transaction = $_REQUEST['tx'];
$item_price = $_POST['amount']; // Paypal received amount
echo "your payment is successfully";
echo "and here is the detail:";
echo $item_transaction;
echo $item_price;
?>
请帮助我在成功页面上获取交易ID,金额和payment_status。
答案 0 :(得分:0)
这不是正确的方法......你必须将你在post方法中获得的所有值作为查询字符串传递给paypal ....使用此函数,它可能对你有用...
现在更改您的表单行,
<input type="submit" value="Buy Now">
要,
<input type="submit" name="submit" value="Buy Now">
现在在页面顶部,
像这样调用函数
function PaypalPayment($paypal_email,$return_url,$cancel_url,$notify_url,$post)
{
$querystring .= "?business=".urlencode($paypal_email)."&";
foreach($post as $key => $value)
{
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode($notify_url);?>
<script type="text/javascript">
window.location = 'https://www.sandbox.paypal.com/cgi-bin/webscr<?php echo $querystring;?>';
/* window.location = 'https://www.paypal.com/cgi-bin/webscr<?php //echo $querystring;?>'; */
</script><?php
exit();
}
if(isset($_POST['submit']))
{
$success_url = // Here Goes Success URL
$cancel_url = // Here Goes Cancel URL
$notify_url = // Here Goes Current Page URL
$payid = // Enter Your merchant id
PaypalPayment($payid,$success_url,$cancel_url,$notify_url,$_POST);
}
现在简单地调用此功能,传递您的所有网址&amp;贝宝电子邮件... 在$ post中传递您的表单数据($ _POST)