Paypal Express Checkout按钮在沙盒模式下不起作用

时间:2017-10-12 06:04:45

标签: javascript paypal-sandbox paypal-rest-sdk

我复制并粘贴了代码Paypal必须在我们的网站https://developer.paypal.com/demo/checkout/#/pattern/client上添加一个结帐按钮。在交互式演示中,它完美运行。但是,一旦我使用复制的代码运行我自己的html文件,该框会显示半秒钟然后崩溃。我收到400错误代码。

这是我的代码:

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://www.paypalobjects.com/api/checkout.js"></script>
</head>

<body>
    <div id="paypal-button-container"></div>

    <script>
        paypal.Button.render({

            env: 'sandbox', // sandbox | production

            //must change to Charle's account
            client: {
                sandbox:    '...',
                production: '...'
            },

            // Show the buyer a 'Pay Now' button in the checkout flow
            commit: true,

            // payment() is called when the button is clicked
            payment: function(data, actions) {

                // Make a call to the REST api to create the payment
                return actions.payment.create({
                    payment: {
                        transactions: [
                            {
                                amount: { total: '10.0', currency: 'USD' }
                            }
                        ]
                    }
                });
            },

            // onAuthorize() is called when the buyer approves the payment
            onAuthorize: function(data, actions) {

                // Make a call to the REST api to execute the payment
                return actions.payment.execute().then(function() {
                    window.alert('Payment Complete!');
                });
            }

        }, '#paypal-button-container');

    </script>
</body>

注意:我删除了问题的客户端ID。最重要的是,如果我将env改为'production。

,这是有效的

0 个答案:

没有答案