-1

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

以及如何从贝宝页面获取交易 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>

和成功.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。

4

2 回答 2

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

现在只需调用此函数,传递您所有的网址和贝宝电子邮件...在 $post 中传递您的表单数据($_POST)

于 2013-11-13T13:23:31.730 回答
0

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

在这里,我们必须为PDT以及auto-return设置“ON”选项。请参阅此屏幕截图。

截屏

于 2020-01-17T10:45:35.333 回答