-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[AC-2678] Enterprise to Families Sponsorship Bugs #4118
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4118 +/- ##
=======================================
Coverage 39.10% 39.10%
=======================================
Files 1203 1203
Lines 58179 58178 -1
Branches 5355 5354 -1
=======================================
Hits 22748 22748
Misses 34360 34360
+ Partials 1071 1070 -1 ☔ View full report in Codecov by Sentry. |
r-tome
approved these changes
May 23, 2024
amorask-bitwarden
approved these changes
May 23, 2024
jlf0dev
approved these changes
May 23, 2024
No New Or Fixed Issues Found |
withinfocus
pushed a commit
that referenced
this pull request
Jul 9, 2024
* Removed prorationDate as it wasn't used, and wasn't needed * Fixed logic to detect if a subscription was sponsored * Moved OrganizationSponsorshipsController.cs to Billing folder
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Objective
This PR resolves two bugs:
Depending on how fast the server could process the request, redeeming a sponsorship would sometimes fail. This was due to our manually setting
prorationDate
on the StripeSubscriptionUpdateOptions
object to the value ofDateTime.UtcNow
. Occasionally, theDateTime.UtcNow
value would be before the lower bound of the Stripe subscriptions billing cycle, causing Stripe to throw an exception since you cannot have a proration set to before the subscription began.After some investigation and testing, we found that
prorationDate
was always being set toDateTime.UtcNow
throughout the app. By removing all references toprorationDate
we're effectively setting it tonull
on theSubscriptionUpdateOptions
. When Stripe receives an update to a subscription with a proration behavior, but no proration date set, then they set it to "now" on their end, ensuring that it will never be before the billing cycle begins.A potential reason you might want to set
prorationDate
would be to apply exactly the same proration that was previewed with the upcoming invoice endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations. We have no need for this logic, so it's being culled.After an organization was successfully sponsored if the sponsoring enterprise organization is then deleted, or the sponsorship relationship otherwise removed, the free families price would never be updated to be full price again.
When we receive the
invoice.upcoming
webhook event from Stripe, we check if the invoice is for a sponsored organization. If it is for a sponsored organization, and the sponsoring enterprise organization is deleted or the sponsorship relationship otherwise removed, then we update the subscription to be a full priced family plan. This was broken since the webhook was looking to see if the subscription's ID matched our hard-coded IDs for a sponsored price, instead of checking the price IDs on the subscription itself.Code changes
Changes around removing
prorationDate
Change to update organization to full-priced Family plan
Before you submit
dotnet format --verify-no-changes
) (required)