我在沙箱环境中使用paypal功能。我正在实现贝宝的非常基本的功能。问题是,当用户购买同一产品的数量超过1时,paypal中的金额价值就会成倍增加。我确信我错过了一些变量使用,但不能弄清楚。我在服务器端计算的总金额。例如,如果买家选择两批相同的产品,价格乘以2,这是paypal形式中金额变量的值。但是当表单提交到paypal时,amount变量的值变成了物品价格的值,最终在paypal中的金额再次乘以2。
这里是我的paypal表单
<form action="<?php echo $paypal_url; ?>" method="post" name="frmPayPal1">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="xyz@exmp.com">
<input type="hidden" name="item_name" value="<?php echo $_SESSION['itemName'];?>">
<input type="hidden" name="quantity" value="<?php echo $quant;?>">
<input type="hidden" name="item_price" value="<?php echo $price;?>">
<input type="hidden" name="amount" value="<?php echo $z?>">
<input type="submit" name="submit" value="pay">
<INPUT TYPE="hidden" NAME="return" value="return website">
<INPUT TYPE="hidden" NAME="cancel_return" value="return website">
</form>
where $quant is the quantity of product, $price is the price of product,
$z为计算出的总金额($quant * $price)
if $quant=2
$price=1000 per unit of product
then $z = 2000
and in paypal website the values become
Item price: 2000.00
Quantity: 2
Amount: 4000
根据Paypal手册,没有名为item_price
的变量
有quantity
:
项目数。
还有amount
:
产品、服务或贡献的价格或数量,而不是包括运费、处理费或税费
所以你应该有:
$z = 1000; //price_per_product;
$quant = 2;