paypal:如何获取订单ID并传递到交易详情页面

paypal: How to get order id and pass to transaction details page

我是 PayPal 集成的新手。我需要获取订单ID以获取交易详情,并希望在另一个页面上向客户显示交易详情。

以下是 javascript 代码。以下代码显示 OrderId = 0。

     <script>
 paypal.Buttons({
     createOrder: function (data, actions) {
         // This function sets up the details of the transaction, including the amount and line item details.
         return actions.order.create({
            application_context: {
                return_url: 'https://example.com',
                cancel_url: 'https://example.com'
            },
             purchase_units: [{
                 amount: {
                     currency_code: 'USD',
                     value: '<%=bookingAmount%>'
                 }
             }]
         });
     },

    onApprove: function (data, actions) {
        // Capture the transaction funds
        return actions.order.capture().then(function () {
            // Show a confirmation to the buyer
            alert('Transaction complete!' & data.orderID);
        });
    }

}).render('#paypal-button-container');   //This function displays Smart Payment Buttons on your web page. 
    </script>

问题:以上代码没有按要求运行。如何解决?

使用以下代码行,我能够检索交易的详细信息。 -

"return actions.order.capture().then(function (details)"

以下是完整的 运行 代码 -

paypal.Buttons({
    createOrder: function (data, actions) {
        // This function sets up the details of the transaction, including the amount and line item details.
        return actions.order.create({
            purchase_units: [{
                amount: {
                    currency_code: 'USD',
                    value: '<%=bookingAmount%>'
                }
            }]
        });
    },
    onApprove: function (data, actions) {
        // Capture the transaction funds
        return actions.order.capture().then(function (details) {
            console.log(JSON.stringify(details));
        });
    }
}).render('#paypal-button-container');