PayPal Express Checkout.js - 发送自定义参数

mag*_*688 3 php paypal express-checkout

如何将自定义参数发送到新的Paypal Express结帐.我需要booking_id在成功全额付款后发送并获得相同的信息.

我已经通过了paypal官方文档,但找不到我们如何发送?

请看以下是我的文件代码:

<!DOCTYPE html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <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
            client: {
                sandbox:    'AYbCnvobq09Ptmsd1TRp3019CMrSTyaAmrHNv6ox0jl86H9OZFmGCPqHqqfPtqpTYTiIuy_e5UGnclMw',
                //production: '<insert production client id>'
            },
            commit: true,
            payment: function(data, actions) {
                return actions.payment.create({
                    payment: {
                        transactions: [
                            {
                                amount: { total: '0.01', currency: 'USD' }
                            }
                        ]
                    }
                });
            },
            onAuthorize: function(data, actions) {
                return actions.payment.execute().then(function() {
                    window.alert('Payment Complete!');
                });
            }
        }, '#paypal-button-container');
    </script>
</body>    
Run Code Online (Sandbox Code Playgroud)

mag*_*688 7

我已经解决了问题,我们可以在付款方式中传递参数.像下面的代码:

payment: function(data, actions) {
    return actions.payment.create({
        payment: {
            transactions: [
                {
                    amount: { total: '10', currency: 'USD' },
                    custom: '1452'
                }
            ]
        }
    });
},
Run Code Online (Sandbox Code Playgroud)

希望这对开发人员有所帮助.