Skip to content

Commit

Permalink
fix(webhook): check string id
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis committed Apr 12, 2024
1 parent 350aa96 commit 6f40716
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions functions/routes/appmax/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ exports.post = ({ appSdk }, req, res) => {
maxRedirects: 0,
validateStatus
}).then(async ({ data }) => {
console.log('order', JSON.stringify(data))
const status = data && data.data && data.data.status
console.log('status', status)
const orderRequest = await findOrderByTransactionId(appSdk, storeId, auth, id)
if (orderRequest && Array.isArray(orderRequest.result) && orderRequest.result.length) {
const order = orderRequest.result[0]
console.log('order ecom', JSON.stringify(order))
const transaction = order.transactions.find(({ intermediator }) => {
return intermediator && intermediator.transaction_id === id
return intermediator && intermediator.transaction_id === String(id)
})
if (transaction && transaction._id) {
const eventTreatement = appmaxTransaction.event === 'OrderChargeBackInTreatment'
Expand Down

0 comments on commit 6f40716

Please sign in to comment.