Skip to content

Commit

Permalink
fix(galaxpay-webhook): prevent error in case of undefined plan
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Sep 12, 2023
1 parent fc5f6c1 commit 9d2b0f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions functions/routes/galaxpay/webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ exports.post = async ({ appSdk, admin }, req, res) => {
? 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}`
notes += ` referente à ${subscriptionLabel} ${periodicity}`
if (planPergentage) {
notes += ` ${plan?.discount?.value || ''} ${planPergentage ? '%' : ''}`
notes += ` sobre ${plan?.discount?.apply_at || ''}`
notes += ` referente à ${subscriptionLabel} ${periodicity}`
}

body = {
opened_at: new Date().toISOString(),
Expand Down

0 comments on commit 9d2b0f6

Please sign in to comment.