@@ -219,13 +219,7 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
219219 {
220220 var client = new StripeClient ( _options . StripeOptions . StripeApiKey ) ;
221221 var invoiceService = new InvoiceService ( client ) ;
222-
223- // In Stripe.net v48, expand to include all necessary price information
224- var options = new InvoiceGetOptions
225- {
226- Expand = new List < string > { "lines" , "lines.data.price" }
227- } ;
228- stripeInvoice = await invoiceService . GetAsync ( id , options ) ;
222+ stripeInvoice = await invoiceService . GetAsync ( id ) ;
229223 }
230224 catch ( Exception ex )
231225 {
@@ -249,15 +243,30 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
249243 Total = stripeInvoice . Total / 100.0m
250244 } ;
251245
246+ // In Stripe.net v49, Price information needs to be fetched separately
247+ var client2 = new StripeClient ( _options . StripeOptions . StripeApiKey ) ;
248+ var priceService = new PriceService ( client2 ) ;
249+
252250 foreach ( var line in stripeInvoice . Lines . Data )
253251 {
254252 var item = new InvoiceLineItem { Amount = line . Amount / 100.0m , Description = line . Description } ;
255- if ( line . Price is not null )
253+
254+ // In v49, access price ID from Pricing.PriceDetails.Price
255+ var priceId = line . Pricing ? . PriceDetails ? . Price ;
256+ if ( ! String . IsNullOrEmpty ( priceId ) )
256257 {
257- string planName = line . Price . Nickname ?? _billingManager . GetBillingPlan ( line . Price . Id ) ? . Name ?? line . Price . Id ;
258- var intervalText = line . Price . Recurring ? . Interval ?? "one-time" ;
259- var priceAmount = line . Price . UnitAmount . HasValue ? ( line . Price . UnitAmount . Value / 100.0 ) : 0.0 ;
260- item . Description = $ "Exceptionless - { planName } Plan ({ priceAmount : c} /{ intervalText } )";
258+ try
259+ {
260+ var price = await priceService . GetAsync ( priceId ) ;
261+ string planName = price . Nickname ?? _billingManager . GetBillingPlan ( price . Id ) ? . Name ?? price . Id ;
262+ var intervalText = price . Recurring ? . Interval ?? "one-time" ;
263+ var priceAmount = line . Pricing ? . UnitAmountDecimal . HasValue == true ? ( line . Pricing . UnitAmountDecimal . Value / 100.0m ) : 0.0m ;
264+ item . Description = $ "Exceptionless - { planName } Plan ({ priceAmount : c} /{ intervalText } )";
265+ }
266+ catch ( Exception ex )
267+ {
268+ _logger . LogWarning ( ex , "Failed to fetch price details for price ID: {PriceId}" , priceId ) ;
269+ }
261270 }
262271
263272 var periodStart = line . Period . Start >= DateTime . MinValue ? line . Period . Start : stripeInvoice . PeriodStart ;
0 commit comments