mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[PM-12601] Add discount to MSP during creation in Admin Portal (#5391)
* Add Provider DiscountId to database and Stripe customer * Fix tests * Add missing EF migrations * Run dotnet format
This commit is contained in:
@ -35,6 +35,7 @@ public class Provider : ITableObject<Guid>, ISubscriber
|
||||
public GatewayType? Gateway { get; set; }
|
||||
public string? GatewayCustomerId { get; set; }
|
||||
public string? GatewaySubscriptionId { get; set; }
|
||||
public string? DiscountId { get; set; }
|
||||
|
||||
public string? BillingEmailAddress() => BillingEmail?.ToLowerInvariant().Trim();
|
||||
|
||||
|
@ -18,8 +18,15 @@ public static class StripeConstants
|
||||
|
||||
public static class CouponIDs
|
||||
{
|
||||
public const string MSPDiscount35 = "msp-discount-35";
|
||||
public const string LegacyMSPDiscount = "msp-discount-35";
|
||||
public const string SecretsManagerStandalone = "sm-standalone";
|
||||
|
||||
public static class MSPDiscounts
|
||||
{
|
||||
public const string Open = "msp-open-discount";
|
||||
public const string Silver = "msp-silver-discount";
|
||||
public const string Gold = "msp-gold-discount";
|
||||
}
|
||||
}
|
||||
|
||||
public static class ErrorCodes
|
||||
|
@ -254,7 +254,7 @@ public class ProviderMigrator(
|
||||
|
||||
await stripeAdapter.CustomerUpdateAsync(customer.Id, new CustomerUpdateOptions
|
||||
{
|
||||
Coupon = StripeConstants.CouponIDs.MSPDiscount35
|
||||
Coupon = StripeConstants.CouponIDs.LegacyMSPDiscount
|
||||
});
|
||||
|
||||
provider.GatewayCustomerId = customer.Id;
|
||||
|
@ -46,7 +46,8 @@ public class OrganizationSale
|
||||
var customerSetup = new CustomerSetup
|
||||
{
|
||||
Coupon = signup.IsFromProvider
|
||||
? StripeConstants.CouponIDs.MSPDiscount35
|
||||
// TODO: Remove when last of the legacy providers has been migrated.
|
||||
? StripeConstants.CouponIDs.LegacyMSPDiscount
|
||||
: signup.IsFromSecretsManagerTrial
|
||||
? StripeConstants.CouponIDs.SecretsManagerStandalone
|
||||
: null
|
||||
|
Reference in New Issue
Block a user