如何解析多个产品到贝宝沙箱?

时间:2019-09-17 19:17:10

标签: php session paypal paypal-sandbox

我无法将多个产品解析到PayPal沙箱。它只是通过了最后添加的一个。实际上,我正在使用会话存储购物车中的产品。

我尝试使用foreach在会话中循环,但不幸的是它没有用。

  <form action="<?php echo $paypal_url; ?>" method="post">    
          <!-- Paypal business test account email id so that you can collect the payments. -->
    <input type="hidden" name="business" value="<?php echo $paypal_email; ?>">  
      <!-- Buy Now button. -->
    <input type="hidden" name="cmd" value="_xclick">    

    <?php       
foreach ($_SESSION["shopping_cart"] as $product){
    $name .= $product["quantity"].' x '.$product["name"].', ';
?>         
    <input type="hidden" name="item_name" value=" <?php echo rtrim($name , ', ') ?> ">
    <input type="hidden" name="item_number" value="<?php echo $product['id']; ?>">
    <input type="hidden" name="amount" value="<?php echo  $total_price ; ?>"> 

<?php } // for each?>

    <!-- Details about the item that buyers will purchase. -->
      <input type="hidden" name="currency_code" value="USD">    

    <!-- URLs -->
    <input type='hidden' name='cancel_return' value='http://localhost/paypal/cancel.php'>
    <input type='hidden' name='return' value='http://localhost/finalcli/paypal/success.php'>
      <input type="hidden" value="2" name="rm"> 

    <!-- 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>        

I want to parse whatever the number of products the user add to cart with its own name, id and price.

0 个答案:

没有答案
相关问题