我正在尝试将PayPal设置为在我的网站上进行付款,并且我想指定用于付款的订单项(使用新的SDK,而不是javascript版本)
我尝试遍历此处列出的API文档:https : //developer.paypal.com/docs/api/orders/v2/。但是,它说我语法无效或缺少字段。
<head>
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
currency_code: 'USD',
value: '0.01',
amount_breakdown: {
}
},
items: {
item: {
name: 'Cake',
quantity:'1',
unit_amount:{
currency_code:'USD',
value:'0.01'
}
}
}
}],
application_context: {
shipping_preference: 'NO_SHIPPING',
}
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
// Call your server to save the transaction
return fetch('/paypal-transaction-complete', {
method: 'post',
body: JSON.stringify({
orderID: data.orderID
})
}); …Run Code Online (Sandbox Code Playgroud)