feat: add payment module and factory

This commit is contained in:
mahyargdz
2025-02-03 15:41:53 +03:30
parent 8fb587f976
commit 31368610dd
48 changed files with 931 additions and 81 deletions
@@ -0,0 +1,28 @@
import { BadGatewayException, Injectable } from "@nestjs/common";
import { PaymentMessage } from "../../../common/enums/message.enum";
import { GatewayEnum } from "../enums/gateway.enum";
import { ZarinpalGateway } from "../gateways/zarinpal.gateway";
import { GatewayType } from "../types/gateway.type";
@Injectable()
export class PaymentGatewayFactory {
constructor(private readonly ZarinpalGateway: ZarinpalGateway) {}
//************************ *
getPaymentGateway(provider: GatewayType) {
switch (provider) {
case "zarinpal":
return this.ZarinpalGateway;
default:
throw new BadGatewayException(PaymentMessage.PAYMENT_GATEWAY_NOT_FOUND);
}
}
//************************ */
getAvailablePaymentGateways() {
const gateways = [{ name: GatewayEnum.ZARINPAL }];
return { gateways };
}
}