Skip to content

Commit

Permalink
fix(webhooks): Update debug errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Nov 24, 2023
1 parent 2f2e7d8 commit 9cf3fdf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions functions/lib/galaxpay/update-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const getAppData = require('../store-api/get-app-data')
const GalaxpayAxios = require('./create-access')
const axios = require('axios')
const { getProductsById } = require('../store-api/request-api')
const { error } = require('firebase-functions/logger')

const checkProducstExists = async (appSdk, storeId, items, auth) => {
// product may have been deleted but still belong to a subscription
Expand Down
9 changes: 8 additions & 1 deletion functions/routes/ecom/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,14 @@ exports.post = async ({ appSdk, admin }, req, res) => {
const transaction = Transactions[i]
if (transaction.value !== newSubscriptionValue && transaction.galaxPayId !== docSubscription.transactionId) {
await updateTransactionGalaxpay(galaxpayAxios, transaction.galaxPayId, newSubscriptionValue)
.catch(console.error)
.catch(error => {
if (error.response) {
const { status, data } = error.response
console.error('Error response: ', status, ' ', data && JSON.stringify(data))
} else {
console.error(error)
}
})
}
i += 1
}
Expand Down
4 changes: 4 additions & 0 deletions functions/routes/galaxpay/webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ exports.post = async ({ appSdk, admin }, req, res) => {
}
} catch (error) {
console.error(error)
if (error.response) {
const { status, data } = error.response
console.error('Error response: ', status, ' ', data && JSON.stringify(data))
}
}

res.sendStatus(200)
Expand Down

0 comments on commit 9cf3fdf

Please sign in to comment.