1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 09:32:48 -05:00

combined tax updates with other operations

This commit is contained in:
Chad Scharf
2020-06-17 19:49:27 -04:00
parent f7e5f1f15e
commit b7a500eb63
10 changed files with 66 additions and 14 deletions

View File

@ -75,7 +75,7 @@ namespace Bit.Core.Services
}
public async Task ReplacePaymentMethodAsync(Guid organizationId, string paymentToken,
PaymentMethodType paymentMethodType)
PaymentMethodType paymentMethodType, TaxInfo taxInfo)
{
var organization = await GetOrgById(organizationId);
if (organization == null)
@ -83,6 +83,7 @@ namespace Bit.Core.Services
throw new NotFoundException();
}
await _paymentService.SaveTaxInfoAsync(organization, taxInfo);
var updated = await _paymentService.UpdatePaymentMethodAsync(organization,
paymentMethodType, paymentToken);
if (updated)

View File

@ -345,7 +345,7 @@ namespace Bit.Core.Services
}
public async Task<string> PurchasePremiumAsync(User user, PaymentMethodType paymentMethodType,
string paymentToken, short additionalStorageGb)
string paymentToken, short additionalStorageGb, string country, string postalCode)
{
if (paymentMethodType != PaymentMethodType.Credit && string.IsNullOrWhiteSpace(paymentToken))
{
@ -463,10 +463,28 @@ namespace Bit.Core.Services
InvoiceSettings = new CustomerInvoiceSettingsOptions
{
DefaultPaymentMethod = stipeCustomerPaymentMethodId
}
},
Address = new AddressOptions
{
Line1 = string.Empty,
Country = country,
PostalCode = postalCode,
},
});
createdStripeCustomer = true;
}
else if (customer != null)
{
await customerService.UpdateAsync(customer.Id, new CustomerUpdateOptions
{
Address = new AddressOptions
{
Line1 = string.Empty,
Country = country,
PostalCode = postalCode,
}
});
}
if (customer == null)
{

View File

@ -703,7 +703,8 @@ namespace Bit.Core.Services
}
public async Task<Tuple<bool, string>> SignUpPremiumAsync(User user, string paymentToken,
PaymentMethodType paymentMethodType, short additionalStorageGb, UserLicense license)
PaymentMethodType paymentMethodType, short additionalStorageGb, UserLicense license,
string country, string postalCode)
{
if (user.Premium)
{
@ -742,7 +743,7 @@ namespace Bit.Core.Services
else
{
paymentIntentClientSecret = await _paymentService.PurchasePremiumAsync(user, paymentMethodType,
paymentToken, additionalStorageGb);
paymentToken, additionalStorageGb, country, postalCode);
}
user.Premium = true;