PayPal Express Checkout.js - send custom parameters

五迷三道 提交于 2019-12-13 14:28:33

问题


How I can send a custom parameter to new Paypal Express checkout. I need to send the booking_id and get the same after success full payment.

I have gone through the paypal official document, but can't found how we can send?

Please see below is my file code:

<!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>    

回答1:


I have solved issues, we can pass the parameters in the payment method. like the below code:

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

Hope this will help for developers.




回答2:


To invoice number use:

      payment: {
                    transactions: [
                        {
                            amount: {
                                    total: '200',
                                    currency: 'BRL'
                            },
                            invoice_number: 100

                        }
                    ]
                }


来源:https://stackoverflow.com/questions/44923951/paypal-express-checkout-js-send-custom-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!