mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 08:32:50 -05:00

* [AC-1423] Add AddonProduct and BitwardenProduct properties to BillingSubscriptionItem (#3037) * [AC-1423] Add AddonProduct and BitwardenProduct properties to BillingSubscriptionItem * [AC-1423] Add helper to StaticStore.cs to find a Plan by StripePlanId * [AC-1423] Use the helper method to set SubscriptionInfo.BitwardenProduct * Add SecretsManagerBilling feature flag to Constants * [AC 1409] Secrets Manager Subscription Stripe Integration (#3019) * [AC-1418] Add missing SecretsManagerPlan property to OrganizationResponseModel (#3055) * [AC 1460] Update Stripe Configuration (#3070) * [AC 1410] Secrets Manager subscription adjustment back-end changes (#3036) * Create UpgradeSecretsManagerSubscription command * [AC-1495] Extract UpgradePlanAsync into a command (#3081) * This is a pure lift & shift with no refactors * [AC-1503] Fix Stripe integration on organization upgrade (#3084) * Fix SM parameters not being passed to Stripe * [AC-1504] Allow SM max autoscale limits to be disabled (#3085) * [AC-1488] Changed SM Signup and Upgrade paths to set SmServiceAccounts to include the plan BaseServiceAccount (#3086) * [AC-1510] Enable access to Secrets Manager to Organization owner for new Subscription (#3089) * Revert changes to ReferenceEvent code (#3091) This will be done in AC-1481 * Add UsePasswordManager to sync data (#3114) * [AC-1522] Fix service account check on upgrading (#3111) * [AC-1521] Address checkmarx security feedback (#3124) * Reinstate target attribute but add noopener noreferrer * Update date on migration script --------- Co-authored-by: Shane Melton <smelton@bitwarden.com> Co-authored-by: Thomas Rittson <trittson@bitwarden.com> Co-authored-by: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Co-authored-by: cyprain-okeke <cokeke@bitwarden.com> Co-authored-by: Rui Tomé <108268980+r-tome@users.noreply.github.com> Co-authored-by: Conner Turnbull <cturnbull@bitwarden.com> Co-authored-by: Rui Tome <rtome@bitwarden.com>
111 lines
4.2 KiB
C#
111 lines
4.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Business;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Api.Models.Request.Organizations;
|
|
|
|
public class OrganizationCreateRequestModel : IValidatableObject
|
|
{
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string Name { get; set; }
|
|
[StringLength(50)]
|
|
public string BusinessName { get; set; }
|
|
[Required]
|
|
[StringLength(256)]
|
|
[EmailAddress]
|
|
public string BillingEmail { get; set; }
|
|
public PlanType PlanType { get; set; }
|
|
[Required]
|
|
public string Key { get; set; }
|
|
public OrganizationKeysRequestModel Keys { get; set; }
|
|
public PaymentMethodType? PaymentMethodType { get; set; }
|
|
public string PaymentToken { get; set; }
|
|
[Range(0, int.MaxValue)]
|
|
public int AdditionalSeats { get; set; }
|
|
[Range(0, 99)]
|
|
public short? AdditionalStorageGb { get; set; }
|
|
public bool PremiumAccessAddon { get; set; }
|
|
[EncryptedString]
|
|
[EncryptedStringLength(1000)]
|
|
public string CollectionName { get; set; }
|
|
public string TaxIdNumber { get; set; }
|
|
public string BillingAddressLine1 { get; set; }
|
|
public string BillingAddressLine2 { get; set; }
|
|
public string BillingAddressCity { get; set; }
|
|
public string BillingAddressState { get; set; }
|
|
public string BillingAddressPostalCode { get; set; }
|
|
[StringLength(2)]
|
|
public string BillingAddressCountry { get; set; }
|
|
public int? MaxAutoscaleSeats { get; set; }
|
|
[Range(0, int.MaxValue)]
|
|
public int? AdditionalSmSeats { get; set; }
|
|
[Range(0, int.MaxValue)]
|
|
public int? AdditionalServiceAccounts { get; set; }
|
|
[Required]
|
|
public bool UseSecretsManager { get; set; }
|
|
|
|
public virtual OrganizationSignup ToOrganizationSignup(User user)
|
|
{
|
|
var orgSignup = new OrganizationSignup
|
|
{
|
|
Owner = user,
|
|
OwnerKey = Key,
|
|
Name = Name,
|
|
Plan = PlanType,
|
|
PaymentMethodType = PaymentMethodType,
|
|
PaymentToken = PaymentToken,
|
|
AdditionalSeats = AdditionalSeats,
|
|
MaxAutoscaleSeats = MaxAutoscaleSeats,
|
|
AdditionalStorageGb = AdditionalStorageGb.GetValueOrDefault(0),
|
|
PremiumAccessAddon = PremiumAccessAddon,
|
|
BillingEmail = BillingEmail,
|
|
BusinessName = BusinessName,
|
|
CollectionName = CollectionName,
|
|
AdditionalSmSeats = AdditionalSmSeats.GetValueOrDefault(),
|
|
AdditionalServiceAccounts = AdditionalServiceAccounts.GetValueOrDefault(),
|
|
UseSecretsManager = UseSecretsManager,
|
|
TaxInfo = new TaxInfo
|
|
{
|
|
TaxIdNumber = TaxIdNumber,
|
|
BillingAddressLine1 = BillingAddressLine1,
|
|
BillingAddressLine2 = BillingAddressLine2,
|
|
BillingAddressCity = BillingAddressCity,
|
|
BillingAddressState = BillingAddressState,
|
|
BillingAddressPostalCode = BillingAddressPostalCode,
|
|
BillingAddressCountry = BillingAddressCountry,
|
|
},
|
|
};
|
|
|
|
Keys?.ToOrganizationSignup(orgSignup);
|
|
|
|
return orgSignup;
|
|
}
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
if (PlanType != PlanType.Free && string.IsNullOrWhiteSpace(PaymentToken))
|
|
{
|
|
yield return new ValidationResult("Payment required.", new string[] { nameof(PaymentToken) });
|
|
}
|
|
if (PlanType != PlanType.Free && !PaymentMethodType.HasValue)
|
|
{
|
|
yield return new ValidationResult("Payment method type required.",
|
|
new string[] { nameof(PaymentMethodType) });
|
|
}
|
|
if (PlanType != PlanType.Free && string.IsNullOrWhiteSpace(BillingAddressCountry))
|
|
{
|
|
yield return new ValidationResult("Country required.",
|
|
new string[] { nameof(BillingAddressCountry) });
|
|
}
|
|
if (PlanType != PlanType.Free && BillingAddressCountry == "US" &&
|
|
string.IsNullOrWhiteSpace(BillingAddressPostalCode))
|
|
{
|
|
yield return new ValidationResult("Zip / postal code is required.",
|
|
new string[] { nameof(BillingAddressPostalCode) });
|
|
}
|
|
}
|
|
}
|