【问题标题】:Passing values or variables over to paypal cart将值或变量传递到贝宝购物车
【发布时间】:2012-03-28 16:32:59
【问题描述】:

我正在开发一个网站,以便客户可以购买园艺产品。目前,客户可以在网站上浏览产品。当他们选择单个产品时,我希望他们能够使用 Paypal 的自定义按钮添加到购物车。我的网站设置为当用户选择产品时,它会从数据库中获取信息。我需要做什么才能让他们添加到购物车的产品出现在 Paypal 购物车中? (带有名称和价格)。

据我了解,您必须为网站上的每个项目创建每个单独的按钮。但我不知道客户从数据库中选择了什么产品,并且我的网站已设置为从数据库中检索产品信息。

希望有人可以帮助我

【问题讨论】:

    标签: php sql paypal


    【解决方案1】:

    一个按钮可以使用不同的产品,你必须在一个循环中。但是隐藏的参数会有所不同。

    <input type="hidden" value="Scicssors" name="item_name">
    <input type="hidden" value="return.php" name="notify_url">
    <input type="hidden" value="10.00" name="amount">
    ...........................................
    

    有多个字段需要作为隐藏传递。您可以将这些连同表单提交按钮一起发送

    参考此链接https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables

    【讨论】:

      【解决方案2】:

      您可以对所有产品使用一个按钮。您可以根据所选产品更改 item_name 和数量。您可以在 item_number 字段中传递用户 ID。

      当客户选择产品时,查询数据库并获取产品名称和数量并将其更新到隐藏字段。

      <?php
      $amt = amt from db;
      $name = product name from db;
      $userid = user's id;
      ?>
      
      <form name=subs action='https://www.paypal.com/cgi-bin/webscr' method='post'>
      <table cellspacing=0 cellpadding=0><tr><td>
      <input type="hidden" name="on0" value="user">
      <input type="hidden" name="os0" value="<?php echo $user_email; ?>">
      <input type="hidden" name="cmd" value="_xclick">
      <input type="hidden" name="business" value="sales@yoursite.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="no_note" value="0">
      <input type="hidden" name="cn" value="add">
      <input type="hidden" name="no_shipping" value="2">
      <input type="hidden" name="rm" value="1">
      <input type="hidden" name="return" value="http://yoursite.com/payment-success.php"> //return to this url after payment completed
      <input type="hidden" name="cancel_return" value="http://yoursite.com/payment-cancel.php"> //return to this url when payment cancelled
      <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
      <input type="hidden" name="custom" value="CustomValue">
      <input type="hidden" name="notify_url" value="http://yoursite.com/payment-confirm.php"> //return instant payment notification to this url where you can get the response from paypal and process it
      <input type="hidden" name="event" value="add">
      <input type="hidden" name="mnt" value="0"> 
      <input type="hidden" name="amount" value="<?php echo $amt; ?>" id="paypalamt"> //the product's amount
      <input type="hidden" name="item_number" id="paypalno" value="<?php echo $userid; ?>"> //you can send the customer/user id with this, so that you can retrieve it after payment completion
      <input type="hidden" name="item_name" id="itemname" value="<?php echo $name; ?>"> //here you can set your product name
      </td></tr>
      </form>
      

      【讨论】:

      • 伙伴 我可以私下联系你吗?我会付钱
      • 我有点明白你的意思,但我发现很难将其合并到我的特定文件中。如果我把它们寄给你,你能帮我吗?我会付钱给你的哥们
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-04
      • 2017-11-18
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-17
      相关资源
      最近更新 更多