Skip to content
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

[PM-12601] Add discount to MSP during creation in Admin Portal #5391

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

amorask-bitwarden
Copy link
Contributor

@amorask-bitwarden amorask-bitwarden commented Feb 11, 2025

🎟️ Tracking

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

📔 Objective

This PR adds a selectable discount type to the MSP creation screen in the Bitwarden Admin Portal. The select list options are mapped to Stripe Coupon IDs and those IDs are then stored in the database on the newly created, nullable Provider.DiscountId column.

Then, when the Stripe Customer for the Provider is created, the service checks for the existence of a DiscountId and uses that to attach the related Stripe Coupon to the Provider's Customer.

After this point, the remainder of the platform's functionality with relation to Provider discounts is driven off the Coupon attached to the Provider's customer.

I chose to forego a feature flag for this feature because it requires a database migration anyway and the actual code change is all just small additions that doesn't disrupt existing logic.

📸 Screenshots

Screen.Recording.2025-02-11.at.11.33.58.AM.mov

⏰ 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 previously approved these changes Feb 11, 2025
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 70.96774% with 9 lines in your changes missing coverage. Please review.

Project coverage is 44.56%. Comparing base (f4c37df) to head (1ef0ee6).

Files with missing lines Patch % Lines
...dmin/AdminConsole/Views/Providers/CreateMsp.cshtml 0.00% 7 Missing ⚠️
.../Commercial.Core/Billing/ProviderBillingService.cs 94.11% 0 Missing and 1 partial ⚠️
...ation/Services/Implementations/ProviderMigrator.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5391   +/-   ##
=======================================
  Coverage   44.56%   44.56%           
=======================================
  Files        1505     1505           
  Lines       69896    69912   +16     
  Branches     6285     6287    +2     
=======================================
+ Hits        31150    31159    +9     
- Misses      37414    37421    +7     
  Partials     1332     1332           

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

Copy link
Contributor

github-actions bot commented Feb 11, 2025

Logo
Checkmarx One – Scan Summary & Details5d26dd20-6b0d-4822-a040-aea0673cdd9b

New Issues (2)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM CSRF /src/Api/AdminConsole/Public/Controllers/GroupsController.cs: 110
detailsMethod Post at line 110 of /src/Api/AdminConsole/Public/Controllers/GroupsController.cs gets a parameter from a user request from model. This param...
Attack Vector
MEDIUM CSRF /src/Api/AdminConsole/Controllers/PoliciesController.cs: 168
detailsMethod GetMasterPasswordPolicy at line 168 of /src/Api/AdminConsole/Controllers/PoliciesController.cs gets a parameter from a user request from Get...
Attack Vector
Fixed Issues (6)

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

Severity Issue Source File / Package
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 176
MEDIUM CSRF /src/Billing/Controllers/StripeController.cs: 164
MEDIUM CSRF /src/Billing/Controllers/RecoveryController.cs: 38
MEDIUM CSRF /src/Api/AdminConsole/Controllers/GroupsController.cs: 164
MEDIUM CSRF /src/Api/Tools/Controllers/ImportCiphersController.cs: 47
MEDIUM CSRF /src/Api/Tools/Controllers/ImportCiphersController.cs: 63

Copy link
Contributor

@BTreston BTreston left a comment

Choose a reason for hiding this comment

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

Looks like there's a failing required test related to missing EF migrations.

@amorask-bitwarden
Copy link
Contributor Author

Looks like there's a failing required test related to missing EF migrations.

@BTreston Completely missed that! Thank you, I've added the migrations.

Copy link
Contributor

@BTreston BTreston left a comment

Choose a reason for hiding this comment

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

Small linter error, otherwise looks good


#nullable disable

namespace Bit.MySqlMigrations.Migrations
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe a semi-colon at the end here will fix these linter errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gah sorry about that I forgot to run dotnet format for the migrations. Should be good now.

Copy link
Contributor

@BTreston BTreston left a comment

Choose a reason for hiding this comment

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

AC code looks good, thank you!

Copy link
Contributor

@rkac-bw rkac-bw left a comment

Choose a reason for hiding this comment

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

lgtm

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