1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-06 13:38:13 -05:00

plan adjustments (#890)

This commit is contained in:
Kyle Spearrin 2020-08-25 14:23:36 -04:00 committed by GitHub
parent 2fb18d8cf2
commit 2cd6d4f61a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 34 deletions

View File

@ -734,7 +734,7 @@ namespace Bit.Core.Services
var storageItem = sub.Items?.FirstOrDefault(i => i.Plan.Id == storagePlanId);
// Retain original collection method
var collectionMethod = sub.CollectionMethod;
var subResponse = await subscriptionService.UpdateAsync(sub.Id, new SubscriptionUpdateOptions
{
Items = new List<SubscriptionItemOptions>
@ -942,7 +942,7 @@ namespace Bit.Core.Services
{
throw new GatewayException("Failed to charge PayPal customer.");
}
braintreeTransaction = transactionResult.Target;
invoice = await invoiceService.UpdateAsync(invoice.Id, new InvoiceUpdateOptions
{
@ -1557,39 +1557,39 @@ namespace Bit.Core.Services
public async Task<TaxInfo> GetTaxInfoAsync(ISubscriber subscriber)
{
if (subscriber != null && !string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
if (subscriber == null || string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
{
var customerService = new CustomerService();
var customer = await customerService.GetAsync(subscriber.GatewayCustomerId);
if (customer == null)
{
return null;
}
var address = customer.Address;
var taxId = customer.TaxIds?.FirstOrDefault();
// Line1 is required, so if missing we're using the subscriber name
// see: https://stripe.com/docs/api/customers/create#create_customer-address-line1
if (address != null && string.IsNullOrWhiteSpace(address.Line1))
{
address.Line1 = null;
}
return new TaxInfo
{
TaxIdNumber = taxId?.Value,
BillingAddressLine1 = address?.Line1,
BillingAddressLine2 = address?.Line2,
BillingAddressCity = address?.City,
BillingAddressState = address?.State,
BillingAddressPostalCode = address?.PostalCode,
BillingAddressCountry = address?.Country,
};
return null;
}
return null;
var customerService = new CustomerService();
var customer = await customerService.GetAsync(subscriber.GatewayCustomerId);
if (customer == null)
{
return null;
}
var address = customer.Address;
var taxId = customer.TaxIds?.FirstOrDefault();
// Line1 is required, so if missing we're using the subscriber name
// see: https://stripe.com/docs/api/customers/create#create_customer-address-line1
if (address != null && string.IsNullOrWhiteSpace(address.Line1))
{
address.Line1 = null;
}
return new TaxInfo
{
TaxIdNumber = taxId?.Value,
BillingAddressLine1 = address?.Line1,
BillingAddressLine2 = address?.Line2,
BillingAddressCity = address?.City,
BillingAddressState = address?.State,
BillingAddressPostalCode = address?.PostalCode,
BillingAddressCountry = address?.Country,
};
}
public async Task SaveTaxInfoAsync(ISubscriber subscriber, TaxInfo taxInfo)

View File

@ -123,9 +123,9 @@ namespace Bit.Core.Utilities
IsAnnual = true,
NameLocalizationKey = "planNameFamilies",
DescriptionLocalizationKey = "planDescFamilies",
BaseSeats = 6,
BaseSeats = 5,
BaseStorageGb = 1,
MaxUsers = 6,
MaxUsers = 5,
HasAdditionalStorageOption = true,
HasPremiumAccessOption = true,
@ -287,6 +287,7 @@ namespace Bit.Core.Utilities
BaseStorageGb = 1,
MaxUsers = 6,
HasAdditionalStorageOption = true,
TrialPeriodDays = 7,
HasSelfHost = true,