first commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using Fitness_core_BE.DTOs.PaymentGateways;
|
||||
using Fitness_core_BE.Helpers;
|
||||
using Fitness_core_BE.Interfaces.Services;
|
||||
using Fitness_core_BE.Models.IOs;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using static Fitness_core_BE.Helpers.JwtMiddleware;
|
||||
using static Fitness_core_BE.Helpers.ApiResponseHelper;
|
||||
|
||||
namespace Fitness_core_BE.Controllers
|
||||
{
|
||||
// Payment gateway catalog (proxied to Payment-Service; see PaymentServiceClient).
|
||||
// This is platform-admin's side of gateway registration — the gym-owner side
|
||||
// (payout track/KYC/wallet enablement) lives in PaymentsEnablementController.
|
||||
[ApiController]
|
||||
[Route("api/admin")]
|
||||
[CustomMiddleware]
|
||||
[TenantResolution]
|
||||
public class AdminPaymentGatewayController : ControllerBase
|
||||
{
|
||||
private readonly IPaymentServiceClient _paymentServiceClient;
|
||||
|
||||
public AdminPaymentGatewayController(IPaymentServiceClient paymentServiceClient)
|
||||
{
|
||||
_paymentServiceClient = paymentServiceClient;
|
||||
}
|
||||
|
||||
[HttpGet("payment-gateways")]
|
||||
public async Task<ActionResult<ApiResponse<List<GatewayDefinitionDto>>>> ListPaymentGateways()
|
||||
{
|
||||
return Response(await _paymentServiceClient.ListGatewaysAsync(HttpContext.RequestAborted));
|
||||
}
|
||||
|
||||
[HttpPost("payment-gateways")]
|
||||
public async Task<ActionResult<ApiResponse<GatewayDefinitionDto>>> UpsertPaymentGateway([FromBody] UpsertGatewayDefinitionRequest request)
|
||||
{
|
||||
return Response(await _paymentServiceClient.UpsertGatewayAsync(request, HttpContext.RequestAborted));
|
||||
}
|
||||
|
||||
[HttpPut("payment-gateways/{id:guid}/enabled")]
|
||||
public async Task<ActionResult<ApiResponse<GatewayDefinitionDto>>> SetPaymentGatewayEnabled(Guid id, [FromBody] SetGatewayEnabledRequest request)
|
||||
{
|
||||
return Response(await _paymentServiceClient.SetGatewayEnabledAsync(id, request.IsEnabled, HttpContext.RequestAborted));
|
||||
}
|
||||
|
||||
[HttpPut("payment-gateways/platforms/{platformId:guid}/credentials/{gatewayName}")]
|
||||
public async Task<ActionResult<ApiResponse<object>>> UpsertPlatformGatewayCredential(
|
||||
Guid platformId, string gatewayName, [FromBody] UpsertPlatformGatewayCredentialRequest request)
|
||||
{
|
||||
request.PlatformId = platformId;
|
||||
request.GatewayName = gatewayName;
|
||||
await _paymentServiceClient.UpsertPlatformCredentialAsync(request, HttpContext.RequestAborted);
|
||||
return Response<object>(new { saved = true });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user