如何在reactjs中的paypal订单中添加数量
How to add a quantity in paypal orders in reactjs
我正在尝试添加订单数量。这就是我所拥有的,它不会工作:(。
它可以在没有数量的情况下工作,但它默认为 1。另外,我将如何添加第二个产品?它只会让我拥有一个
window.paypal.Buttons({
createOrder: (data, actions, err) => {
return actions.order.create({
intent: "CAPTURE",
purchase_units: [
{
description: "cool tablet",
amount: {
currency_code: "CAD",
value: 650.00,
},
quantity: 2,
},
{
description: "ink",
amount: {
currency_code: "CAD",
value: 777.00,
}
}
]
})
},
onApprove: async (data, actions)=>{
const order = await (actions.order.capture());
console.log(order);
},
onError: (err) => {
console.log(err);
}
})
.render(paypal.current)
}, []);
您需要一个采购单位、一个具有所需细分对象的金额以及一个具有订单项详细信息的项目数组。请参阅 API 参考 https://developer.paypal.com/docs/api/orders/v2/#orders_create
这是一个例子:
"purchase_units": [{
"description": "DESCRIPTION GOES HERE",
"amount": {
"value": "3.00",
"currency_code": "CAD",
"breakdown": {
"item_total": {
"currency_code": "CAD",
"value": "3.00"
}
}
},
"items": [
{
"name": "item one",
"quantity": "1",
"unit_amount": {
"currency_code": "CAD",
"value": "1.00"
}
},
{
"name": "item two",
"quantity": "1",
"unit_amount": {
"currency_code": "CAD",
"value": "2.00"
}
}
]
}
]
我正在尝试添加订单数量。这就是我所拥有的,它不会工作:(。
它可以在没有数量的情况下工作,但它默认为 1。另外,我将如何添加第二个产品?它只会让我拥有一个
window.paypal.Buttons({
createOrder: (data, actions, err) => {
return actions.order.create({
intent: "CAPTURE",
purchase_units: [
{
description: "cool tablet",
amount: {
currency_code: "CAD",
value: 650.00,
},
quantity: 2,
},
{
description: "ink",
amount: {
currency_code: "CAD",
value: 777.00,
}
}
]
})
},
onApprove: async (data, actions)=>{
const order = await (actions.order.capture());
console.log(order);
},
onError: (err) => {
console.log(err);
}
})
.render(paypal.current)
}, []);
您需要一个采购单位、一个具有所需细分对象的金额以及一个具有订单项详细信息的项目数组。请参阅 API 参考 https://developer.paypal.com/docs/api/orders/v2/#orders_create
这是一个例子:
"purchase_units": [{
"description": "DESCRIPTION GOES HERE",
"amount": {
"value": "3.00",
"currency_code": "CAD",
"breakdown": {
"item_total": {
"currency_code": "CAD",
"value": "3.00"
}
}
},
"items": [
{
"name": "item one",
"quantity": "1",
"unit_amount": {
"currency_code": "CAD",
"value": "1.00"
}
},
{
"name": "item two",
"quantity": "1",
"unit_amount": {
"currency_code": "CAD",
"value": "2.00"
}
}
]
}
]