1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-12 21:27:35 -05:00

[PM-8445] Allow for organization sales with no payment method for trials (#4800)

* Allow for OrganizationSales with no payment method

* Run dotnet format
This commit is contained in:
Alex Morask
2024-09-25 08:55:45 -04:00
committed by GitHub
parent 6514b342fc
commit 2e072aebe3
4 changed files with 112 additions and 101 deletions

View File

@ -4,7 +4,9 @@
public class CustomerSetup
{
public required TokenizedPaymentSource TokenizedPaymentSource { get; set; }
public required TaxInformation TaxInformation { get; set; }
public TokenizedPaymentSource? TokenizedPaymentSource { get; set; }
public TaxInformation? TaxInformation { get; set; }
public string? Coupon { get; set; }
public bool IsBillable => TokenizedPaymentSource != null && TaxInformation != null;
}

View File

@ -41,18 +41,27 @@ public class OrganizationSale
SubscriptionSetup = GetSubscriptionSetup(upgrade)
};
private static CustomerSetup? GetCustomerSetup(OrganizationSignup signup)
private static CustomerSetup GetCustomerSetup(OrganizationSignup signup)
{
var customerSetup = new CustomerSetup
{
Coupon = signup.IsFromProvider
? StripeConstants.CouponIDs.MSPDiscount35
: signup.IsFromSecretsManagerTrial
? StripeConstants.CouponIDs.SecretsManagerStandalone
: null
};
if (!signup.PaymentMethodType.HasValue)
{
return null;
return customerSetup;
}
var tokenizedPaymentSource = new TokenizedPaymentSource(
customerSetup.TokenizedPaymentSource = new TokenizedPaymentSource(
signup.PaymentMethodType!.Value,
signup.PaymentToken);
var taxInformation = new TaxInformation(
customerSetup.TaxInformation = new TaxInformation(
signup.TaxInfo.BillingAddressCountry,
signup.TaxInfo.BillingAddressPostalCode,
signup.TaxInfo.TaxIdNumber,
@ -61,18 +70,7 @@ public class OrganizationSale
signup.TaxInfo.BillingAddressCity,
signup.TaxInfo.BillingAddressState);
var coupon = signup.IsFromProvider
? StripeConstants.CouponIDs.MSPDiscount35
: signup.IsFromSecretsManagerTrial
? StripeConstants.CouponIDs.SecretsManagerStandalone
: null;
return new CustomerSetup
{
TokenizedPaymentSource = tokenizedPaymentSource,
TaxInformation = taxInformation,
Coupon = coupon
};
return customerSetup;
}
private static SubscriptionSetup GetSubscriptionSetup(OrganizationUpgrade upgrade)