Add Slip Verify

This commit is contained in:
Thanakarn Klangkasame
2025-10-02 17:50:35 +07:00
parent 563a341a99
commit 33470d5fd4
16 changed files with 152 additions and 0 deletions

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

View File

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

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Abstractions.Applications.UseCases.Payments.SlipVerification.QrDecode;
public interface IQrDecoder
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Abstractions.Infrastructures.Integrations.SCB.Clients;
public interface IScbSlipClient
{
}

View File

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

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification.QrDecode;
public class TransRefParser
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification.QrDecode;
public class ZxingQrDecoder
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Application.UseCases.Payments.SlipVerification;
public class VerifyFromImageUseCase
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.Common;
public class SCBStatus
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.OAuth;
public class OAuthRequest
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.OAuth;
public class OAuthResponse
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Contracts.DTOs.Integrations.SCB.SlipVerification;
public class SlipVerificationEnvelope
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Contracts.DTOs.Payments.SlipVerification;
public class VerifyFromImageRequest
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Contracts.DTOs.Payments.SlipVerification;
public class VerifyFromImageResponse
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Domain.Shared.Payments;
public class SCBOptions
{
}

View File

@@ -0,0 +1,6 @@
namespace AMREZ.EOP.Infrastructures.Integrations.SCB.Clients;
public class ScbSlipClient
{
}