无法用paypal快速结账显示金额

时间:2017-03-29 07:21:56

标签: paypal express-checkout

我正在使用我自己的客户端ID的演示代码,请检查代码,我无法显示金额和当前,也不会重定向到返回网址。

<script src="https://www.paypalobjects.com/api/checkout.js"></script>

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

<script>

    // Render the PayPal button

    paypal.Button.render({

        // Set your environment

        env: 'sandbox', // sandbox | production

        // Specify the style of the button

        style: {
            label: 'checkout', // checkout || credit
            size:  'small',    // tiny | small | medium
            shape: 'pill',     // pill | rect
            color: 'blue'      // gold | blue | silver
        },

        // PayPal Client IDs - replace with your own
        // Create a PayPal app: https://developer.paypal.com/developer/applications/create

        client: {
            sandbox:    'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
            production: 'Aco85QiB9jk8Q3GdsidqKVCXuPAAVbnqm0agscHCL2-K2Lu2L6MxDU2AwTZa-ALMn_N0z-s2MXKJBxqJ'
        },

        // Wait for the PayPal button to be clicked

        payment: function() {

            // Make a client-side call to the REST api to create the payment

            return paypal.rest.payment.create(this.props.env, this.props.client, {
                transactions: [
                    {
                        amount: { total: '0.01', currency: 'USD' }
                    }
                ]
            });
        },

        // Wait for the payment to be authorized by the customer

        onAuthorize: function(data, actions) {
            return actions.payment.execute().then(function() {
                document.querySelector('#paypal-button-container').innerText = 'Payment Complete!';
            });
        }

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

</script>

这是他们网站上提供的演示。我是这个paypal集成的新手。请帮助我! 感谢

1 个答案:

答案 0 :(得分:4)

请添加commit:true,

   payment: function() {

            // Make a client-side call to the REST api to create the payment

            return paypal.rest.payment.create(this.props.env, this.props.client, {
                transactions: [
                    {
                        amount: { total: '0.01', currency: 'USD' }
                    }
                ]
            });
        },
		
		commit: true,