Paypal Checkout错误 - ReferenceError:未定义操作

use*_*246 1 javascript paypal paypal-sandbox

我正在尝试使用此处的教程实现Paypal结帐按钮:

https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/client-side-REST-integration/

我在页面上有checkout.js文件:

<script src="https://www.paypalobjects.com/api/checkout.js"></script>
Run Code Online (Sandbox Code Playgroud)

按钮代码是:

<div id="paypal-button"></div>
<script>
    paypal.Button.render({
        env: 'sandbox', // 'sandbox' Or 'production',
        client: {
            sandbox: '<sandbox id>',
            production: ''
        },
        locale: 'en_GB',
        commit: true, // Show a 'Pay Now' button
        payment: function() {
            // Set up the payment here
            return actions.payment.create({
                payment: {
                    transactions: [
                        {
                            amount: { total: '1.00', currency: 'GBP' }
                        }
                    ]
                }
            });
        },
        onAuthorize: function(data, actions) {
            // Execute the payment here
            return actions.payment.execute().then(function(payment) {

                // The payment is complete!
                // You can now show a confirmation message to the customer
            });
        }
    }, '#paypal-button');
</script>
Run Code Online (Sandbox Code Playgroud)

但是当我单击按钮时,我在控制台中得到"ReferenceError:actions not defined",没有任何反应.我应该包含另一个Javascript文件,因为教程中没有提到它?

blu*_*ume 6

payment: function() {
Run Code Online (Sandbox Code Playgroud)

应该

payment: function(data, actions) {
Run Code Online (Sandbox Code Playgroud)