我正在使用paypal REST API测试沙盒环境上的快速结账。
一切正常,除了一件事:订单描述区域相当空:没有总和,没有单独的项目信息,没有总订单金额 - 我只能看到我的虚拟描述“无论我是否通过订单总和金额。
我正在传递类似于示例应用中使用的付款信息:
var ppPayment = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {},
"transactions": [{
"amount": {
"currency": "EUR",
"details": {
"subtotal": 0
}
}
}]
};
ppPayment.transactions[0].amount.total = params.req_order_amount;
ppPayment.redirect_urls.return_url = "http://xxxxxxxxx/confirm?order_id=" + order_id;
ppPayment.redirect_urls.cancel_url = "http://xxxxxxxxx/cancel?order_id" + order_id;
ppPayment.transactions[0].description = "Dummy description";
ppPayment.transactions[0].amount.details.subtotal = params.req_order_amount;
我应该在payment.create调用中添加哪些行,以便能够看到此处显示的说明?
答案 0 :(得分:3)
遵循API
您需要在其中包含transaction object
个项目的item_list object
内创建item object
。让我们命名一个paypalItem.name
或者点击你的屏幕截图:
item object
invoice_item object
的API。某些字段仅存在于Invoice object
答案 1 :(得分:0)
所以明确的答案是:
ppPayment.transactions[0].amount.total = params.req_order_amount;
ppPayment.redirect_urls.return_url = "http://xxxxxxxxx/confirm?order_id=" + order_id;
ppPayment.redirect_urls.cancel_url = "http://xxxxxxxxx/cancel?order_id" + order_id;
ppPayment.transactions[0].description = "Dummy description";
ppPayment.transactions[0].amount.details.subtotal = params.req_order_amount;
ppPayment.transactions[0].item_list =
{
items: [{quantity: 1, name: 'My stuff', price: params.req_order_amount, currency: "USD"}]
};