我有一个webhook,我的Square帐户每次在订单上发生PAYMENT_UPDATED
事件时都会发出请求。我在这里关注API文档:https://docs.connect.squareup.com/api/connect/v1/#setupwebhooks
它表示webhook使用以下参数向我的应用发出请求:
{
"merchant_id": "18YC4JBH91E1H",
"location_id": "JGHJ0343",
"event_type": "PAYMENT_UPDATED",
"entity_id": "Jq74mCczmFXk1tC10GB"
}
这是我的节点应用程序中的代码:
index.js
app.post("/payment_notifications", (req, resp) => {
paymentService.receivePayment(req.body, resp);
});
payment_service.js
module.exports = {
receivePayment(requestBody, response){
const { entity_id, location_id, merchant_id } = requestBody;
console.log("payment_id: ", entity_id);
console.log("location_id: ", location_id);
console.log("merchant_id: ", merchant_id);
console.dir("requestBody: ", requestBody);
console.dir("requestBody.merchant_id: ", requestBody.merchant_id);
console.dir("requestBody.location_id: ", requestBody.location_id);
getPayment(entity_id, location_id, merchant_id);
response.sendStatus(200);
},
};
我的应用在每个订单的日志中为location_id
和merchant_id
打印相同的值。我检查了我的数据库,该ID是位置ID,而不是商家ID
2016-11-07T17:28:55.770302+00:00 app[web.1]: payment_id: paymentId123123
2016-11-07T17:28:55.770328+00:00 app[web.1]: location_id: 6HB994C06J6PE
2016-11-07T17:28:55.770366+00:00 app[web.1]: merchant_id: 6HB994C06J6PE
发生了什么事?
答案 0 :(得分:0)
很抱歉,对于大多数多单元商家来说,webhook请求只会包含位置ID。我们正在努力将我的webhooks服务升级到v2版本,并将在此过程中解决此问题。
在此期间,您可以随意使用v1/{{location_id}}/business
端点从这些通知中获取正确的商家ID。