显示Paypal结账中的所有购物车商品

时间:2015-12-09 19:32:56

标签: php paypal

我想列出在Paypal结帐时购买的所有商品。我尝试了以下代码,但它没有显示项目。它只显示结帐时的输入字段。我也在添加贝宝的快照。我是第一次尝试将我的网站与Paypal集成。enter image description here

代码

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
 <input type="hidden" name="business" value="testaddabusiness@shop.com">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick">
<?php
if(isset($_SESSION['cart'])){
  foreach($_SESSION['cart'] as $id => $value){
    $count=1;
?>
<input type="text" name="item_name_<?php echo $count ?>" value="<?php echo $value['name']  ?>">
 <input type="text" name="item_qty_<?php echo $count ?>" value="<?php echo $value['quantity'] ?>">
 <input type="text" name="amount_<?php echo $count ?>" value="<?php echo $value['price']   ?>">
  <input type="text" name="color_<?php echo $count ?>" value="<?php echo $value['color'] ?>">
  <input type="text" name="size_<?php echo $count ?>" value="<?php echo $value['size']   ?>">
  <input type="text" name="currency_code_<?php echo $count ?>" value="USD">

 <?php
 $count++;
  }}
  ?>
 <!-- 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>

1 个答案:

答案 0 :(得分:1)

item_name_x仅适用于购物车上传命令。

您需要将cmd值更改为&#34; _cart&#34;,然后添加另一个名为upload且值为1的变量。

以下是一个例子:

cmd = _cart
upload = 1
amount_1 = 0.01
item_name_1 = Test Item
item_number_1 = 123
currency_code = USD
...

之后,您的代码应该有效。

有关详细信息,请访问HTML Variables of PayPal Payment Standard