安全的PayPal结帐客户端吗?

问题描述 投票:0回答:1

[通过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个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.