dsfadsa08911 2015-09-04 13:07
浏览 62
已采纳

Paypal购物车检测到错误

I've created my shopping cart which works perfectly for adding multiple items. This will then loop over each item and display the image, name, quantity and total price.

I have added a paypal button and am trying to get this to work but I'm not sure why it isn't picking anything up. I always get 'Error Detected, nothing in shopping cart'.

I also print out my variables to ensure they are correct which they are, but still looks like it's not getting picked up in the form.

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="business@gmail.com">

for ($i = 0; $i < count($cart); $i++) {
         $s += $cart[$i]->price * $cart[$i]->quantity;
         $ppName = $cart[$i]->name;
         $ppAmount = $cart[$i]->price * $cart[$i]->quantity;
         $ppQuantity = $cart[$i]->quantity;
         // Inside of for each loop 
         ?>  
         <input type="hidden" name="item_name_<?php echo $x; ?>" value="<?php echo $ppName; ?>">
         <input type="hidden" name="amount_<?php echo $x; ?>" value="<?php echo $ppAmount; ?>">
         <input type="hidden" name="quantity_<?php echo $x; ?>" value="<?php echo $ppQuantity; ?>">
         <tr>
         <td class="col-md-2"><img class="img-responsive" img src= '<?php echo $cart[$i]->image_name; ?>' alt="Oops, Image cannot be found!" height="150" width="150"/></td>
         <td class="col-md-4">Name: <?php echo $cart[$i]->name; ?><br><br> <?php echo $cart[$i]->description; ?></td>
         <td class="col-md-4"> <a href="checkout.php?index=<?php echo $index; ?>" onclick="return confirm('Are you sure?')"><span class="glyphicon glyphicon-minus"></a></span> Qty <?php echo $cart[$i]->quantity; ?> <span class="glyphicon glyphicon-plus"></span></td>
         <td><?php echo $cart[$i]->price * $cart[$i]->quantity; ?></td>         
         </tr>
         <br>
         <?php
         $index++;
         $x = $i + 1;
         ?>

 <input type="hidden" name="currency_code" value="GBP">
 <input type="hidden" name="hosted_button_id" value="2R2BAJEWK3LRU">
 <input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
 <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">

I would appreciate any feedback. Many thanks.

  • 写回答

1条回答 默认 最新

  • dtah63820 2015-09-07 03:26
    关注

    I found the hosted_button_id contained in your button code, once the hotsted button id is contained, all of the extra codes you added are invalid.

    Please delete the line of "hosted_button_id" and retry it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料