fix: added pending balance

This commit is contained in:
Damien Ostler 2024-02-25 02:29:20 -05:00
parent eba1de0cd0
commit ce3b019cfa
4 changed files with 13 additions and 0 deletions

View File

@ -85,10 +85,12 @@ public class ArtistController : Controller
var account = _paymentService.GetAccount(Artist.StripeAccountId);
var balance = _paymentService.GetBalance(Artist.StripeAccountId);
var pendingBalance = _paymentService.GetPendingBalance(Artist.StripeAccountId);
var result = new PayoutModel()
{
Enabled = account.PayoutsEnabled,
Balance = balance,
PendingBalance = pendingBalance,
PayoutUrl = _paymentService.CreateDashboardUrl(Artist.StripeAccountId)
};
return Ok(result);

View File

@ -7,4 +7,5 @@ public class PayoutModel
public double Balance { get; set; }
public bool Enabled { get; set; }
public string PayoutUrl { get; set; }
public double PendingBalance { get; set; }
}

View File

@ -13,4 +13,5 @@ public interface IPaymentService
string CreateDashboardUrl(string accountId);
Account GetAccount(string? artistStripeAccountId);
double GetBalance(string accountId);
double GetPendingBalance(string accountId);
}

View File

@ -152,4 +152,13 @@ public class StripePaymentServiceProvider:IPaymentService
});
return balance.Available[0].Amount/100;
}
public double GetPendingBalance(string accountId)
{
var balanceService = new BalanceService();
var balance = balanceService.Get(new RequestOptions()
{
StripeAccount = accountId
});
return balance.Pending[0].Amount/100;
}
}