UNPKG

expresscheckout-nodejs

Version:

Juspay's official expresscheckout-nodejs sdk

70 lines 2.97 kB
import * as fs from 'fs'; import path from 'path'; import { JuspayEnvironment } from './JuspayEnvironment.js'; import { DefaultJuspayLogger } from './JuspayLogger.js'; import * as JuspayError from './JuspayError.js'; // resources import Customer from './resources/Customer.js'; import Order from './resources/Order.js'; import Payments from './resources/Payments.js'; import OrderSession from './resources/OrderSession.js'; /** * Juspay's sdk */ var Juspay = /** @class */ (function () { function Juspay(juspayConfig) { var juspayEnvironment = new JuspayEnvironment(juspayConfig); this.juspayEnvironment = juspayEnvironment; this.order = new Order(juspayEnvironment); this.customer = new Customer(juspayEnvironment); this.payments = new Payments(juspayEnvironment); this.orderSession = new OrderSession(juspayEnvironment); } Juspay.getInstanceFromJuspayEnvironment = function (juspayEnvironment) { return new Juspay(juspayEnvironment.getJuspayConfig()); }; Juspay.prototype.getJuspayEnvironment = function () { return this.juspayEnvironment; }; Juspay.getSdkPackage = function () { if (Juspay.pkg != undefined) { return Juspay.pkg; } else { var filePath = path.join(process.cwd(), 'package.json'); if (fs.existsSync(filePath)) { // eslint-disable-next-line @typescript-eslint/no-var-requires try { var pkg = JSON.parse(fs.readFileSync(filePath).toString()); if (pkg.version == undefined || pkg.name == undefined) { throw new JuspayError.JuspayError("Critical! failed to read version or name in package.json, Please report this bug"); } else { return { name: pkg.name, version: pkg.version }; } } catch (ignored) { throw new JuspayError.JuspayError("Critical! failed to parse package.json, Please report this bug."); } } throw new JuspayError.JuspayError("Critical! failed to read package.json, searched path:- ".concat(filePath, ", Please report this bug.")); } }; /** Http Request Defaults constants */ Juspay.DEFAULT_REQUEST_TIMEOUT = 80000; Juspay.SANDBOX_BASE_URL = 'https://sandbox.juspay.in'; Juspay.PRODUCTION_BASE_URL = 'https://api.juspay.in'; Juspay.API_VERSION = '2019-05-07'; Juspay.pkg = Juspay.getSdkPackage(); Juspay.silentLogger = DefaultJuspayLogger.getSilentLogger(); /** exposing errors as static */ Juspay.errors = JuspayError; return Juspay; }()); export { Juspay }; export default Juspay; export * from './JuspayLogger.js'; export * from './JuspayEnvironment.js'; export * from './JuspayError.js'; export * from './types/index.js'; //# sourceMappingURL=Juspay.js.map