【问题标题】:How to send multiple items to PayPal如何将多个项目发送到 PayPal
【发布时间】:2011-06-15 00:42:08
【问题描述】:

我想向 PayPal 发送多个商品名称和商品价格,但我无法使用以下代码发布商品名称和价格,您能帮帮我吗?

<form method="post"  name="cart" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="business" value="navive_1295939206_biz@gmail.com">
    <input type="hidden" name="lc" value="US">

    <input type="hidden" name="currency_code" value="USD">
    <input type="hidden" name="button_subtype" value="services">
    <input type="hidden" name="notify_url" value="http://newzonemedia.com/henry/ipn.php" />
    <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
    <input type="hidden" name="return" value="http://www.example.com/thank_you_kindly.html" />


    <?php
    //select items for table
    $srowcart_dtl = mysql_num_rows($srscart_dtl);
    if($srowcart_dtl > 0) {
        $cnt=1;
        while($srscart_dtl1 = mysql_fetch_assoc($srscart_dtl)) {
            ?>  
            <input type="hidden" name="item_name[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iname']; ?>">

            <input type="hidden" name="amount[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iprc']; ?>">
            <?php
            $cnt++;
        }
    }
    ?>
    <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

【问题讨论】:

  • 你如何检查服务器上的值?
  • 我检查了值,值是手动插入到表中的。只是我正在测试,我在表中有项目中殿和价格。

标签: paypal paypal-sandbox


【解决方案1】:

像这样创建你的代码:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart">  <!-- change _xclick to _cart -->
    <input type="hidden" name="upload" value="1">  <!-- add this line in your code -->
    <input type="hidden" name="business" value="your_seller_account">
    <input type="hidden" name="item_name_1" value="Item Name 1">
    <input type="hidden" name="amount_1" value="1.00">
    <input type="hidden" name="item_name_2" value="Item Name 2">
    <input type="hidden" name="amount_2" value="2.00">
    <input type="submit" value="PayPal">
</form>

【讨论】:

  • 感谢您提及cmd field +1
【解决方案2】:

除了devilprince 建议的更改之外,订单项输入标签的名称属性中缺少下划线,并且这些标签也不是正确的自结束标签,因为缺少结束/。正确如下:

<form method="post" name="cart" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
  <input type="hidden" name="cmd" value="_cart">
  <input type="hidden" name="upload" value="1">
  <input type="hidden" name="business" value="navive_1295939206_biz@gmail.com">
  <input type="hidden" name="lc" value="US">
  <input type="hidden" name="currency_code" value="USD">
  <input type="hidden" name="button_subtype" value="services">
  <input type="hidden" name="notify_url" value="http://newzonemedia.com/henry/ipn.php" />
  <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
  <input type="hidden" name="return" value="http://www.mysite.org/thank_you_kindly.html" />

  <?php
    // select items for table
    $srowcart_dtl = mysql_num_rows($srscart_dtl);
    if($srowcart_dtl > 0)
    {
       $cnt=1;
       while($srscart_dtl1 = mysql_fetch_assoc($srscart_dtl))
       {
  ?>    
         <input type="hidden" name="item_name_[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iname']; ?>"/>
         <input type="hidden" name="amount_[<?php echo $cnt ?>]" value="<?php echo $srscart_dtl1['cart_iprc']; ?>"/>
  <?php
         $cnt++;
       }
    }
  ?>
  <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
  <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

(您可能还想转义 value 属性中的特殊字符,至少对于 " 字符,以防它出现在您的项目名称数据中。)

今天只需要为客户解决这个问题。除了item_name_Namount_N,我还使用了quantity_Ntax_Nshipping_N(其中N 是行项目编号,从1 开始)。

此页面包含所有参数的列表:PayPal HTML Form Variables,但此处给出的问题和答案是比 PayPal 网站上的简单示例更好的真实示例。

【讨论】:

    猜你喜欢
    • 2014-01-18
    • 2014-11-19
    • 1970-01-01
    • 2015-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多