1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using MTWorkHR.Application.Filters;
- using MTWorkHR.Application.Services.Interfaces;
- namespace MTWorkHR.API.Controllers
- {
- [Route("api/[controller]")]
- [ApiController]
- [AppAuthorize]
- public class PaymentController : ControllerBase
- {
- private readonly IMatchMoveService _PaymentService;
- public PaymentController(IMatchMoveService PaymentService)
- {
- this._PaymentService = PaymentService;
- }
-
- [HttpPost]
- public async Task<IActionResult> ProcessPayment([FromBody] object paymentRequest)
- {
- try
- {
- // Step 1: Get OAuth token
- var token = await _PaymentService.GetAccessTokenAsync();
- // Step 2: Process the payment
- var response = await _PaymentService.ProcessPaymentAsync(token, paymentRequest);
- return Ok(response); // Return the MatchMove API response
- }
- catch (Exception ex)
- {
- return BadRequest(new { error = ex.Message });
- }
- }
- }
- }
|