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,46 @@
|
||||
import { type PaymentProvider } from '@prisma/client';
|
||||
|
||||
export const PAYMENT_GATEWAY_FACTORY = Symbol('PAYMENT_GATEWAY_FACTORY');
|
||||
|
||||
export interface CreatePaymentUrlParams {
|
||||
orderId: string;
|
||||
amountVND: bigint;
|
||||
description: string;
|
||||
returnUrl: string;
|
||||
ipAddress: string;
|
||||
}
|
||||
|
||||
export interface CreatePaymentUrlResult {
|
||||
paymentUrl: string;
|
||||
providerTxId: string;
|
||||
}
|
||||
|
||||
export interface CallbackVerifyResult {
|
||||
isValid: boolean;
|
||||
orderId: string;
|
||||
providerTxId: string;
|
||||
isSuccess: boolean;
|
||||
rawData: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface RefundParams {
|
||||
providerTxId: string;
|
||||
amountVND: bigint;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
export interface RefundResult {
|
||||
success: boolean;
|
||||
refundTxId: string | null;
|
||||
}
|
||||
|
||||
export interface IPaymentGateway {
|
||||
readonly provider: PaymentProvider;
|
||||
createPaymentUrl(params: CreatePaymentUrlParams): Promise<CreatePaymentUrlResult>;
|
||||
verifyCallback(data: Record<string, string>): CallbackVerifyResult;
|
||||
refund(params: RefundParams): Promise<RefundResult>;
|
||||
}
|
||||
|
||||
export interface IPaymentGatewayFactory {
|
||||
getGateway(provider: PaymentProvider): IPaymentGateway;
|
||||
}
|
||||
Reference in New Issue
Block a user