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



表单运行良好,并返回PayPal的所有详细信息,但仅在我没有进入成功页面user_name,我还想在此表单中添加字段,但不返回仅我正在获得item_name,item_number,金额和货币 code.so 请告诉我如何获得成功user_name.php页面。

<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
}
?>

我的成功.php页面

最新更新