UNPKG

@sastatesla/payment-gateway-sdk

Version:

A unified interface for integrating multiple payment providers (e.g., Razorpay, Cashfree) in your Node.js application.

51 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PaymentManager = void 0; const index_1 = require("./providers/index"); const cashfree_1 = require("./providers/cashfree"); const inputParser_1 = require("./utils/inputParser"); class PaymentManager { constructor(providerInstance) { this.providerInstance = providerInstance; } static init(config) { const validatedConfig = (0, inputParser_1.parsePaymentManagerConfig)(config); switch (config.provider) { case "razorpay": return new PaymentManager( // @ts-ignore new index_1.RazorpayProvider(config.config)); case "cashfree": return new PaymentManager( // @ts-ignore new cashfree_1.CashfreeProvider(config.config)); // case "paypal": // return new PaymentManager(new PayPalProvider(config.config)); default: throw new Error("Unsupported provider"); } } charge(...args) { return this.providerInstance.charge(...args); } refund(...args) { return this.providerInstance.refund(...args); } getPaymentStatus(...args) { return this.providerInstance.getPaymentStatus(...args); } listUserPayments(...args) { return this.providerInstance.listUserPayments(...args); } listAllPayments(...args) { return this.providerInstance.listAllPayments(...args); } getSettlementDetails(...args) { return this.providerInstance.getSettlementDetails(...args); } getRefundStatus(...args) { return this.providerInstance.getRefundStatus(...args); } } exports.PaymentManager = PaymentManager; //# sourceMappingURL=gateways-manager.js.map