Add Slip Verify
This commit is contained in:
41
AMREZ.EOP.API/Controllers/SCBController.cs
Normal file
41
AMREZ.EOP.API/Controllers/SCBController.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using AMREZ.EOP.Abstractions.Applications.UseCases.Payments.SlipVerification;
|
||||||
|
using AMREZ.EOP.Contracts.DTOs.Payments.SlipVerification;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace AMREZ.EOP.API.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class SCBController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly IVerifyFromImageUseCase _verifyFromImage;
|
||||||
|
|
||||||
|
public SCBController(IVerifyFromImageUseCase verifyFromImage)
|
||||||
|
{
|
||||||
|
_verifyFromImage = verifyFromImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อัปโหลด "รูปสลิป" เพื่อตรวจสอบกับธนาคาร (ไม่ใช้ OCR — scan QR + heuristic)
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost("slips/verify")]
|
||||||
|
[Consumes("multipart/form-data")]
|
||||||
|
[RequestSizeLimit(5_000_000)]
|
||||||
|
public async Task<IActionResult> VerifySlipFromImage(
|
||||||
|
[FromForm(Name = "Image")] IFormFile? Image,
|
||||||
|
[FromForm] string? OverrideSendingBank,
|
||||||
|
CancellationToken ct)
|
||||||
|
{
|
||||||
|
if (Image is null || Image.Length == 0)
|
||||||
|
return BadRequest(new { message = "Missing slip image" });
|
||||||
|
|
||||||
|
var res = await _verifyFromImage.ExecuteAsync(new VerifyFromImageRequest
|
||||||
|
{
|
||||||
|
Image = Image,
|
||||||
|
OverrideSendingBank = OverrideSendingBank
|
||||||
|
}, ct);
|
||||||
|
|
||||||
|
if (res is null) return NotFound(new { message = "Cannot extract transRef or verification failed" });
|
||||||
|
return Ok(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using AMREZ.EOP.Contracts.DTOs.Payments.SlipVerification;
|
||||||
|
|
||||||
|
namespace AMREZ.EOP.Abstractions.Applications.UseCases.Payments;
|
||||||
|
|
||||||
|
public interface IVerifyFromImageUseCase
|
||||||
|
{
|
||||||
|
Task<VerifyFromImageResponse?> ExecuteAsync(VerifyFromImageRequest request, CancellationToken ct);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Abstractions.Applications.UseCases.Payments.SlipVerification.QrDecode;
|
||||||
|
|
||||||
|
public interface IQrDecoder
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Abstractions.Infrastructures.Integrations.SCB.Clients;
|
||||||
|
|
||||||
|
public interface IScbSlipClient
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using AMREZ.EOP.Abstractions.Applications.UseCases.Payments.SlipVerification.BankDetect;
|
||||||
|
using AMREZ.EOP.Application.UseCases.Payments.SlipVerification.QrDecode;
|
||||||
|
using SkiaSharp;
|
||||||
|
|
||||||
|
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification.BankDetect;
|
||||||
|
|
||||||
|
public static class BankDetect
|
||||||
|
{
|
||||||
|
// SCB=014, KBank=004
|
||||||
|
public static string? FromQrText(string? raw)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(raw)) return null;
|
||||||
|
|
||||||
|
var id = TransRefParser.TryExtract(raw);
|
||||||
|
if (string.IsNullOrEmpty(id)) return null;
|
||||||
|
|
||||||
|
// เคสสลิป SCB มักขึ้นต้น "20..." (ปี+วันเวลา) → เดาว่า 014
|
||||||
|
if (id.StartsWith("20")) return "014";
|
||||||
|
|
||||||
|
// KBank มักเป็นตัวเลขยาวตามด้วยอักษร (เช่น 015275114427ATF02456) → เดา 004
|
||||||
|
if (id.Any(char.IsLetter)) return "004";
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification.QrDecode;
|
||||||
|
|
||||||
|
public class TransRefParser
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification.QrDecode;
|
||||||
|
|
||||||
|
public class ZxingQrDecoder
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification;
|
||||||
|
|
||||||
|
public class VerifyFromImageUseCase
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.Common;
|
||||||
|
|
||||||
|
public class SCBStatus
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.OAuth;
|
||||||
|
|
||||||
|
public class OAuthRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.OAuth;
|
||||||
|
|
||||||
|
public class OAuthResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.SlipVerification;
|
||||||
|
|
||||||
|
public class SlipVerificationEnvelope
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Contracts.DTOs.Payments.SlipVerification;
|
||||||
|
|
||||||
|
public class VerifyFromImageRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Contracts.DTOs.Payments.SlipVerification;
|
||||||
|
|
||||||
|
public class VerifyFromImageResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
6
AMREZ.EOP.Domain/Shared/Payments/SCBOptions.cs
Normal file
6
AMREZ.EOP.Domain/Shared/Payments/SCBOptions.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Domain.Shared.Payments;
|
||||||
|
|
||||||
|
public class SCBOptions
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace AMREZ.EOP.Infrastructures.Integrations.SCB.Clients;
|
||||||
|
|
||||||
|
public class ScbSlipClient
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user