diff --git a/src/Core/Models/Api/Response/BillingResponseModel.cs b/src/Core/Models/Api/Response/BillingResponseModel.cs index 816dd531d..2d42d56e2 100644 --- a/src/Core/Models/Api/Response/BillingResponseModel.cs +++ b/src/Core/Models/Api/Response/BillingResponseModel.cs @@ -11,13 +11,13 @@ namespace Bit.Core.Models.Api public BillingResponseModel(BillingInfo billing) : base("billing") { - CreditAmount = billing.CreditAmount; + Balance = billing.Balance; PaymentSource = billing.PaymentSource != null ? new BillingSource(billing.PaymentSource) : null; Transactions = billing.Transactions?.Select(t => new BillingTransaction(t)); Invoices = billing.Invoices?.Select(i => new BillingInvoice(i)); } - public decimal CreditAmount { get; set; } + public decimal Balance { get; set; } public BillingSource PaymentSource { get; set; } public IEnumerable Invoices { get; set; } public IEnumerable Transactions { get; set; } diff --git a/src/Core/Models/Business/BillingInfo.cs b/src/Core/Models/Business/BillingInfo.cs index 4eb2c1b38..38cc68c33 100644 --- a/src/Core/Models/Business/BillingInfo.cs +++ b/src/Core/Models/Business/BillingInfo.cs @@ -8,9 +8,8 @@ namespace Bit.Core.Models.Business { public class BillingInfo { - public decimal CreditAmount { get; set; } + public decimal Balance { get; set; } public BillingSource PaymentSource { get; set; } - public IEnumerable Charges { get; set; } = new List(); public IEnumerable Invoices { get; set; } = new List(); public IEnumerable Transactions { get; set; } = new List(); @@ -85,57 +84,6 @@ namespace Bit.Core.Models.Business public bool NeedsVerification { get; set; } } - public class BillingCharge - { - public BillingCharge(Charge charge) - { - Amount = charge.Amount / 100M; - RefundedAmount = charge.AmountRefunded / 100M; - PaymentSource = charge.Source != null ? new BillingSource(charge.Source) : null; - CreatedDate = charge.Created; - FailureMessage = charge.FailureMessage; - Refunded = charge.Refunded; - Status = charge.Status; - InvoiceId = charge.InvoiceId; - } - - public BillingCharge(Braintree.Transaction transaction) - { - Amount = transaction.Amount.GetValueOrDefault(); - RefundedAmount = 0; // TODO? - - if(transaction.PayPalDetails != null) - { - PaymentSource = new BillingSource(transaction.PayPalDetails); - } - else if(transaction.CreditCard != null && - transaction.CreditCard.CardType != Braintree.CreditCardCardType.UNRECOGNIZED) - { - PaymentSource = new BillingSource(transaction.CreditCard); - } - else if(transaction.UsBankAccountDetails != null) - { - PaymentSource = new BillingSource(transaction.UsBankAccountDetails); - } - - CreatedDate = transaction.CreatedAt.GetValueOrDefault(); - FailureMessage = null; - Refunded = transaction.RefundedTransactionId != null; - Status = transaction.Status.ToString(); - InvoiceId = null; - } - - public DateTime CreatedDate { get; set; } - public decimal Amount { get; set; } - public BillingSource PaymentSource { get; set; } - public string Status { get; set; } - public string FailureMessage { get; set; } - public bool Refunded { get; set; } - public bool PartiallyRefunded => !Refunded && RefundedAmount > 0; - public decimal RefundedAmount { get; set; } - public string InvoiceId { get; set; } - } - public class BillingTransaction { public BillingTransaction(Transaction transaction) diff --git a/src/Core/Services/Implementations/StripePaymentService.cs b/src/Core/Services/Implementations/StripePaymentService.cs index 7ef5b1f03..6f096088a 100644 --- a/src/Core/Services/Implementations/StripePaymentService.cs +++ b/src/Core/Services/Implementations/StripePaymentService.cs @@ -939,7 +939,7 @@ namespace Bit.Core.Services var customer = await customerService.GetAsync(subscriber.GatewayCustomerId); if(customer != null) { - billingInfo.CreditAmount = customer.AccountBalance / 100M; + billingInfo.Balance = customer.AccountBalance / 100M; if(customer.Metadata?.ContainsKey("btCustomerId") ?? false) { @@ -968,14 +968,6 @@ namespace Bit.Core.Services } } - var charges = await chargeService.ListAsync(new ChargeListOptions - { - CustomerId = customer.Id, - Limit = 20 - }); - billingInfo.Charges = charges?.Data?.OrderByDescending(c => c.Created) - .Select(c => new BillingInfo.BillingCharge(c)); - var invoices = await invoiceService.ListAsync(new InvoiceListOptions { CustomerId = customer.Id,