【问题标题】:Secure PayPal Checkout Client-side?安全的 PayPal Checkout 客户端?
【发布时间】:2020-06-26 10:54:12
【问题描述】:

他们声称,通过 paypal 的客户端结帐,您可以简单地将他们的代码放到您的网站(前端)上。然而,从这个例子来看,用户可以修改请求的金额,因为代码在客户端上(“从不信任客户端”)。

是否可以保护它或是否需要服务器端代码?

直接来自demo的代码

<!DOCTYPE html>

<head>
    <!-- Add meta tags for mobile and IE -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

<body>
    <!-- Set up a container element for the button -->
    <div id="paypal-button-container"></div>

    <!-- Include the PayPal JavaScript SDK -->
    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

    <script>
        // Render the PayPal button into #paypal-button-container
        paypal.Buttons({

            // Set up the transaction
            createOrder: function(data, actions) {
                return actions.order.create({
                    purchase_units: [{
                        amount: {
                            value: '0.01'
                        }
                    }]
                });
            },

            // Finalize the transaction
            onApprove: function(data, actions) {
                return actions.order.capture().then(function(details) {
                    // Show a success message to the buyer
                    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                });
            }


        }).render('#paypal-button-container');
    </script>
</body>

【问题讨论】:

    标签: javascript security paypal client frontend


    【解决方案1】:

    服务器端是确保金额(以及描述和您希望在交易中指定的任何其他数据)的必要条件

    Here is the front-end demo pattern 用于服务器端。

    【讨论】:

      猜你喜欢
      • 2019-03-21
      • 2020-11-11
      • 2021-06-24
      • 2021-03-29
      • 2018-11-27
      • 1970-01-01
      • 2012-06-29
      相关资源
      最近更新 更多