first
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Csob.Models;
|
||||
using Csob.Services;
|
||||
|
||||
namespace Csob.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// PISP – single payment initiation and its authorization (sign) flow. Requires the ČSOB credential
|
||||
/// headers. After <c>POST /payments</c> the response carries <c>signInfo.signId</c>; use it with the
|
||||
/// sign endpoints to drive Strong Customer Authentication (SCA).
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("payments")]
|
||||
[Produces("application/json")]
|
||||
[Tags("PISP – Payments")]
|
||||
public sealed class PaymentsController : ControllerBase
|
||||
{
|
||||
private readonly PaymentsService _service;
|
||||
|
||||
public PaymentsController(PaymentsService service) => _service = service;
|
||||
|
||||
/// <summary>Initiate a domestic (DMCT) or SEPA (ESCT) payment.</summary>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Initiate([FromBody] PaymentInitiationRequest request, CancellationToken ct)
|
||||
=> Ok(await _service.InitiateAsync(request, ct));
|
||||
|
||||
/// <summary>Get the full payment detail.</summary>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> Detail(string id, CancellationToken ct)
|
||||
=> Ok(await _service.DetailAsync(id, ct));
|
||||
|
||||
/// <summary>Get the payment instruction status.</summary>
|
||||
[HttpGet("{id}/status")]
|
||||
public async Task<IActionResult> Status(string id, CancellationToken ct)
|
||||
=> Ok(await _service.StatusAsync(id, ct));
|
||||
|
||||
/// <summary>Cancel a not-yet-authorized payment.</summary>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> Cancel(string id, CancellationToken ct)
|
||||
=> Ok(await _service.CancelAsync(id, ct));
|
||||
|
||||
/// <summary>Start the authorization (SCA) of a payment. Returns the PSU redirect details.</summary>
|
||||
[HttpPost("{id}/sign/{signId}")]
|
||||
public async Task<IActionResult> StartSign(string id, string signId, [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] JsonNode? body, CancellationToken ct)
|
||||
=> Ok(await _service.StartSignAsync(id, signId, body, ct));
|
||||
|
||||
/// <summary>Get the current state of an authorization (sign) transaction.</summary>
|
||||
[HttpGet("{id}/sign/{signId}")]
|
||||
public async Task<IActionResult> SignStatus(string id, string signId, CancellationToken ct)
|
||||
=> Ok(await _service.SignStatusAsync(id, signId, ct));
|
||||
|
||||
/// <summary>Finalize an authorization (sign) transaction.</summary>
|
||||
[HttpPut("{id}/sign/{signId}")]
|
||||
public async Task<IActionResult> FinalizeSign(string id, string signId, [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] JsonNode? body, CancellationToken ct)
|
||||
=> Ok(await _service.FinalizeSignAsync(id, signId, body, ct));
|
||||
}
|
||||
Reference in New Issue
Block a user