如何将多件商品发送至 PayPal

发布于 2024-10-13 12:30:53 字数 1804 浏览 3 评论 0原文

我想向 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="[email protected]">
    <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>

I want to send multiple item names and item prices to PayPal but I am unable to post my item name and price with below code can you please help me?

<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="[email protected]">
    <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酸甜透明夹心 2024-10-20 12:30:53

像这样创建你的代码:

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

Create your code like this:

<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>
幽梦紫曦~ 2024-10-20 12:30:53

除了 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="[email protected]">
  <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 code> (其中 N 是行项目编号,从 1 开始)。

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

In addition to the changes suggested by devilprince, the underscores are missing from the line item input tags' name attributes, and also the tags are not proper self-closing tags because the closing / is missing. Correct like so:

<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="[email protected]">
  <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>

(You may also want to escape special characters in the value attribute, at least for the " character in case it shows up in your item name data.)

Just had to figure this out today for a client. Besides item_name_N and amount_N I also used quantity_N, tax_N, and shipping_N (where N is the line item number, starting with 1).

This page has a list of all parameters: PayPal HTML Form Variables, but the question & answers given here are a better real-world example than the trivial examples on the PayPal site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文