doucheng3811 2019-02-05 08:14
浏览 24

如何在paypal html表单中发布多个字段并在php中返回成功页面的所有数据

The form is working fine and return all details from paypal but only user_name i am not getting in success page and i also want to add for fields in this form but not return only i am getting item_name, item_number,amount and currency code.so please tell me how to get user_name in success.php page.

<form action="<?php echo $paypal_link; ?>" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypal_username; ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="<?php echo $row['name']; ?>">
<input type="hidden" name="item_number" value="<?php echo $row['id']; ?>">
<input type="hidden" name="amount" value="<?php echo $row['price']; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="first_name" value="arif">
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='http://localhost/PHP-PayPalDemo-master/paypal_cancel.php'>
<input type='hidden' name='return' value='http://localhost/PHP-PayPalDemo-master/paypal_success.php'>
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form>
  • 写回答

1条回答 默认 最新

  • douxie2007 2019-02-05 12:39
    关注
    <?php
    include 'connection.php';
    print_r($_GET);
    die();
    //here i got that result only
    //Array ( [amt] => 10.00 [cc] => USD [item_name] => Product1 [item_number] => 1 [st] => Completed [tx] => 23024871HW419281C ) 
    //save Trasaction information form PayPal
    
    $txn_id = $_GET['tx'];
    $payment_gross = $_GET['amt'];
    $currency_code = $_GET['cc'];
    $payment_status = $_GET['st'];
    $item_number = $_GET['item_number']; 
    
    
    
    //Get product price
    $productResult = $db->query("SELECT price FROM products WHERE id = ".$item_number);
    $productRow = $productResult->fetch_assoc();
    $productPrice = $productRow['price'];
    
    if(!empty($txn_id) && $payment_gross == $productPrice){
        //Check if payment data exists with the same TXN ID.
        $prevPaymentResult = $db->query("SELECT payment_id FROM payments WHERE txn_id = '".$txn_id."'");
    
        if($prevPaymentResult->num_rows > 0){
            $paymentRow = $prevPaymentResult->fetch_assoc();
            $last_insert_id = $paymentRow['payment_id'];
        }else{
            //Insert tansaction data into the database
            $insert = $db->query("INSERT INTO payments(item_number,txn_id,payment_gross,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')");
            $last_insert_id = $db->insert_id;
        }
    ?>
        <h1>Your payment has been successful.</h1>
        <h1>Your Payment ID - <?php echo $last_insert_id; ?>.</h1>
    <?php
    }else{
    ?>
        <h1>Your payment has failed.</h1>
    <?php
    }
    ?>
    

    my success.php page

    评论

报告相同问题?

悬赏问题

  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计