node.js - 捕获 PayPal 订单
问题描述
当使用 NodeJS SDK与 PayPal 的 V2 Orders API 集成时,什么时候是完成订单的正确时间(例如,将产品运送给客户)。
async function captureOrder(orderId) {
try {
const request = new checkoutNodeJssdk.orders.OrdersCaptureRequest(orderId);
request.requestBody({});
const response = await payPalClient.client().execute(request);
// Is it safe to assume, if the above line didn't reject, the order has been successfully captured?...or do we need to verify the status of the order / capture etc.
return response;
}
catch (e) {
console.log(e)
}
}
解决方案
如果您想在装运前进行积极检查,您可以检查 a status
of COMPLETED
,这是成功的 API 参考中记录的值https://developer.paypal.com/docs/api/orders/v2/#orders_capture
的可追回资金失败问题INSTRUMENT_DECLINED
,以及任何不可追回的情况,应按照https://developer.paypal.com/demo/checkout/#/pattern/server中的逻辑处理
推荐阅读
- sql - SQL 更新触发器 - 状态更新
- c++ - 将函数范围变量的引用作为值返回是否未定义?
- json - 更新子资源时的标准 REST Api 约定
- vba - 用于自动更新每日每周和每月报告的数据的宏或 vba 代码
- operating-system - 实时系统是硬/软还是 RTOS 本身?
- python - 如何使用 miltiprocessing for 循环?
- javascript - ReactJs - 添加打开和关闭标签而没有语法错误
- javascript - 在 React 中一键连续调用函数
- android - MPAndroid Chart - LimitLine 和 Cubic Bezier 绘图 - 曲线超过 min-max 限制线
- neo4j - Neo4j java.rmi.UnmarshalException:解组返回标头时出错;嵌套异常是: