@@ -315,7 +315,7 @@ async function handleSubscriptionCreated(data: any) {
315315
316316 // Extract subscription information
317317 const priceId = data . items ?. data ?. [ 0 ] ?. price ?. id ;
318- const planName = getPlanName ( priceId ) ;
318+ const planName = getPlanName ( priceId ) || 'Premium Plan' ;
319319 const amount = formatAmount ( data . items ?. data ?. [ 0 ] ?. price ?. unit_amount || 0 , data . currency ) ;
320320 const billingPeriod = getBillingPeriod ( data . items ?. data ?. [ 0 ] ?. price ?. recurring ?. interval ) ;
321321 const emailConfig = await getEmailConfig ( ) ;
@@ -361,7 +361,7 @@ async function handleSubscriptionUpdated(data: any) {
361361
362362 // Extract subscription information
363363 const priceId = data . items ?. data ?. [ 0 ] ?. price ?. id ;
364- const planName = getPlanName ( priceId ) ;
364+ const planName = getPlanName ( priceId ) || 'Premium Plan' ;
365365 const amount = formatAmount ( data . items ?. data ?. [ 0 ] ?. price ?. unit_amount || 0 , data . currency ) ;
366366 const billingPeriod = getBillingPeriod ( data . items ?. data ?. [ 0 ] ?. price ?. recurring ?. interval ) ;
367367
@@ -409,7 +409,7 @@ async function handleSubscriptionCancelled(data: any) {
409409 await webhookSubscriptionService . handleSubscriptionCancelled ( data ) ;
410410 const customerInfo = extractCustomerInfo ( data ) ;
411411 const priceId = data . items ?. data ?. [ 0 ] ?. price ?. id ;
412- const planName = getPlanName ( priceId ) ;
412+ const planName = getPlanName ( priceId ) || 'Premium Plan' ;
413413 const amount = formatAmount ( data . items ?. data ?. [ 0 ] ?. price ?. unit_amount || 0 , data . currency ) ;
414414 const billingPeriod = getBillingPeriod ( data . items ?. data ?. [ 0 ] ?. price ?. recurring ?. interval ) ;
415415
@@ -461,7 +461,7 @@ async function handleSubscriptionPaymentSucceeded(data: any) {
461461 // Extract payment information
462462 const amount = formatAmount ( data . amount_paid , data . currency ) ;
463463 const subscription = data . subscription ;
464- const planName = subscription ? getPlanName ( subscription . items ?. data ?. [ 0 ] ?. price ?. id ) : 'Premium Plan' ;
464+ const planName = subscription ? ( getPlanName ( subscription . items ?. data ?. [ 0 ] ?. price ?. id ) || 'Premium Plan' ) : 'Premium Plan' ;
465465 const billingPeriod = subscription
466466 ? getBillingPeriod ( subscription . items ?. data ?. [ 0 ] ?. price ?. recurring ?. interval )
467467 : 'month' ;
@@ -508,7 +508,7 @@ async function handleSubscriptionPaymentFailed(data: any) {
508508 // Extract payment information
509509 const amount = formatAmount ( data . amount_due , data . currency ) ;
510510 const subscription = data . subscription ;
511- const planName = subscription ? getPlanName ( subscription . items ?. data ?. [ 0 ] ?. price ?. id ) : 'Premium Plan' ;
511+ const planName = subscription ? ( getPlanName ( subscription . items ?. data ?. [ 0 ] ?. price ?. id ) || 'Premium Plan' ) : 'Premium Plan' ;
512512 const billingPeriod = subscription
513513 ? getBillingPeriod ( subscription . items ?. data ?. [ 0 ] ?. price ?. recurring ?. interval )
514514 : 'month' ;
@@ -555,7 +555,7 @@ async function handleSubscriptionTrialEnding(data: any) {
555555
556556 // Extract subscription information
557557 const priceId = data . items ?. data ?. [ 0 ] ?. price ?. id ;
558- const planName = getPlanName ( priceId ) ;
558+ const planName = getPlanName ( priceId ) || 'Premium Plan' ;
559559 const amount = formatAmount ( data . items ?. data ?. [ 0 ] ?. price ?. unit_amount || 0 , data . currency ) ;
560560 const billingPeriod = getBillingPeriod ( data . items ?. data ?. [ 0 ] ?. price ?. recurring ?. interval ) ;
561561
0 commit comments