如何通过PayPal智能支付按钮完成付款后获得订单ID



我在我的网站上集成了PayPal智能支付按钮。我的网站是在PHP代码点火器框架中构建的。我想知道交易成功后是否可以获得订单ID`

<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>
`
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交易相对应。

最新更新