根据要购买的商品,我想创建一个JASON对象,将其放置在PAYPAL交易的“交易”区域中。无论做什么我都会失败。以下是我要测试的javascript代码:
paypal.Button.render({
env: 'sandbox',
client: {
sandbox: 'demo_sandbox_client_id'
},
payment: function (data, actions) {
var oAmount = {},
oAmount_details = {};
oAmount.total = '30.11';
oAmount.currency = "USD";
oAmount_details.subtotal = '30.00';
oAmount_details.tax = '00.11';
oAmount.details = oAmount_details;
return actions.payment.create({
transactions: [{
amount: oAmount
/*
amount: {
total: '30.11',
currency: 'USD',
details: {
subtotal: '30.00',
tax: '0.11'
}
}
*/
}]
});
},
onAuthorize: function (data, actions) {
return actions.payment.execute()
.then(function () {
window.alert('Thank you for your purchase!');
});
}
}, '#paypal-button');
*请注意,如果您注释掉:
amount: oAmount
然后取消注释:
amount: {
total: '30.11',
currency: 'USD',
details: {
subtotal: '30.00',
tax: '0.11'
}
}
然后它将起作用。
任何帮助将不胜感激。