mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 01:52:49 -05:00
[AC-2965] Use OrganizationBillingService to purchase org when FF is on (#4737)
* Add PurchaseSubscription to OrganizationBillingService and call from OrganizationService.SignUpAsync when FF is on * Run dotnet format * Missed billing service DI for SCIM which uses the OrganizationService
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Billing.Models;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Models.Business;
|
||||
@ -14,4 +15,42 @@ public class OrganizationSignup : OrganizationUpgrade
|
||||
public string PaymentToken { get; set; }
|
||||
public int? MaxAutoscaleSeats { get; set; } = null;
|
||||
public string InitiationPath { get; set; }
|
||||
|
||||
public OrganizationSubscriptionPurchase ToSubscriptionPurchase(bool fromProvider = false)
|
||||
{
|
||||
if (!PaymentMethodType.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var metadata = new OrganizationSubscriptionPurchaseMetadata(fromProvider, IsFromSecretsManagerTrial);
|
||||
|
||||
var passwordManager = new OrganizationPasswordManagerSubscriptionPurchase(
|
||||
AdditionalStorageGb,
|
||||
PremiumAccessAddon,
|
||||
AdditionalSeats);
|
||||
|
||||
var paymentSource = new TokenizedPaymentSource(PaymentMethodType.Value, PaymentToken);
|
||||
|
||||
var secretsManager = new OrganizationSecretsManagerSubscriptionPurchase(
|
||||
AdditionalSmSeats ?? 0,
|
||||
AdditionalServiceAccounts ?? 0);
|
||||
|
||||
var taxInformation = new TaxInformation(
|
||||
TaxInfo.BillingAddressCountry,
|
||||
TaxInfo.BillingAddressPostalCode,
|
||||
TaxInfo.TaxIdNumber,
|
||||
TaxInfo.BillingAddressLine1,
|
||||
TaxInfo.BillingAddressLine2,
|
||||
TaxInfo.BillingAddressCity,
|
||||
TaxInfo.BillingAddressState);
|
||||
|
||||
return new OrganizationSubscriptionPurchase(
|
||||
metadata,
|
||||
passwordManager,
|
||||
paymentSource,
|
||||
Plan,
|
||||
UseSecretsManager ? secretsManager : null,
|
||||
taxInformation);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user