php - Paypal 结帐 php : how to securise a cart?

标签 php paypal checkout cart

我必须在 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 网站上创建项目而只想在其网站后台创建项目的人准备的网站。

在此先感谢您的帮助。

最佳答案

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

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

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

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

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

关于php - Paypal 结帐 php : how to securise a cart?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22099978/

相关文章:

php - symfony2 fatal error 无法重新声明类

php - 网站图标定制或动画

ios - 将 twilio sdk 用于 iOS 应用程序?

php - 从数据库中获取记录时的动态行跨度

php - 将 3 个数据库表连接在一起

java - PayPal:替代 ConfigManager.getInstance().load()

android - 如何在 Android 应用程序中集成 Paypal 捐赠?

php - 禁用 WooCommerce 中特定运输方式的 “Place order” 按钮

javascript - 如何更改 Stripe 在网站上的货币显示?

magento - 如何自定义magento一页结帐表格