我试图通过PayPal按钮将我的产品价格传递到付款处理页面(或发票)。当您点击PayPal按钮时,它会将我的价格更改为0并继续以0.00为价格的PayPal。
$totalprice = array();
foreach ($_POST as $key => $value) {
$sql = "SELECT pprice FROM stock WHERE `pid`= ".$key;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$totalprice[$key] = $row["pprice"] * $value;
}
}
}
$totalprice["x"] = "0";
$totalprice["y"] = "0";
$finaltotal = array_sum($totalprice);
echo $finaltotal;
$data=array(
'merchant_email'=>'myemail@paypal.com',
'product_name'=>'Custom Product',
'amount'=> $finaltotal,
'currency_code'=>'GBP',
'thanks_page'=>"http://".$_SERVER['HTTP_HOST'].'/manager.php?ordered=1',
'notify_url'=>"http://".$_SERVER['HTTP_HOST'].'/manager.php?notify=1',
'cancel_url'=>"http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],
'paypal_mode'=>true,
);
?>
if(isset($_POST['pay_now'])){
echo processPaypal($data);
}
function processPaypal($data) {
define( 'SSL_URL', 'https://www.paypal.com/cgi-bin/webscr' );
define( 'SSL_SAND_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr' );
$action = '';
$action = ($data['paypal_mode']) ? SSL_SAND_URL : SSL_URL;
$form = '';
$form .= '<form name="frm_payment_method" action="' . $action . '" method="post">';
$form .= '<input type="hidden" name="business" value="' . $data['merchant_email'] . '" />';
// Instant Payment Notification & Return Page Details /
$form .= '<input type="hidden" name="notify_url" value="' . $data['notify_url'] . '" />';
$form .= '<input type="hidden" name="cancel_return" value="' . $data['cancel_url'] . '" />';
$form .= '<input type="hidden" name="return" value="' . $data['thanks_page'] . '" />';
$form .= '<input type="hidden" name="rm" value="2" />';
// Configures Basic Checkout Fields -->
$form .= '<input type="hidden" name="lc" value="" />';
$form .= '<input type="hidden" name="no_shipping" value="1" />';
$form .= '<input type="hidden" name="no_note" value="1" />';
// <input type="hidden" name="custom" value="localhost" />-->
$form .= '<input type="hidden" name="currency_code" value="' . $data['currency_code'] . '" />';
$form .= '<input type="hidden" name="page_style" value="paypal" />';
$form .= '<input type="hidden" name="charset" value="utf-8" />';
$form .= '<input type="hidden" name="item_name" value="' . $data['product_name'] . '" />';
$form .= '<input type="hidden" value="_xclick" name="cmd"/>';
$form .= '<input type="hidden" name="amount" value="' . $data['amount'] . '" />';
$form .= '<script>';
$form .= 'setTimeout("document.frm_payment_method.submit()", 2);';
$form .= '</script>';
$form .= '</form>';
return $form;
}
?>
有人知道为什么我推动&#34;支付&#34;它正在将价格重置为0?
我在解释事情时非常糟糕,所以如果需要任何进一步的信息来帮助找到解决方案 - 请问!
非常感谢。