Browse Source

null checked Stripe.Customer.Address for org seat and storage upgrades (#1099)

pull/1100/head
Addison Beck 5 years ago committed by GitHub
parent
commit
001bbf2f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      src/Core/Services/Implementations/OrganizationService.cs
  2. 28
      src/Core/Services/Implementations/StripePaymentService.cs

28
src/Core/Services/Implementations/OrganizationService.cs

@ -415,20 +415,24 @@ namespace Bit.Core.Services @@ -415,20 +415,24 @@ namespace Bit.Core.Services
};
var customer = await new CustomerService().GetAsync(sub.CustomerId);
var taxRates = await _taxRateRepository.GetByLocationAsync(
new Bit.Core.Models.Table.TaxRate()
if (!string.IsNullOrWhiteSpace(customer?.Address?.Country)
&& !string.IsNullOrWhiteSpace(customer?.Address?.PostalCode))
{
var taxRates = await _taxRateRepository.GetByLocationAsync(
new Bit.Core.Models.Table.TaxRate()
{
Country = customer.Address.Country,
PostalCode = customer.Address.PostalCode
}
);
var taxRate = taxRates.FirstOrDefault();
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
{
Country = customer.Address.Country,
PostalCode = customer.Address.PostalCode
subUpdateOptions.DefaultTaxRates = new List<string>(1)
{
taxRate.Id
};
}
);
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);

28
src/Core/Services/Implementations/StripePaymentService.cs

@ -719,20 +719,24 @@ namespace Bit.Core.Services @@ -719,20 +719,24 @@ namespace Bit.Core.Services
};
var customer = await new CustomerService().GetAsync(sub.CustomerId);
var taxRates = await _taxRateRepository.GetByLocationAsync(
new Bit.Core.Models.Table.TaxRate()
if (!string.IsNullOrWhiteSpace(customer?.Address?.Country)
&& !string.IsNullOrWhiteSpace(customer?.Address?.PostalCode))
{
var taxRates = await _taxRateRepository.GetByLocationAsync(
new Bit.Core.Models.Table.TaxRate()
{
Country = customer.Address.Country,
PostalCode = customer.Address.PostalCode
}
);
var taxRate = taxRates.FirstOrDefault();
if (taxRate != null && !sub.DefaultTaxRates.Any(x => x.Equals(taxRate.Id)))
{
Country = customer.Address.Country,
PostalCode = customer.Address.PostalCode
subUpdateOptions.DefaultTaxRates = new List<string>(1)
{
taxRate.Id
};
}
);
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);

Loading…
Cancel
Save