mirror of
https://github.com/bitwarden/server.git
synced 2025-02-01 23:31:41 +01:00
null checked Stripe.Customer.Address for org seat and storage upgrades (#1099)
This commit is contained in:
parent
fe4c36c04a
commit
001bbf2f2b
@ -415,20 +415,24 @@ namespace Bit.Core.Services
|
|||||||
};
|
};
|
||||||
|
|
||||||
var customer = await new CustomerService().GetAsync(sub.CustomerId);
|
var customer = await new CustomerService().GetAsync(sub.CustomerId);
|
||||||
var taxRates = await _taxRateRepository.GetByLocationAsync(
|
if (!string.IsNullOrWhiteSpace(customer?.Address?.Country)
|
||||||
new Bit.Core.Models.Table.TaxRate()
|
&& !string.IsNullOrWhiteSpace(customer?.Address?.PostalCode))
|
||||||
{
|
|
||||||
Country = customer.Address.Country,
|
|
||||||
PostalCode = customer.Address.PostalCode
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var taxRate = taxRates.FirstOrDefault();
|
|
||||||
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
|
|
||||||
{
|
{
|
||||||
subUpdateOptions.DefaultTaxRates = new List<string>(1)
|
var taxRates = await _taxRateRepository.GetByLocationAsync(
|
||||||
{
|
new Bit.Core.Models.Table.TaxRate()
|
||||||
taxRate.Id
|
{
|
||||||
};
|
Country = customer.Address.Country,
|
||||||
|
PostalCode = customer.Address.PostalCode
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var taxRate = taxRates.FirstOrDefault();
|
||||||
|
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
|
||||||
|
{
|
||||||
|
subUpdateOptions.DefaultTaxRates = new List<string>(1)
|
||||||
|
{
|
||||||
|
taxRate.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var subResponse = await subscriptionService.UpdateAsync(sub.Id, subUpdateOptions);
|
var subResponse = await subscriptionService.UpdateAsync(sub.Id, subUpdateOptions);
|
||||||
|
@ -719,20 +719,24 @@ namespace Bit.Core.Services
|
|||||||
};
|
};
|
||||||
|
|
||||||
var customer = await new CustomerService().GetAsync(sub.CustomerId);
|
var customer = await new CustomerService().GetAsync(sub.CustomerId);
|
||||||
var taxRates = await _taxRateRepository.GetByLocationAsync(
|
if (!string.IsNullOrWhiteSpace(customer?.Address?.Country)
|
||||||
new Bit.Core.Models.Table.TaxRate()
|
&& !string.IsNullOrWhiteSpace(customer?.Address?.PostalCode))
|
||||||
{
|
|
||||||
Country = customer.Address.Country,
|
|
||||||
PostalCode = customer.Address.PostalCode
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var taxRate = taxRates.FirstOrDefault();
|
|
||||||
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
|
|
||||||
{
|
{
|
||||||
subUpdateOptions.DefaultTaxRates = new List<string>(1)
|
var taxRates = await _taxRateRepository.GetByLocationAsync(
|
||||||
{
|
new Bit.Core.Models.Table.TaxRate()
|
||||||
taxRate.Id
|
{
|
||||||
};
|
Country = customer.Address.Country,
|
||||||
|
PostalCode = customer.Address.PostalCode
|
||||||
|
}
|
||||||
|
);
|
||||||
|
var taxRate = taxRates.FirstOrDefault();
|
||||||
|
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
|
||||||
|
{
|
||||||
|
subUpdateOptions.DefaultTaxRates = new List<string>(1)
|
||||||
|
{
|
||||||
|
taxRate.Id
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var subResponse = await subscriptionService.UpdateAsync(sub.Id, subUpdateOptions);
|
var subResponse = await subscriptionService.UpdateAsync(sub.Id, subUpdateOptions);
|
||||||
|
Loading…
Reference in New Issue
Block a user