捕获贝宝订单

时间:2020-09-28 18:37:58

标签: node.js paypal paypal-rest-sdk

与PayPal的V2订单API using the NodeJS SDK集成时,何时才是完成订单的正确时间(例如,将产品运送给客户)。

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)
    }
}

1 个答案:

答案 0 :(得分:0)

如果要在发货前进行正面检查,则可以检查status中的COMPLETED,这是成功的API参考中记录的值https://developer.paypal.com/docs/api/orders/v2/#orders_capture

INSTRUMENT_DECLINED的可恢复资金失败问题以及任何不可恢复的情况,应根据https://developer.paypal.com/demo/checkout/#/pattern/server的逻辑进行处理