[英]PHP Paypal pass multiple items dynamically
I am trying to add multiple products for processing on paypal. 我正在尝试添加多个产品以在Paypal上进行处理。 The order summery is not showing any item.
夏季订单未显示任何项目。 I am trying it on paypal sandbox.
我正在贝宝沙盒上尝试。
Here is the complete code : 这是完整的代码:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="paypal">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cbt" value="Return to max shop" />
<input type="hidden" name="business" value="example@gmail.com">
<?php
if(isset($_SESSION['products']))
{
$obj=new project;
$i=1;
foreach($_SESSION['products'] as $product)
{
$sql=$obj->get_products($product['id']);
$row=mysql_fetch_array($sql);
?>
<input type="hidden" name="item_number_<?php echo $i ?>" value="<?php echo $i ?>">
<input type="hidden" name="item_name_<?php echo $i ?>" value="<?php echo $row['title'] ?>" />
<input type="hidden" name="amount_<?php echo $i ?>" value="<?php echo $row['cost'] ?>">
<input type="hidden" name="item_quantity_<?php echo $i ?>" value="<?php echo $product['qty'] ?>">
<?php
$i++;
}
}
?>
<input type="hidden" name="button_subtype" value="services" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="http://localhost/oops" />
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" id="custom" name="custom" value="invoice_id to track"/>
<input type="hidden" class="btn btn-primary" style="width:100%" alt="PayPal - The safer, easier way to pay online!"/>
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" width="68" height="23" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
I also tried the array format like below but did not recieved any result; 我还尝试了如下所示的数组格式,但未收到任何结果;
<input type="hidden" name="item_number[<?php echo $i ?>]" value="<?php echo $i ?>">
<input type="hidden" name="item_name[<?php echo $i ?>]" value="<?php echo $row['title'] ?>" />
<input type="hidden" name="amount[<?php echo $i ?>]" value="<?php echo $row['cost'] ?>">
<input type="hidden" name="item_quantity[<?php echo $i ?>]" value="<?php echo $product['qty'] ?>">
Upload command works only for _cart
and not _xclick
. 上载命令仅适用于
_cart
而不适用于_xclick
。
Change this line to : 将此行更改为:
<input type="hidden" name="cmd" value="_cart" />
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="paypal">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cbt" value="Return to max shop" />
<input type="hidden" name="business" value="XXX-facilitator@gmail.com">
<?php
$_SESSION['products'] =2;
$product ='';
$pro =array("red","green");
if(isset($_SESSION['products']))
{
// $obj=new project;
$i=1;
foreach($pro as $key)
{
//$sql=$obj->get_products($product['id']);
$row='row';
?>
<input type="hidden" name="item_number_<?php echo $i ?>" value="<?php echo $i ?>">
<input type="hidden" name="item_name_<?php echo $i ?>" value="title" />
<input type="hidden" name="amount_<?php echo $i ?>" value="10.00">
<input type="hidden" name="item_quantity_<?php echo $i ?>" value="product">
<?php
$i++;
}
}
?>
<input type="hidden" name="button_subtype" value="services" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="http://localhost/oops" />
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" id="custom" name="custom" value="invoice_id to track"/>
<input type="hidden" class="btn btn-primary" style="width:100%" alt="PayPal - The safer, easier way to pay online!"/>
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/x-click-but23.gif" border="0" name="submit" width="68" height="23" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.