-
-
Notifications
You must be signed in to change notification settings - Fork 516
Bump Stripe.net from 47.4.0 to 49.0.0 and fix breaking API changes #1938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
9dfee0a
2395dcf
b32732f
b2479a2
ea39f39
1f13ded
25a00e2
b0bc8c4
77a7c41
80a9faf
048364e
539e0ef
ba014dc
c07716a
56f2daa
56a1efd
faa6d3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -239,26 +239,24 @@ public async Task<ActionResult<Invoice>> GetInvoiceAsync(string id) | |||||
OrganizationId = organization.Id, | ||||||
OrganizationName = organization.Name, | ||||||
Date = stripeInvoice.Created, | ||||||
Paid = stripeInvoice.Paid, | ||||||
Paid = String.Equals(stripeInvoice.Status, "paid"), | ||||||
Total = stripeInvoice.Total / 100.0m | ||||||
}; | ||||||
|
||||||
foreach (var line in stripeInvoice.Lines.Data) | ||||||
{ | ||||||
var item = new InvoiceLineItem { Amount = line.Amount / 100.0m, Description = line.Description }; | ||||||
if (line.Plan is not null) | ||||||
{ | ||||||
string planName = line.Plan.Nickname ?? _billingManager.GetBillingPlan(line.Plan.Id)?.Name ?? line.Plan.Id; | ||||||
item.Description = $"Exceptionless - {planName} Plan ({(line.Plan.Amount / 100.0):c}/{line.Plan.Interval})"; | ||||||
} | ||||||
// Note: In Stripe.net v48, Price property was removed from InvoiceLineItem | ||||||
// We'll use basic properties and avoid complex price details that are no longer available | ||||||
// The line.Description already contains the necessary information | ||||||
|
||||||
|
||||||
var periodStart = line.Period.Start >= DateTime.MinValue ? line.Period.Start : stripeInvoice.PeriodStart; | ||||||
var periodEnd = line.Period.End >= DateTime.MinValue ? line.Period.End : stripeInvoice.PeriodEnd; | ||||||
item.Date = $"{periodStart.ToShortDateString()} - {periodEnd.ToShortDateString()}"; | ||||||
invoice.Items.Add(item); | ||||||
} | ||||||
|
||||||
var coupon = stripeInvoice.Discount?.Coupon; | ||||||
var coupon = stripeInvoice.Discounts?.FirstOrDefault(d => d.Deleted is false)?.Coupon; | ||||||
if (coupon is not null) | ||||||
{ | ||||||
if (coupon.AmountOff.HasValue) | ||||||
|
@@ -429,15 +427,29 @@ public async Task<ActionResult<ChangePlanResult>> ChangePlanAsync(string id, str | |||||
var createCustomer = new CustomerCreateOptions | ||||||
{ | ||||||
Source = stripeToken, | ||||||
Plan = planId, | ||||||
Description = organization.Name, | ||||||
Email = CurrentUser.EmailAddress | ||||||
}; | ||||||
|
||||||
var customer = await customerService.CreateAsync(createCustomer); | ||||||
|
||||||
// Create subscription separately since Plan is deprecated in CustomerCreateOptions | ||||||
var subscriptionCreateOptions = new SubscriptionCreateOptions | ||||||
{ | ||||||
Customer = customer.Id, | ||||||
Items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions { Price = planId } } | ||||||
}; | ||||||
|
||||||
// Apply coupon as discount if provided | ||||||
if (!String.IsNullOrWhiteSpace(couponId)) | ||||||
createCustomer.Coupon = couponId; | ||||||
{ | ||||||
subscriptionCreateOptions.Discounts = new List<SubscriptionDiscountOptions> | ||||||
{ | ||||||
new SubscriptionDiscountOptions { Coupon = couponId } | ||||||
}; | ||||||
} | ||||||
|
||||||
var customer = await customerService.CreateAsync(createCustomer); | ||||||
await subscriptionService.CreateAsync(subscriptionCreateOptions); | ||||||
|
||||||
organization.BillingStatus = BillingStatus.Active; | ||||||
organization.RemoveSuspension(); | ||||||
|
@@ -446,8 +458,8 @@ public async Task<ActionResult<ChangePlanResult>> ChangePlanAsync(string id, str | |||||
} | ||||||
else | ||||||
{ | ||||||
var update = new SubscriptionUpdateOptions { Items = [] }; | ||||||
var create = new SubscriptionCreateOptions { Customer = organization.StripeCustomerId, Items = [] }; | ||||||
var update = new SubscriptionUpdateOptions { Items = new List<SubscriptionItemOptions>() }; | ||||||
|
var update = new SubscriptionUpdateOptions { Items = new List<SubscriptionItemOptions>() }; | |
var update = new SubscriptionUpdateOptions { Items = [] }; |
do we even need to initialize Items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified to use C# 12 collection expression []
syntax. We do need to initialize Items since we call .Add()
on it later (lines 499 and 504). Fixed in 78a8bcf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to latest version: 49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to Stripe.net v49.0.0 and fixed the breaking API changes. The main change in v49 is that InvoiceLineItem.Price was completely removed - now using Pricing.PriceDetails.Price for the price ID and fetching full Price objects via PriceService. Fixed in ee24f43.