feat(payments): implement BankTransferService payment gateway with admin confirmation

Add BANK_TRANSFER as a fully supported payment provider:
- BankTransferService implementing IPaymentGateway with HMAC-SHA256 verification
- ConfirmBankTransferCommand/Handler for admin manual payment confirmation
- POST /payments/:id/confirm-transfer admin endpoint (RBAC-protected)
- Atomic status updates with idempotency (PENDING/PROCESSING → COMPLETED)
- Registered in PaymentGatewayFactory alongside VNPAY, MOMO, ZALOPAY
- Comprehensive unit tests for service and handler

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-16 02:34:54 +07:00
parent 18bb6bfe17
commit 89aaa25bb6
11 changed files with 760 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { CancelOrderHandler } from './application/commands/cancel-order/cancel-order.handler';
import { ConfirmBankTransferHandler } from './application/commands/confirm-bank-transfer/confirm-bank-transfer.handler';
import { CreateOrderHandler } from './application/commands/create-order/create-order.handler';
import { CreatePaymentHandler } from './application/commands/create-payment/create-payment.handler';
import { HandleCallbackHandler } from './application/commands/handle-callback/handle-callback.handler';
@@ -16,6 +17,7 @@ import { PAYMENT_REPOSITORY } from './domain/repositories/payment.repository';
import { PrismaEscrowRepository } from './infrastructure/repositories/prisma-escrow.repository';
import { PrismaOrderRepository } from './infrastructure/repositories/prisma-order.repository';
import { PrismaPaymentRepository } from './infrastructure/repositories/prisma-payment.repository';
import { BankTransferService } from './infrastructure/services/bank-transfer.service';
import { MomoService } from './infrastructure/services/momo.service';
import { PaymentGatewayFactory } from './infrastructure/services/payment-gateway.factory';
import { PAYMENT_GATEWAY_FACTORY } from './infrastructure/services/payment-gateway.interface';
@@ -26,6 +28,7 @@ import { PaymentsController } from './presentation/controllers/payments.controll
const CommandHandlers = [
CancelOrderHandler,
ConfirmBankTransferHandler,
CreateOrderHandler,
CreatePaymentHandler,
HandleCallbackHandler,
@@ -53,6 +56,7 @@ const QueryHandlers = [
VnpayService,
MomoService,
ZalopayService,
BankTransferService,
{ provide: PAYMENT_GATEWAY_FACTORY, useClass: PaymentGatewayFactory },
// CQRS