Skip to content

Commit 56f2daa

Browse files
Copilotniemyjski
andcommitted
Update Stripe.net to v49.0.0 and fix breaking API changes
Co-authored-by: niemyjski <1020579+niemyjski@users.noreply.github.com>
1 parent c07716a commit 56f2daa

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/Exceptionless.Core/Exceptionless.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.8" />
3232
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.8" />
3333
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.8" />
34-
<PackageReference Include="Stripe.net" Version="48.0.2" />
34+
<PackageReference Include="Stripe.net" Version="49.0.0" />
3535
<PackageReference Include="System.DirectoryServices" Version="9.0.8" />
3636
<PackageReference Include="UAParser" Version="3.1.47" />
3737
<PackageReference Include="Foundatio.Repositories.Elasticsearch" Version="7.17.17" Condition="'$(ReferenceFoundatioRepositoriesSource)' == '' OR '$(ReferenceFoundatioRepositoriesSource)' == 'false'" />

src/Exceptionless.Web/Controllers/OrganizationController.cs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)