【发布时间】:2017-04-21 02:21:31
【问题描述】:
如何从 Braintree 的 webhook 通知中获取客户 ID?
例如,我可以执行以下操作来获取他们的 ID:
gateway.webhookNotification.parse(sampleNotification.bt_signature, sampleNotification.bt_payload, (err, webhookNotification) => {
let customerId = webhookNotification.subject.subscription.transactions[0].customer.id;
});
但这要求用户首先至少有一笔交易。如果客户还没有任何交易(例如新用户),我如何获取客户的 ID?
这是登录webhookNotification时的响应:
WebhookNotification {
timestamp: '2017-04-30T11:01:33Z',
kind: 'subscription_charged_unsuccessfully',
subject: {
subscription: {
id: 'jywgnr',
transactions: [],
addOns: [],
discounts: []
}
},
subscription: Subscription {
id: 'jywgnr',
transactions: [],
addOns: [],
discounts: []
}
}
【问题讨论】: