Paypal立即购买按钮,具有可变/动态价格

时间:2017-07-05 14:19:27

标签: php paypal paypal-rest-sdk

这不是this post的重复。

我从链接的帖子中引用:

  

截至2017年6月29日,我发现这不起作用。 Paypal再次更改了规则,我认为它不再接受表单提交中的隐藏HTML字段:它们必须在Paypal的按钮编辑器中设置。

Paypal文档很乱。一半的链接被破坏,另一半的链接指向文档索引。

那里的大脑是否知道如何实现Paypal支付按钮,我可以动态设置价格?

2 个答案:

答案 0 :(得分:1)

PayPal建议使用快速结账客户端集成,您可以从您的网站动态发送金额到PayPal代码。

请参阅以下链接,了解PayPal Express结帐客户端集成:

https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/client-side-REST-integration/

https://developer.paypal.com/demo/checkout/#/pattern/client

其他,请尝试使用以下PayPal HTML按钮代码。

 <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
        <!-- Identify your business so that you can collect the payments. -->
        <input type="hidden" name="business" value="Yourbusinessemail@paypal.com"> <!-- Add your PayPal Seller/Business email address Required-->
        <!-- Specify a Buy Now button. -->
        <input type="hidden" name="cmd" value="_xclick">
        <!-- Specify details about the item that buyers will purchase. -->
        <input type="hidden" name="item_name" value=""> <!-- Add Description e.g your room type Required-->
        <input type="hidden" name="amount" value=""> <!-- Dynamically add Total Amount Required-->
        <input type="hidden" name="currency_code" value=""> <!-- Update to your currency -->
        <input id="invoice" type="hidden" value="" name="invoice"> <!-- Add Unique invoice for each transaction -->
        <input type="hidden" name="notify_url" value="www.yourwebsite.com/ipn.php"> <!-- Please add IPN URL You can use this service to automate back-office and administrative functions, including fulfilling orders, tracking customers, and providing status and other information related to transactions. -->
        <input type='hidden' name='cancel_return' value='' /> <!-- Take customers to this URL when they cancel their checkout -->
        <input type='hidden' name='return' value='' /> <!-- Take customers to this URL when they finish their checkout  -->
        <!-- Display the 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">
    </form>

HTML Variables - https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/  
Buy Now button - https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/buy_now_step_1/ 
IPN - https://developer.paypal.com/docs/classic/ipn/gs_IPN/ 
IPN - https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/ 
IPN Sample: https://github.com/paypal/ipn-code-samples 

答案 1 :(得分:0)

  <form  name="_xclick"  method="post" action= "https://www.paypal.com/cgi-bin/webscr">
                <input type="hidden" name="cmd" value="_xclick">
                <input type="hidden" name="business" value="xxx@jjdj.com">
                <input type="hidden" name="item_name" value="XXXX">
                <input type="hidden" name="notify_url" value="http://XXXXXXX.com/ipn.php" />
                <input type="hidden" id="buybuttonid" name="custom" value="XXXXX" />
                <input type="hidden" name="amount" value="amount that you want to send">
                <input type="submit" value="Buy Now">
              </form>

请使用此按钮,不要传递项目编号和数量,否则不会动态设置数量。

只需创建简单的立即购买按钮,并在创建按钮时将价格/金额值留空