feat(payments): implement Payments module with VNPay, MoMo, ZaloPay integration
Implement complete payment processing module following DDD + CQRS patterns: - Domain layer: PaymentEntity aggregate, Money value object, domain events - Infrastructure: PrismaPaymentRepository, VnpayService, MomoService, ZalopayService - PaymentGatewayFactory pattern for provider abstraction - CQRS Commands: CreatePayment, HandleCallback, RefundPayment - CQRS Queries: GetPaymentStatus, ListTransactions - Callback/webhook endpoints with signature verification and idempotency - 23 unit tests covering domain, VNPay service, and gateway factory Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
IsEnum,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUrl,
|
||||
MinLength,
|
||||
} from 'class-validator';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { PaymentProvider, PaymentType } from '@prisma/client';
|
||||
|
||||
export class CreatePaymentDto {
|
||||
@IsEnum(PaymentProvider)
|
||||
provider!: PaymentProvider;
|
||||
|
||||
@IsEnum(PaymentType)
|
||||
type!: PaymentType;
|
||||
|
||||
@Transform(({ value }) => BigInt(value))
|
||||
amountVND!: bigint;
|
||||
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
description!: string;
|
||||
|
||||
@IsUrl()
|
||||
returnUrl!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
transactionId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
idempotencyKey?: string;
|
||||
}
|
||||
3
apps/api/src/modules/payments/presentation/dto/index.ts
Normal file
3
apps/api/src/modules/payments/presentation/dto/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { CreatePaymentDto } from './create-payment.dto';
|
||||
export { RefundPaymentDto } from './refund-payment.dto';
|
||||
export { ListTransactionsDto } from './list-transactions.dto';
|
||||
@@ -0,0 +1,19 @@
|
||||
import { IsEnum, IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
import { PaymentStatus } from '@prisma/client';
|
||||
|
||||
export class ListTransactionsDto {
|
||||
@IsOptional()
|
||||
@IsEnum(PaymentStatus)
|
||||
status?: PaymentStatus;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(100)
|
||||
limit?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
offset?: number;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { IsString, MinLength } from 'class-validator';
|
||||
|
||||
export class RefundPaymentDto {
|
||||
@IsString()
|
||||
@MinLength(1)
|
||||
reason!: string;
|
||||
}
|
||||
Reference in New Issue
Block a user