chore: parsian

This commit is contained in:
mahyargdz
2025-06-07 15:01:38 +03:30
parent f4ce67c00c
commit 4a7003a532
14 changed files with 582 additions and 19 deletions
@@ -2,6 +2,7 @@ import { BadGatewayException, Injectable } from "@nestjs/common";
import { PaymentMessage } from "../../../common/enums/message.enum";
import { GatewayEnum } from "../enums/gateway.enum";
import { ParsianGateway } from "../gateways/parsian.gateway";
import { ZarinpalGateway } from "../gateways/zarinpal.gateway";
import { IPaymentGateway, IPaymentGatewayFactory } from "../interfaces/IPayment";
import { GatewayType } from "../types/gateway.type";
@@ -10,13 +11,17 @@ import { GatewayType } from "../types/gateway.type";
export class PaymentGatewayFactory implements IPaymentGatewayFactory {
private readonly gateways: Map<GatewayType, IPaymentGateway>;
constructor(private readonly zarinpalGateway: ZarinpalGateway) {
constructor(
private readonly zarinpalGateway: ZarinpalGateway,
private readonly parsianGateway: ParsianGateway,
) {
this.gateways = new Map<GatewayType, IPaymentGateway>();
this.initializeGateways();
}
private initializeGateways(): void {
this.gateways.set(GatewayEnum.ZARINPAL, this.zarinpalGateway);
this.gateways.set(GatewayEnum.PARSIAN, this.parsianGateway);
}
getPaymentGateway(provider: GatewayType): IPaymentGateway {