mirror of
				https://github.com/D4M13N-D3V/comissions-app-core-api.git
				synced 2025-10-31 01:25:27 +00:00 
			
		
		
		
	fix: updated routes for onboarding
This commit is contained in:
		
							parent
							
								
									ccde0d3fa7
								
							
						
					
					
						commit
						ff448b218c
					
				| @ -1,6 +1,7 @@ | ||||
| using comissions.app.api.Models.SellerProfileRequest; | ||||
| using ArtPlatform.Database; | ||||
| using ArtPlatform.Database.Entities; | ||||
| using comissions.app.api.Services.Payment; | ||||
| using comissions.app.database; | ||||
| using comissions.app.database.Entities; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| @ -15,9 +16,11 @@ namespace comissions.app.api.Controllers; | ||||
| public class AdminSellerRequestsController : Controller | ||||
| { | ||||
|     private readonly ApplicationDbContext _dbContext; | ||||
|     private readonly IPaymentService _paymentService; | ||||
| 
 | ||||
|     public AdminSellerRequestsController(ApplicationDbContext dbContext) | ||||
|     public AdminSellerRequestsController(ApplicationDbContext dbContext, IPaymentService paymentService) | ||||
|     { | ||||
|         _paymentService = paymentService; | ||||
|         _dbContext = dbContext; | ||||
|     } | ||||
|      | ||||
| @ -69,12 +72,13 @@ public class AdminSellerRequestsController : Controller | ||||
| 
 | ||||
|         request.Accepted = true; | ||||
|         request.AcceptedDate = DateTime.UtcNow; | ||||
| 
 | ||||
|         var accountId = _paymentService.CreateSellerAccount(); | ||||
|         var newSellerProfile = new UserSellerProfile() | ||||
|         { | ||||
|             UserId = userId, | ||||
|             AgeRestricted = false, | ||||
|             Biography = string.Empty, | ||||
|             StripeAccountId = accountId, | ||||
|             SocialMediaLinks = new List<string>(){} | ||||
|         }; | ||||
|         _dbContext.UserSellerProfiles.Add(newSellerProfile); | ||||
|  | ||||
| @ -206,37 +206,9 @@ public class SellerProfileController : Controller | ||||
|         return Ok(); | ||||
|     } | ||||
|      | ||||
|     [HttpPost] | ||||
|     [Authorize("write:seller-profile")] | ||||
|     [Route("Payment")] | ||||
|     public async Task<IActionResult> CreatePaymentAccount() | ||||
|     { | ||||
|         var userId = User.GetUserId(); | ||||
|         var existingSellerProfile = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(sellerProfile=>sellerProfile.UserId==userId); | ||||
|         if (existingSellerProfile == null) | ||||
|         { | ||||
|             var sellerProfileRequest = await _dbContext.SellerProfileRequests.FirstOrDefaultAsync(request=>request.UserId==userId && request.Accepted==false); | ||||
|             if(sellerProfileRequest!=null) | ||||
|                 return BadRequest(); | ||||
|             return Unauthorized(); | ||||
|         } | ||||
|          | ||||
|         if(existingSellerProfile.Suspended) | ||||
|             return BadRequest(); | ||||
|         if(existingSellerProfile.StripeAccountId!=null) | ||||
|             return BadRequest(); | ||||
| 
 | ||||
|         var accountId = _paymentService.CreateSellerAccount(); | ||||
|         existingSellerProfile.StripeAccountId = accountId; | ||||
|         existingSellerProfile = _dbContext.UserSellerProfiles.Update(existingSellerProfile).Entity; | ||||
|         await _dbContext.SaveChangesAsync(); | ||||
|         var result = _paymentService.CreateSellerAccountOnboardingUrl(accountId); | ||||
|         return Ok(new SellerOnboardUrlModel(){ OnboardUrl= result }); | ||||
|     } | ||||
|      | ||||
|     [HttpGet] | ||||
|     [Authorize("write:seller-profile")] | ||||
|     [Route("Payment/Onboarded")] | ||||
|     [Route("Onboard")] | ||||
|     public async Task<IActionResult> PaymentAccountStatus() | ||||
|     { | ||||
|         var userId = User.GetUserId(); | ||||
| @ -264,7 +236,7 @@ public class SellerProfileController : Controller | ||||
|      | ||||
|     [HttpGet] | ||||
|     [Authorize("write:seller-profile")] | ||||
|     [Route("Payment")] | ||||
|     [Route("Onboard/Url")] | ||||
|     public async Task<IActionResult> GetPaymentAccount() | ||||
|     { | ||||
|         var userId = User.GetUserId(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Damien Ostler
						Damien Ostler