UNPKG

bc-opayo-sdk

Version:

BetterCommerce's Opayo NodeJS SDK enables BC client applications to integrate with Opayo merchant API system. It publishes an interface to interact with [Opayo API](https://www.elavon.co.uk/resource-center/help-with-your-solutions/opayo/integrations/types

87 lines (86 loc) 3.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Endpoints_1 = require("../../constants/Endpoints"); /** * {OpayoEnvironment} class is used to setup the environment. * This class provides options to select the environment. */ class OpayoEnvironment { /** * Initializes the OpayoEnvironment with the vendor name, integration key, integration password and * whether to use the sandbox environment or not. If useSandBox is not provided, it will default to true. * @param vendorName {string} The vendor name. * @param integrationKey {string} The integration key. * @param integrationPassword {string} The integration password. * @param useSandBox {boolean} Whether to use the sandbox environment or not. Defaults to true. * @param extras {any} Any additional information that needs to be passed to the server. * @returns {OpayoEnvironment} The OpayoEnvironment instance. */ static init(vendorName, integrationKey, integrationPassword, useSandBox = true, extras = {}) { OpayoEnvironment.vendorName = vendorName; OpayoEnvironment.integrationKey = integrationKey; OpayoEnvironment.integrationPassword = integrationPassword; OpayoEnvironment.extras = extras; if (useSandBox) { OpayoEnvironment.authUrl = Endpoints_1.Endpoints.Base.Auth.SANDBOX_URL; OpayoEnvironment.baseUrl = Endpoints_1.Endpoints.Base.Api.SANDBOX_URL; OpayoEnvironment.environment = "sandbox"; } else { OpayoEnvironment.authUrl = Endpoints_1.Endpoints.Base.Auth.PRODUCTION_URL; OpayoEnvironment.baseUrl = Endpoints_1.Endpoints.Base.Api.PRODUCTION_URL; OpayoEnvironment.environment = "production"; } return this; } /** * Get the vendor name set in the OpayoEnvironment. * @returns {string} The vendor name. */ static getVendorName() { return OpayoEnvironment.vendorName; } /** * Get the integration key set in the OpayoEnvironment. * @returns {string} The integration key. */ static getIntegrationKey() { return OpayoEnvironment.integrationKey; } /** * Get the integration password set in the OpayoEnvironment. * @returns {string} The integration password. */ static getIntegrationPassword() { return OpayoEnvironment.integrationPassword; } /** * Get any additional configuration options that were passed in the constructor. * @returns {Object} The additional configuration options. */ static getExtras() { return OpayoEnvironment.extras; } /** * Get the current environment being used in the OpayoEnvironment. * @returns {string} The current environment, either "sandbox" or "production". */ static getEnvironment() { return OpayoEnvironment.environment; } /** * Get the URL of the authentication service. * @returns {string} The URL of the authentication service. */ static getAuthUrl() { return OpayoEnvironment.authUrl; } /** * Get the URL of the API service. * @returns {string} The URL of the API service. */ static getBaseUrl() { return OpayoEnvironment.baseUrl; } } exports.default = OpayoEnvironment;