mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
Consistency on TaxInfo use in service params
This commit is contained in:
@ -345,7 +345,7 @@ namespace Bit.Core.Services
|
||||
}
|
||||
|
||||
public async Task<string> PurchasePremiumAsync(User user, PaymentMethodType paymentMethodType,
|
||||
string paymentToken, short additionalStorageGb, string country, string postalCode)
|
||||
string paymentToken, short additionalStorageGb, TaxInfo taxInfo)
|
||||
{
|
||||
if (paymentMethodType != PaymentMethodType.Credit && string.IsNullOrWhiteSpace(paymentToken))
|
||||
{
|
||||
@ -393,7 +393,7 @@ namespace Bit.Core.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
await UpdatePaymentMethodAsync(user, paymentMethodType, paymentToken, true);
|
||||
await UpdatePaymentMethodAsync(user, paymentMethodType, paymentToken, true, taxInfo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -467,24 +467,12 @@ namespace Bit.Core.Services
|
||||
Address = new AddressOptions
|
||||
{
|
||||
Line1 = string.Empty,
|
||||
Country = country,
|
||||
PostalCode = postalCode,
|
||||
Country = taxInfo.BillingAddressCountry,
|
||||
PostalCode = taxInfo.BillingAddressPostalCode,
|
||||
},
|
||||
});
|
||||
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)
|
||||
{
|
||||
@ -1116,7 +1104,7 @@ namespace Bit.Core.Services
|
||||
}
|
||||
|
||||
public async Task<bool> UpdatePaymentMethodAsync(ISubscriber subscriber, PaymentMethodType paymentMethodType,
|
||||
string paymentToken, bool allowInAppPurchases = false)
|
||||
string paymentToken, bool allowInAppPurchases = false, TaxInfo taxInfo = null)
|
||||
{
|
||||
if (subscriber == null)
|
||||
{
|
||||
@ -1304,7 +1292,16 @@ namespace Bit.Core.Services
|
||||
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
||||
{
|
||||
DefaultPaymentMethod = stipeCustomerPaymentMethodId
|
||||
}
|
||||
},
|
||||
Address = taxInfo == null ? null : new AddressOptions
|
||||
{
|
||||
Country = taxInfo.BillingAddressCountry,
|
||||
PostalCode = taxInfo.BillingAddressPostalCode,
|
||||
Line1 = taxInfo.BillingAddressLine1 ?? string.Empty,
|
||||
Line2 = taxInfo.BillingAddressLine2,
|
||||
City = taxInfo.BillingAddressCity,
|
||||
State = taxInfo.BillingAddressState,
|
||||
},
|
||||
});
|
||||
|
||||
subscriber.Gateway = GatewayType.Stripe;
|
||||
@ -1363,7 +1360,16 @@ namespace Bit.Core.Services
|
||||
InvoiceSettings = new CustomerInvoiceSettingsOptions
|
||||
{
|
||||
DefaultPaymentMethod = defaultPaymentMethodId
|
||||
}
|
||||
},
|
||||
Address = taxInfo == null ? null : new AddressOptions
|
||||
{
|
||||
Country = taxInfo.BillingAddressCountry,
|
||||
PostalCode = taxInfo.BillingAddressPostalCode,
|
||||
Line1 = taxInfo.BillingAddressLine1 ?? string.Empty,
|
||||
Line2 = taxInfo.BillingAddressLine2,
|
||||
City = taxInfo.BillingAddressCity,
|
||||
State = taxInfo.BillingAddressState,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user