douche5961 2012-03-12 09:15
浏览 35
已采纳

将值或变量传递给paypal cart

I am developing a website so that a customer can buy gardening products. Currently, a customer can browse products on the website. When they select an individual product, I want them to be able to add to cart using Paypal's custom button. My website is set up so that when a user selects a product, it grabs the information from the database. What do I need to do in order for the product they have added to cart to appear in the Paypal cart? (with its name, and price).

From what I understand, you have to create each individual button for each item on your website. But I do not know what product the customer has selected from the database and my website is set up so that it retrieves the product info from the db.

Hope somebody could help me

  • 写回答

2条回答 默认 最新

  • douwu0335 2012-03-12 10:35
    关注

    You can use a single button for all products. You can change the item_name and amount depending upon the product selected. You can pass userid in item_number field.

    When a customer selects the product, query to the database and fetch the product name and amount and update it to the hidden fields.

    <?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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问为什么我配置IPsec后PC1 ping不通 PC2,抓包出来数据包也并没有被加密
  • ¥200 求博主教我搞定neo4j简易问答系统,有偿
  • ¥15 nginx的使用与作用
  • ¥100 关于#VijeoCitect#的问题,如何解决?(标签-ar|关键词-数据类型)
  • ¥15 一个矿井排水监控系统的plc梯形图,求各程序段都是什么意思
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要