@@ -215,13 +215,17 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
215215 id = "in_" + id ;
216216
217217 Stripe . Invoice ? stripeInvoice = null ;
218- PriceService ? priceService = null ;
219218 try
220219 {
221220 var client = new StripeClient ( _options . StripeOptions . StripeApiKey ) ;
222221 var invoiceService = new InvoiceService ( client ) ;
223- priceService = new PriceService ( client ) ;
224- stripeInvoice = await invoiceService . GetAsync ( id ) ;
222+
223+ // In Stripe.net v48, expand line items to include price data
224+ var options = new InvoiceGetOptions
225+ {
226+ Expand = new List < string > { "lines.data.price" }
227+ } ;
228+ stripeInvoice = await invoiceService . GetAsync ( id , options ) ;
225229 }
226230 catch ( Exception ex )
227231 {
@@ -249,23 +253,13 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
249253 {
250254 var item = new InvoiceLineItem { Amount = line . Amount / 100.0m , Description = line . Description } ;
251255
252- // In Stripe.net v48, the Price object property was removed from InvoiceLineItem
253- // but the price ID should be available as a direct string property
254- if ( priceService is not null && ! String . IsNullOrEmpty ( line . Price ) )
256+ // With expansion, the Price property should be available in Stripe.net v48
257+ if ( line . Price is not null )
255258 {
256- try
257- {
258- var price = await priceService . GetAsync ( line . Price ) ;
259- string planName = price . Nickname ?? _billingManager . GetBillingPlan ( price . Id ) ? . Name ?? price . Id ;
260- var intervalText = price . Recurring ? . Interval ?? "one-time" ;
261- var priceAmount = price . UnitAmount . HasValue ? ( price . UnitAmount . Value / 100.0 ) : 0.0 ;
262- item . Description = $ "Exceptionless - { planName } Plan ({ priceAmount : c} /{ intervalText } )";
263- }
264- catch ( StripeException ex )
265- {
266- _logger . LogWarning ( ex , "Failed to get price details for price ID: {PriceId}" , line . Price ) ;
267- // Fall back to original description if price lookup fails
268- }
259+ string planName = line . Price . Nickname ?? _billingManager . GetBillingPlan ( line . Price . Id ) ? . Name ?? line . Price . Id ;
260+ var intervalText = line . Price . Recurring ? . Interval ?? "one-time" ;
261+ var priceAmount = line . Price . UnitAmount . HasValue ? ( line . Price . UnitAmount . Value / 100.0 ) : 0.0 ;
262+ item . Description = $ "Exceptionless - { planName } Plan ({ priceAmount : c} /{ intervalText } )";
269263 }
270264
271265 var periodStart = line . Period . Start >= DateTime . MinValue ? line . Period . Start : stripeInvoice . PeriodStart ;
@@ -274,6 +268,12 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id)
274268 invoice . Items . Add ( item ) ;
275269 }
276270
271+ var periodStart = line . Period . Start >= DateTime . MinValue ? line . Period . Start : stripeInvoice . PeriodStart ;
272+ var periodEnd = line . Period . End >= DateTime . MinValue ? line . Period . End : stripeInvoice . PeriodEnd ;
273+ item . Date = $ "{ periodStart . ToShortDateString ( ) } - { periodEnd . ToShortDateString ( ) } ";
274+ invoice . Items . Add ( item ) ;
275+ }
276+
277277 var coupon = stripeInvoice . Discounts ? . FirstOrDefault ( d => d . Deleted is false ) ? . Coupon ;
278278 if ( coupon is not null )
279279 {
0 commit comments