UNPKG

bc-clearpay-sdk

Version:

BetterCommerce's ClearPay NodeJS SDK enables BC client applications to integrate with ClearPay merchant API system. It publishes an interface to interact with [ClearPay API v2](https://developers.clearpay.co.uk/clearpay-online/reference) endpoints.

53 lines (52 loc) 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClearPayEnvironment = void 0; const Endpoints_1 = require("../../constants/Endpoints"); /** * Class {ClearPayEnvironment} is used to store the ClearPay environment configuration such as the user ID, password, and base URL. * The class provides a static method {init} to set the configuration. */ class ClearPayEnvironment { /** * Initializes the ClearPay environment with the provided credentials and sets the base URL. * * @param userId - The user ID for authentication. * @param password - The password for authentication. * @param useSandBox - Optional flag to determine if the sandbox environment should be used. Defaults to true. * If true, sets the base URL to the sandbox environment; otherwise, sets it to the production environment. * @returns The ClearPayEnvironment class with updated credentials and base URL. */ static init(userId, password, useSandBox = true) { ClearPayEnvironment.userId = userId; ClearPayEnvironment.password = password; if (useSandBox) { ClearPayEnvironment.baseUrl = Endpoints_1.Endpoints.Base.SANDBOX_URL; } else { ClearPayEnvironment.baseUrl = Endpoints_1.Endpoints.Base.PRODUCTION_URL; } return this; } /** * Gets the user ID for authentication. * @returns {string} The user ID for authentication. */ static getUserId() { return ClearPayEnvironment.userId; } /** * Gets the password for authentication. * @returns {string} The password for authentication. */ static getPassword() { return ClearPayEnvironment.password; } /** * Gets the base URL for the ClearPay API. * @returns {string} The base URL for the ClearPay API. */ static getBaseUrl() { return ClearPayEnvironment.baseUrl; } } exports.ClearPayEnvironment = ClearPayEnvironment;