1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 17:42:49 -05:00

handle PaymentMethods for PaymentSource billing info

This commit is contained in:
Kyle Spearrin
2019-08-09 15:53:01 -04:00
parent 9686b4bf2b
commit b11fd2fab8
2 changed files with 26 additions and 0 deletions

View File

@ -1216,6 +1216,18 @@ namespace Bit.Core.Services
}
}
}
if(billingInfo.PaymentSource == null)
{
var paymentMethodService = new PaymentMethodService();
var paymentMethods = paymentMethodService.ListAutoPaging(
new PaymentMethodListOptions { CustomerId = customer.Id, Type = "card" });
var paymentMethod = paymentMethods.Where(m => m.Card != null)
.OrderByDescending(m => m.Created).FirstOrDefault();
if(paymentMethod != null)
{
billingInfo.PaymentSource = new BillingInfo.BillingSource(paymentMethod);
}
}
var invoices = await invoiceService.ListAsync(new InvoiceListOptions
{