我想在 paypal 的 actions.order.create 函数中添加更多属性。诸如 tax_total、运输、保险、客户购买的物品清单等属性。
我已经实现了他们网站上的代码并且运行良好,剩下的就是在代码中添加额外的细节。这是他们的文档:https : //developer.paypal.com/docs/api/orders/v2/#orders_create。
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
// value: '350.00',
breakdown: {
item_total: '300.00',
tax_total: '20.00',
shipping: '10.00',
handling: '10.00',
insurance: '10.00'
},
}
}]
});
},
onApprove: function(data, actions) {
// Capture the funds from the transaction
return actions.order.capture().then(function(details) {
// Show a success message to your buyer
console.log(data, actions);
alert('Transaction completed by ' + details.payer.name.given_name);
// Call your server to save the …Run Code Online (Sandbox Code Playgroud)