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>>> ListPaymentGateways() { return Response(await _paymentServiceClient.ListGatewaysAsync(HttpContext.RequestAborted)); } [HttpPost("payment-gateways")] public async Task>> UpsertPaymentGateway([FromBody] UpsertGatewayDefinitionRequest request) { return Response(await _paymentServiceClient.UpsertGatewayAsync(request, HttpContext.RequestAborted)); } [HttpPut("payment-gateways/{id:guid}/enabled")] public async Task>> 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>> UpsertPlatformGatewayCredential( Guid platformId, string gatewayName, [FromBody] UpsertPlatformGatewayCredentialRequest request) { request.PlatformId = platformId; request.GatewayName = gatewayName; await _paymentServiceClient.UpsertPlatformCredentialAsync(request, HttpContext.RequestAborted); return Response(new { saved = true }); } } }