【发布时间】:2020-06-27 12:09:25
【问题描述】:
我正在创建将 Angular 8 和 NodeJS 集成为 paypal 订购者的应用程序。我想知道如何获取我发送到交易的所有项目。例如,这是我的 createOrder 对象:
request.requestBody({
intent: 'CAPTURE',
purchase_units: [{
amount: {
value: '7',
currency_code: 'USD',
breakdown: {
item_total: {value: '7', currency_code: 'USD'}
}
},
invoice_id: 'muesli_invoice_id',
items: [{
name: 'Hafer',
unit_amount: {value: '3', currency_code: 'USD'},
quantity: '1',
sku: 'haf001'
}, {
name: 'Discount',
unit_amount: {value: '4', currency_code: 'USD'},
quantity: '1',
sku: 'dsc002'
}]
}]
});
但是当我试图在我的服务器上捕获这个事务时:
const paymentId = req.body['paymentID'];
const request = new paypal.orders.OrdersCaptureRequest(paymentId);
request.requestBody({});
// Call API with your client and get a response for your call
let response = await payPalClient.execute(request);
res.send(response);
我没有得到项目列表,只是来自贝宝的基本信息(送货地址等)
这里有什么问题?当我想取回这个项目列表时,我需要改变什么?
编辑:
statusCode: 201
headers:
cache-control: "max-age=0, no-cache, no-store, must-revalidate"
content-length: "1500"
content-type: "application/json"
date: "Mon, 16 Mar 2020 12:10:51 GMT"
paypal-debug-id: "c82e286689b67"
connection: "close"
__proto__: Object
result:
id: "64L22722PN8615907"
purchase_units: Array(1)
0:
reference_id: "default"
shipping:
name:
full_name: "John Doe"
__proto__: Object
address:
address_line_1: "Bajkowa 2 / 5"
address_line_2: "Case postale 12"
admin_area_2: "Warszawa"
admin_area_1: "PL_zip = 00800"
postal_code: "00800"
country_code: "PL"
__proto__: Object
__proto__: Object
payments:
captures: Array(1)
0:
id: "1XE85118J8824304V"
status: "COMPLETED"
amount:
currency_code: "USD"
value: "7.00"
__proto__: Object
final_capture: true
seller_protection:
status: "ELIGIBLE"
dispute_categories: (2) ["ITEM_NOT_RECEIVED", "UNAUTHORIZED_TRANSACTION"]
__proto__: Object
seller_receivable_breakdown:
gross_amount: {currency_code: "USD", value: "7.00"}
paypal_fee: {currency_code: "USD", value: "0.50"}
net_amount: {currency_code: "USD", value: "6.50"}
__proto__: Object
invoice_id: "muesli_invoice_id"
links: (3) [{…}, {…}, {…}]
create_time: "2020-03-16T12:10:50Z"
update_time: "2020-03-16T12:10:50Z"
__proto__: Object
length: 1
__proto__: Array(0)
__proto__: Object
__proto__: Object
length: 1
__proto__: Array(0)
payer:
name:
given_name: "John"
surname: "Doe"
__proto__: Object
email_address: "sb-o0n47b1188456@personal.example.com"
payer_id: "Z95Z7FJLRFVBS"
address: {country_code: "PL"}
__proto__: Object
links: Array(1)
0:
href: "https://api.sandbox.paypal.com/v2/checkout/orders/64L22722PN8615907"
rel: "self"
method: "GET"
__proto__: Object
length: 1
__proto__: Array(0)
status: "COMPLETED"
这是我的 json 格式的全部回复
【问题讨论】:
-
显示您获得的实际信息。如果不存在,您将需要对付款对象的获取请求。
-
我已经编辑了我的帖子。也许我应该以其他方式或其他方式将项目添加到付款中?
标签: node.js angular express paypal