1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

[PM-11993] Fix free organization bug in SubscriberService.GetPaymentMethod (#4766)

* Handle free organization in SubscriberService.GetPaymentMethod

* Run dotnet format
This commit is contained in:
Alex Morask 2024-09-12 08:47:34 -04:00 committed by GitHub
parent c8392804f9
commit 97795de19e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -4,4 +4,7 @@ public record PaymentMethod(
long AccountCredit, long AccountCredit,
PaymentSource PaymentSource, PaymentSource PaymentSource,
string SubscriptionStatus, string SubscriptionStatus,
TaxInformation TaxInformation); TaxInformation TaxInformation)
{
public static PaymentMethod Empty => new(0, null, null, null);
}

View File

@ -213,11 +213,16 @@ public class SubscriberService(
{ {
ArgumentNullException.ThrowIfNull(subscriber); ArgumentNullException.ThrowIfNull(subscriber);
var customer = await GetCustomerOrThrow(subscriber, new CustomerGetOptions var customer = await GetCustomer(subscriber, new CustomerGetOptions
{ {
Expand = ["default_source", "invoice_settings.default_payment_method", "subscriptions", "tax_ids"] Expand = ["default_source", "invoice_settings.default_payment_method", "subscriptions", "tax_ids"]
}); });
if (customer == null)
{
return PaymentMethod.Empty;
}
var accountCredit = customer.Balance * -1 / 100; var accountCredit = customer.Balance * -1 / 100;
var paymentMethod = await GetPaymentSourceAsync(subscriber.Id, customer); var paymentMethod = await GetPaymentSourceAsync(subscriber.Id, customer);