mirror of
				https://github.com/D4M13N-D3V/comissions-app-core-api.git
				synced 2025-10-31 09:35:25 +00:00 
			
		
		
		
	fix: added endpoint to get if a account is onboarded, and changed the models of responses
This commit is contained in:
		
							parent
							
								
									df051237fa
								
							
						
					
					
						commit
						a2d6c3fa3b
					
				| @ -78,7 +78,7 @@ public class SellerProfileController : Controller | |||||||
|             return NotFound(); |             return NotFound(); | ||||||
|         var result = sellerProfileRequest.ToModel(); |         var result = sellerProfileRequest.ToModel(); | ||||||
|         return Ok(result); |         return Ok(result); | ||||||
|     } |     }    | ||||||
|      |      | ||||||
|     [HttpPost] |     [HttpPost] | ||||||
|     [Authorize("write:seller-profile")] |     [Authorize("write:seller-profile")] | ||||||
| @ -230,8 +230,36 @@ public class SellerProfileController : Controller | |||||||
|         existingSellerProfile.StripeAccountId = accountId; |         existingSellerProfile.StripeAccountId = accountId; | ||||||
|         existingSellerProfile = _dbContext.UserSellerProfiles.Update(existingSellerProfile).Entity; |         existingSellerProfile = _dbContext.UserSellerProfiles.Update(existingSellerProfile).Entity; | ||||||
|         await _dbContext.SaveChangesAsync(); |         await _dbContext.SaveChangesAsync(); | ||||||
|         var result = existingSellerProfile.ToModel(); |         var result = _paymentService.CreateSellerAccountOnboardingUrl(accountId); | ||||||
|         return Ok(result); |         return Ok(new { onboardUrl = result }); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [HttpGet] | ||||||
|  |     [Authorize("write:seller-profile")] | ||||||
|  |     [Route("Payment/Onboarded")] | ||||||
|  |     public async Task<IActionResult> PaymentAccountStatus() | ||||||
|  |     { | ||||||
|  |         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.SellerAccountIsOnboarded(accountId); | ||||||
|  |         return Ok(new { onboarded=result }); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
| @ -254,7 +282,7 @@ public class SellerProfileController : Controller | |||||||
|             return BadRequest(); |             return BadRequest(); | ||||||
| 
 | 
 | ||||||
|         var result = _paymentService.CreateSellerAccountOnboardingUrl(existingSellerProfile.StripeAccountId); |         var result = _paymentService.CreateSellerAccountOnboardingUrl(existingSellerProfile.StripeAccountId); | ||||||
|         return Ok(result); |         return Ok(new { onboardUrl = result }); | ||||||
|     } |     } | ||||||
|      |      | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Damien Ostler
						Damien Ostler