paypal快速结账安全与cilent ajax电话

时间:2016-12-14 13:52:52

标签: javascript jquery node.js paypal paypal-sandbox

PayPal的新结账让我觉得不安全,用户不能在无声的一面触发虚假付款吗?

提供的代码如下所示

paypal.Button.render({  
    env: 'sandbox',
    client: {
        sandbox: 'AapGZeCaaDK_q_KPeG19DHnD_kd18vr6BxNe4P6uuhfTKPjIedtNEI9plyDgmzfyI-xGhbxjpv0k-Ha9',
        production: 'xxxxxxxxx' // u expose the key to client side? is this ok?
    },
    payment: function() {
        var env    = this.props.env;
        var client = this.props.client;

        return paypal.rest.payment.create(env, client, {
            transactions: [{
                amount: { total: ($scope.number_of_uses * 9) + '.00' , currency: 'USD' },
                item_list: {
                    items: [{
                        "name": "example",
                        "quantity": $scope.number_of_uses,
                        "price": "9.00",
                        "currency": "USD"
                    }]
                }
            }],
            redirect_urls: {
                "return_url": $location.absUrl(),
                "cancel_url": $location.absUrl()
            }
        });
    },

    onAuthorize: function(data, actions) {
        return actions.payment.execute().then(function() {
            actions.payment.get().then(function(data){
                // here I will save data detail to db to record sales
                // $http something something 
            });
        });
    }

}, '#paypal-button');

在条带中,我必须将令牌传递给后面,然后在我的服务器端验证该令牌,如果一切正常则继续记录销售。但是在paypal中,似乎这是我需要实现的唯一表达结账的东西。这甚至是安全的吗?

1 个答案:

答案 0 :(得分:5)

您确定更新数据库是不安全的。这是一种安全的付款方式,但是,您无法与客户验证付款是否成功,然后使用onAuthorize方法更新您的数据库。

要验证您的数据库付款是否成功,您必须使用Server Side REST API。遗憾的是,PayPal文档非常缺乏,但有SDKs文档记录更多,更容易实现。 (Shortcut to Node SDK)。

我建议您使用这些来实现数据库的更新。 PayPal返回一个参数,告诉您付款成功。