UNPKG

paiementfactory

Version:

Unified SDK for multiple payment gateways (Easebuzz, Razorpay, etc.)

24 lines (23 loc) 782 B
"use strict"; const EasebuzzGateway = require('./gateways/EasebuzzGateway'); const RazorpayGateway = require('./gateways/RazorpayGateway'); const { GATEWAYS } = require("./utils/constants"); class PaiementFactory { static create(type, config) { var _Object$keys; if (config && ((_Object$keys = Object.keys(config)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) == 0) { throw new Error("Please provide payment gateway config"); } switch (type.toLowerCase()) { case GATEWAYS.RAZORYPAY: return new RazorpayGateway(config); case GATEWAYS.EASEBUZZ: return new EasebuzzGateway(config); default: throw new Error(`Unsupported payment gateway: ${type}`); } } } module.exports = PaiementFactory;