我正在使用 PayPal API 将付款选项添加到我的网站。在他们的教程中,他们使用 JavaScript 在客户端完全渲染按钮并设置交易。这是示例代码:
<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({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
return actions.order.capture().then(function(details) {
// This function shows a transaction success message to your buyer.
alert('Transaction completed by ' + details.payer.name.given_name);
});
}
}).render('#paypal-button-container');
//This …Run Code Online (Sandbox Code Playgroud)