Skip to content

Conversation

@jonashendrickx
Copy link
Contributor

@jonashendrickx jonashendrickx commented Apr 10, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-20090

📔 Objective

An additional check has been placed on the POST /organizations/{orgid}/billing/restart-subscription endpoint to prevent an additional subscription from being created if the customer already has an active subscription in Stripe (definition not in a canceled status).

📸 Screenshots

https://bitwarden.atlassian.net/browse/PM-20090?focusedCommentId=93746

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@jonashendrickx jonashendrickx changed the title Restarting subscription for unpaid organizations [PM-20090] Restarting subscription for unpaid organizations Apr 10, 2025
@codecov
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 10 lines in your changes missing coverage. Please review.

Project coverage is 45.81%. Comparing base (d85807e) to head (915828e).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...ices/Implementations/OrganizationBillingService.cs 35.71% 6 Missing and 3 partials ⚠️
src/Core/Models/Business/SubscriptionInfo.cs 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5635      +/-   ##
==========================================
+ Coverage   45.73%   45.81%   +0.08%     
==========================================
  Files        1603     1609       +6     
  Lines       72659    73181     +522     
  Branches     6507     6558      +51     
==========================================
+ Hits        33229    33529     +300     
- Misses      38018    38221     +203     
- Partials     1412     1431      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jonashendrickx jonashendrickx marked this pull request as ready for review April 10, 2025 17:02
@jonashendrickx jonashendrickx requested a review from a team as a code owner April 10, 2025 17:02
@github-actions
Copy link
Contributor

github-actions bot commented Apr 10, 2025

Logo
Checkmarx One – Scan Summary & Detailsf9d44fe2-be93-4dcf-bc30-79dd887bdff0

Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Admin/Billing/Controllers/BusinessUnitConversionController.cs: 70

CancelledDate = sub.CanceledAt;
CancelAtEndDate = sub.CancelAtPeriodEnd;
Cancelled = sub.Status == "canceled" || sub.Status == "unpaid" || sub.Status == "incomplete_expired";
Cancelled = sub.Status is StripeConstants.SubscriptionStatus.Canceled or StripeConstants.SubscriptionStatus.IncompleteExpired;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ This property is used in 13 places throughout the web application so changing it here is almost certainly going to have downstream effects.

For example:

Organization disablement may handle some of this, but if all we're trying to do is prevent the POST restart-subscription endpoint from being invoked when the subscription is "unpaid", I think it would be more straightforward to find that point of invocation in the web app and prevent it there using the subscription.status property.

Let me know your thoughts.

CancelledDate = sub.CanceledAt;
CancelAtEndDate = sub.CancelAtPeriodEnd;
Cancelled = sub.Status == "canceled" || sub.Status == "unpaid" || sub.Status == "incomplete_expired";
Cancelled = sub.Status is StripeConstants.SubscriptionStatus.Canceled or StripeConstants.SubscriptionStatus.Unpaid or StripeConstants.SubscriptionStatus.IncompleteExpired;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a stylistic change. But might help navigate the code base faster related to specific subscription statuses.

@sonarqubecloud
Copy link

Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do if have a situation where customer that has other status are able to call this endpoint today?

@amorask-bitwarden amorask-bitwarden deleted the PM-20090 branch April 15, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants