Files
Core_Be/Controllers/AdminPaymentGatewayController.cs
Dhananjaya99 bffc9b1686 first commit
2026-09-28 11:44:26 +05:30

56 lines
2.5 KiB
C#

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 });
}
}
}