Skip to content

Commit

Permalink
fix(galaxpay-webhook): prevent error with undefined subscription plan
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 authored Sep 12, 2023
1 parent 1732efb commit fc5f6c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion functions/routes/galaxpay/webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ exports.post = async ({ appSdk, admin }, req, res) => {
current: parseStatus(galaxPayTransactionStatus)
}

const planPergentage = plan.discount.type === 'percentage' || plan.discount.percentage
const planPergentage = plan?.discount
? plan.discount.type === 'percentage' || plan.discount.percentage
: null
let notes = `Parcela #${quantity} desconto de ${planPergentage ? '' : 'R$'}`
notes += ` ${plan.discount.value} ${planPergentage ? '%' : ''}`
notes += ` sobre ${plan.discount.apply_at}`
Expand Down

0 comments on commit fc5f6c1

Please sign in to comment.