fix: added endpoint to get stripe dashboard url

This commit is contained in:
Damien Ostler 2024-02-25 01:41:01 -05:00
parent 9973a31561
commit b6eaee0831
3 changed files with 25 additions and 0 deletions

View File

@ -66,6 +66,23 @@ public class ArtistController : Controller
var result = Artist.ToStatsModel(); var result = Artist.ToStatsModel();
return Ok(result); return Ok(result);
} }
[HttpGet]
[Authorize("read:artist")]
[Route("PayoutDashboard")]
public async Task<IActionResult> PayoutDashboard()
{
var userId = User.GetUserId();
var Artist = await _dbContext.UserArtists.Include(x=>x.Requests).FirstOrDefaultAsync(Artist=>Artist.UserId==userId);
if(Artist==null)
{
var ArtistRequest = await _dbContext.ArtistRequests.FirstOrDefaultAsync(request=>request.UserId==userId && request.Accepted==false);
if(ArtistRequest!=null)
return BadRequest();
return Unauthorized();
}
var url = _paymentService.CreateDashboardUrl(Artist.StripeAccountId);
return Ok(new {url});
}
[HttpPut] [HttpPut]
[Authorize("write:artist")] [Authorize("write:artist")]

View File

@ -8,4 +8,5 @@ public interface IPaymentService
string CreateArtistAccountOnboardingUrl(string accountId); string CreateArtistAccountOnboardingUrl(string accountId);
bool ArtistAccountIsOnboarded(string accountId); bool ArtistAccountIsOnboarded(string accountId);
string Charge(int orderArtistServiceId, string? sellerStripeAccountId, double orderPrice); string Charge(int orderArtistServiceId, string? sellerStripeAccountId, double orderPrice);
string CreateDashboardUrl(string accountId);
} }

View File

@ -128,4 +128,11 @@ public class StripePaymentServiceProvider:IPaymentService
var session = service.Create(options, requestOptions); var session = service.Create(options, requestOptions);
return session.Url; return session.Url;
} }
public string CreateDashboardUrl(string accountId)
{
var service = new LoginLinkService();
var url = service.Create(accountId);
return url.Url;
}
} }