【问题标题】:How to get orderid after completing payment through PayPal Smart Payment Buttons通过PayPal智能支付按钮完成支付后如何获取orderid
【发布时间】:2020-08-13 04:19:10
【问题描述】:

我在我的网站中集成了 PayPal 智能支付按钮。我的网站是在 PHP codeigniter 框架中构建的。 我想知道交易成功后能不能拿到orderid。`

<head>
    <!-- Add meta tags for mobile and IE -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

<body>
    <!-- Set up a container element for the button -->
    <div id="paypal-button-container"></div>

    <!-- Include the PayPal JavaScript SDK -->
    <script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

    <script>
        // Render the PayPal button into #paypal-button-container
        paypal.Buttons({

            // Set up the transaction
            createOrder: function(data, actions) {
                return actions.order.create({
                    purchase_units: [{
                        amount: {
                            value: '0.01'
                        }
                    }]
                });
            },

            // Finalize the transaction
            onApprove: function(data, actions) {
                return actions.order.capture().then(function(details) {
                    // Show a success message to the buyer
                    alert('Transaction completed by ' + details.payer.name.given_name + '!');
                });
            }


        }).render('#paypal-button-container');
    </script>
</body>
`

【问题讨论】:

    标签: php codeigniter paypal payment-gateway


    【解决方案1】:
    onApprove: function(data, actions) {
                    return actions.order.capture().then(function(details) {
                        // Show a success message to the buyer
                        alert('Transaction completed by ' + details.payer.name.given_name + '!');
                    });
                }
    

    在此处添加console.log(details);

    orderid 在捕获后没有真正的实用价值。它仅用于付款审批/捕获过程,之后绝对没有会计价值。

    从捕获中生成的付款 ID 对应于 PayPal 交易。

    【讨论】:

      猜你喜欢
      • 2020-03-23
      • 2021-01-28
      • 2021-07-14
      • 2019-11-16
      • 2020-05-09
      • 2019-10-31
      • 2020-05-25
      • 2019-09-03
      • 1970-01-01
      相关资源
      最近更新 更多