【问题标题】:Paypal checkout php: how to securise a cart?Paypal 结帐 php:如何保护购物车?
【发布时间】:2014-02-28 16:02:06
【问题描述】:

我必须在 php 中构建一个 paypal 购物车(这是我使用的教程:http://jdmweb.com/how-to-easily-integrate-a-paypal-checkout-with-php)。

最后我有一个这样的 HTML 表单:

<form id="paypal_checkout" action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <!-- Paypal: Valeurs définissant que les produits appartiennent à un panier -->
    <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">           
        <input type="hidden" name="no_note" value="0">                      
        <input type="hidden" name="bn" value="PP-BuyNowBF">                 
        <input type="hidden" name="tax" value="0">          
        <input type="hidden" name="rm" value="2">

    <!-- Paypal: Valeurs de configurations du compte paypal créditeur -->
    <input type="hidden" name="business" value="projet.license.info@gmail.com">
        <input type="hidden" name="handling_cart" value="6.1">
        <input type="hidden" name="currency_code" value="EUR">
        <input type="hidden" name="lc" value="FR">
        <input type="hidden" name="return" value="http://localhost/site-web-commercial/controllers/ControllerCommande.php?action=retourPaypal">         
        <input type="hidden" name="cbt" value="Revenir chez Home Lampe">
        <input type="hidden" name="cancel_return" value="http://localhost/site-web-commercial/controllers/ControllerCommande.php?action=cancelPaypal">          
        <input type="hidden" name="custom" value="">

            <div id="item_1" class="itemwrap">
            <input type="hidden" name="item_name_1" value="produit1">
            <input type="hidden" name="quantity_1" value="4">
            <input type="hidden" name="amount_1" value="18.67">
            <input type="hidden" name="shipping_1" value="0">
        </div>
            <div id="item_2" class="itemwrap">
            <input type="hidden" name="item_name_2" value="produit3">
            <input type="hidden" name="quantity_2" value="2">
            <input type="hidden" name="amount_2" value="22.22">
            <input type="hidden" name="shipping_2" value="0">
        </div>

         <input id="ppcheckoutbtn" type="button" name="submitPaiement" value="Checkout" class="button">
</form>

我的问题是,经过实验的用户可以在发送之前修改表单的数量(例如使用 firebug)。

有没有办法保护这样的表单?

我的想法是在 ajax 中获取表单,然后将其提交给 Paypal。这样用户就不能修改项目的数量。不知道是不是最好的选择。

这是一个为不想在 Paypal 网站上创建项目而只在其网站后台创建项目的人提供的网站。

提前感谢您的帮助。

【问题讨论】:

    标签: php paypal checkout cart


    【解决方案1】:

    是否使用 ajax 并不重要。用户总是有办法更改他发送给您的数据。开发应用程序的基本规则是永远不要相信来自用户的数据。

    在这种情况下,诀窍是只收集主要数据,即项目 ID 和数量。您不会从表格中获取价格。在发送之前,请检查数据库中所选产品的价格并将其发送到 Paypal。

    所以他可以修改的唯一变量是产品和数量。如果他将金额从 1 更改为 10,他只需支付 10,所以这不是问题 :)

    我不知道你正在使用这个类,但它非常不安全,你不应该使用它。 例如,您可以使用 curl 向 Paypal 发送数据,而不是直接从表单中发送数据。

    您应该阅读如何使用快速结帐或直接付款。

    【讨论】:

    • 感谢您的回复,我找到了curl的教程。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-13
    • 2020-07-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-10
    • 1970-01-01
    • 2019-11-02
    相关资源
    最近更新 更多