简体   繁体   English

如何以贝宝html形式发布多个字段并返回成功页面php中的所有数据

[英]how to post multiple fields in paypal html form and return success page all data in 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. 表格工作正常,并从贝宝(Paypal)返回所有详细信息,但只有user_name我没有进入成功页面,我也想在此表单中添加字段,但不返回,只有我正在获取item_name,item_number,金额和货币代码。所以请告诉我如何在success.php页面中获取user_name。

<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>
<?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 我的success.php页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM