modem-pay
Version:
A TypeScript SDK for integrating with the Modem Pay payment gateway, enabling seamless payment processing and financial services in your applications.
120 lines (119 loc) • 4.52 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const transfer_1 = __importDefault(require("../resources/transfer"));
const coupon_1 = __importDefault(require("../resources/coupon"));
const customer_1 = __importDefault(require("../resources/customer"));
const mandate_1 = __importDefault(require("../resources/mandate"));
const payment_intent_1 = __importDefault(require("../resources/payment-intent"));
const payment_link_1 = __importDefault(require("../resources/payment-link"));
const session_1 = __importDefault(require("../resources/session"));
const transaction_1 = __importDefault(require("../resources/transaction"));
const webhook_1 = __importDefault(require("../resources/webhook"));
const balance_1 = __importDefault(require("../resources/balance"));
const sub_account_1 = __importDefault(require("../resources/sub-account"));
const invoice_1 = __importDefault(require("../resources/invoice"));
class ModemPay {
constructor(apiKey, config = { maxRetries: 3, timeout: 60 }) {
var _a, _b;
this._customers = null;
this._sessions = null;
this._paymentLinks = null;
this._paymentIntents = null;
this._invoices = null;
this._balances = null;
this._subAccounts = null;
this._transfers = null;
this._coupons = null;
this._transactions = null;
this._webhooks = null;
this._mandates = null;
this.apiKey = apiKey;
this.maxRetries = (_a = config.maxRetries) !== null && _a !== void 0 ? _a : 3;
this.timeout = (_b = config.timeout) !== null && _b !== void 0 ? _b : 60;
}
get webhooks() {
if (!this._webhooks) {
this._webhooks = new webhook_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._webhooks;
}
get transactions() {
if (!this._transactions) {
this._transactions = new transaction_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._transactions;
}
get transfers() {
if (!this._transfers) {
this._transfers = new transfer_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._transfers;
}
get customers() {
if (!this._customers) {
this._customers = new customer_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._customers;
}
get coupons() {
if (!this._coupons) {
this._coupons = new coupon_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._coupons;
}
get balances() {
if (!this._balances) {
this._balances = new balance_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._balances;
}
get subAccounts() {
if (!this._subAccounts) {
this._subAccounts = new sub_account_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._subAccounts;
}
get sessions() {
if (!this._sessions) {
this._sessions = new session_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._sessions;
}
get paymentLinks() {
if (!this._paymentLinks) {
this._paymentLinks = new payment_link_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._paymentLinks;
}
get paymentIntents() {
if (!this._paymentIntents) {
this._paymentIntents = new payment_intent_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._paymentIntents;
}
get invoices() {
if (!this._invoices) {
this._invoices = new invoice_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._invoices;
}
// get paymentMethods(): PaymentMethodsResource {
// if (!this._paymentMethods) {
// this._paymentMethods = new PaymentMethodsResource(
// this.apiKey,
// this.maxRetries
// );
// }
// return this._paymentMethods;
// }
get mandates() {
if (!this._mandates) {
this._mandates = new mandate_1.default(this.apiKey, this.maxRetries, this.timeout);
}
return this._mandates;
}
}
exports.default = ModemPay;