【发布时间】:2020-04-14 08:31:14
【问题描述】:
我正在尝试使用 javascript api purchase_units 将订单发送到贝宝,但是当贝宝重定向到成功页面时,我收到错误未知 purchase_units。当我在控制台中检查 api 调用时,我在使用 purchase_units 的调用附近得到感叹号
这是我的代码
paypal.Buttons({
env: 'sendbox',
style: {
layout: 'horizontal',
size: 'responsive',
shape: 'pill',
color: 'gold',
fundingicons: false,
tagline: false
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [ {
reference_id: "PUHF",
description: "Some description",
custom_id: "Something7364",
soft_descriptor: "Great description 1",
amount: {
currency_code: "USD",
value: "200.00",
breakdown: {
item_total: {
currency_code: "USD",
value: "200.00"
}
}
}, items: [{
name: "Item 1",
description: "The best item ever",
sku: "xyz-2654",
unit_amount: {
currency_code: "USD",
value: "100.00"
},
quantity: "1"
}, {
name: "Item 2",
description: "Not bad too",
sku: "zdc-3942",
unit_amount: {
currency_code: "USD",
value: "50.00"
}, quantity: "2"
}
],
}
]
})}, onApprove: function(data, actions) {
return fetch('<?= $rootPath.URL['services']['orderGet'] ?>', {
method: 'GET'
}
).then(function(res) {
return res.json();
}).then(function(res) {
window.location.href = 'pages/success.php';
});
}
}).render('#paypalCheckoutContainer');
【问题讨论】:
标签: javascript paypal paypal-sandbox