在贝宝成功后无法获得成功页面上的信息

问题描述 投票:-1回答:2

我在我的网站上使用贝宝(Paypal)标准代码,但是成功付款后,我在成功页面上没有任何信息。

以及如何从贝宝页面获取交易ID,金额和其他详细信息。

我的代码是这个:

payment.php页面

<?php 
 $paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
 $paypal_id='[email protected]'; // 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,金额和付款状态。

php paypal opencart
2个回答
0
投票

这是不正确的方式...您必须将在post方法中获得的所有值作为查询字符串传递给paypal。...使用此功能,这可能对您有用...

现在从此更改表格行,

<input type="submit" value="Buy Now">

to,

<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);   
  }

现在只需调用此功能,通过您的所有网址和Paypal电子邮件...在$ post中传递表单($ _POST)]中的帖子数据


0
投票

您的源代码不是问题。您必须在PayPal中进行一些设置。使用PayPal商业帐户登录,然后在浏览器中发布以下链接。https://www.sandbox.paypal.com/businessmanage/preferences/website#

© www.soinside.com 2019 - 2024. All rights reserved.