feat: add payment module and factory
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user