Skip to content

Commit

Permalink
fix(webhooks): update indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 28, 2023
1 parent 270ab49 commit 3eb5929
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
8 changes: 5 additions & 3 deletions functions/routes/ecom/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ exports.post = async ({ appSdk, admin }, req, res) => {
})
})
})
} else if (trigger.resource === 'orders' && trigger.body.status
&& trigger.body.status !== 'cancelled' && trigger.action !== 'create'
&& trigger.fields.includes('items')) {
} else if (
trigger.resource === 'orders' && trigger.body.status &&
trigger.body.status !== 'cancelled' && trigger.action !== 'create' &&
trigger.fields.includes('items')
) {
console.log('>> ', JSON.stringify(trigger))
// When the original order is edited
try {
Expand Down
17 changes: 8 additions & 9 deletions functions/routes/galaxpay/webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const {
compareDocItemsWithOrder,
updateValueSubscriptionGalaxpay
} = require('../../lib/galaxpay/update-subscription')
const {
const {
createItemsAndAmount,
updateDocSubscription
updateDocSubscription
} = require('./../../lib/firestore/utils')
const getAppData = require('./../../lib/store-api/get-app-data')
const GalaxpayAxios = require('./../../lib/galaxpay/create-access')
Expand Down Expand Up @@ -138,7 +138,6 @@ exports.post = async ({ appSdk, admin }, req, res) => {
...newShippingLine
}
shippingMethodLabel = newShippingLine.label


if (amount.balance) {
delete amount.balance
Expand Down Expand Up @@ -573,19 +572,19 @@ exports.post = async ({ appSdk, admin }, req, res) => {
},
{ merge: true }
)
try{

try {
const appData = await getAppData({ appSdk, storeId, auth })

const galaxpayAxios = new GalaxpayAxios(appData.galaxpay_id, appData.galaxpay_hash, storeId)
await galaxpayAxios.preparing

let { data } = await galaxpayAxios.axios
const { data } = await galaxpayAxios.axios
.get(`/transactions?galaxPayIds=${GalaxPayTransaction.galaxPayId}&startAt=0&limit=1`)

const total = itemsAndAmount?.amount?.total && Math.floor((itemsAndAmount?.amount?.total).toFixed(2) * 100)
// console.log('>> ', data?.Transactions[0]?.value, ' ', total , ' ', JSON.stringify(data))
const hasUpdateValue = total && data?.Transactions[0]?.value && total !== data?.Transactions[0]?.value
const hasUpdateValue = total && data?.Transactions[0]?.value && total !== data?.Transactions[0]?.value
if (hasUpdateValue) {
const resp = await updateValueSubscriptionGalaxpay(galaxpayAxios, subscriptionId, total)
if (resp) {
Expand All @@ -597,7 +596,7 @@ exports.post = async ({ appSdk, admin }, req, res) => {
await updateDocSubscription(collectionSubscription, body, subscriptionId)
}
}
} catch (error){
} catch (error) {
console.error(error)
}

Expand Down

0 comments on commit 3eb5929

Please sign in to comment.