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 @@
|
||||
export { Money } from './money.vo';
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ValueObject } from '@modules/shared/domain/value-object';
|
||||
import { Result } from '@modules/shared/domain/result';
|
||||
|
||||
interface MoneyProps {
|
||||
amountVND: bigint;
|
||||
}
|
||||
|
||||
export class Money extends ValueObject<MoneyProps> {
|
||||
get value(): bigint {
|
||||
return this.props.amountVND;
|
||||
}
|
||||
|
||||
static create(amountVND: bigint): Result<Money, string> {
|
||||
if (amountVND <= 0n) {
|
||||
return Result.err('Số tiền phải lớn hơn 0');
|
||||
}
|
||||
if (amountVND > 999_999_999_999n) {
|
||||
return Result.err('Số tiền vượt quá giới hạn cho phép');
|
||||
}
|
||||
return Result.ok(new Money({ amountVND }));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user