首页 > 解决方案 > 捕获 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)
    }
}

标签: node.jspaypalpaypal-rest-sdk

解决方案


如果您想在装运前进行积极检查,您可以检查 a statusof COMPLETED,这是成功的 API 参考中记录的值https://developer.paypal.com/docs/api/orders/v2/#orders_capture

的可追回资金失败问题INSTRUMENT_DECLINED,以及任何不可追回的情况,应按照https://developer.paypal.com/demo/checkout/#/pattern/server中的逻辑处理


推荐阅读