Skip to content

Commit

Permalink
chore: update webhook to get more log
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis committed Apr 12, 2024
1 parent 7dce5f0 commit 350aa96
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions functions/routes/appmax/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const validateStatus = function (status) {
}

exports.post = ({ appSdk }, req, res) => {
console.log('>>Webhook Pagaleve: ')
const { body, query } = req
// https://docs.pagar.me/docs/gerenciando-postbacks
const storeId = Number(query.storeId)
Expand All @@ -46,6 +45,7 @@ exports.post = ({ appSdk }, req, res) => {
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
})
Expand All @@ -70,8 +70,12 @@ exports.post = ({ appSdk }, req, res) => {
flags: ['APPMAX, MGNR']
},
auth
)
res.status(200)
).then(response => {
console.log('update with success')
return res.status(200)
}).catch(error => {
console.log('erro de realizar update payment', error)
})
}
}
}).catch(err => {
Expand Down

0 comments on commit 350aa96

Please sign in to comment.