UNPKG

bc-elavon-sdk

Version:

BetterCommerce's Elavon NodeJS SDK enables BC client applications to integrate with Elavon merchant API system. It publishes an interface to interact with [Elavon API](https://developer.elavon.com/products/checkout-js/v1/api-reference/) endpoints.

117 lines (116 loc) 4.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ElavonEnvironment = void 0; const Endpoints_1 = require("../../constants/Endpoints"); /** * {ElavonEnvironment} class is used to setup the environment. * This class provides options to select the environment. */ class ElavonEnvironment { /** * Initializes the server environment for Elavon. * * This method sets up the environment by configuring merchant and vendor details, * as well as setting the appropriate API base URLs for authentication and communication. * * @param {string} merchantId - The unique identifier for the merchant. * @param {string} merchantUserId - The user identifier for the merchant. * @param {string} merchantPIN - The PIN associated with the merchant account. * @param {string} vendorId - The identifier for the vendor. * @param {boolean} [useSandBox=true] - Flag indicating whether to use the sandbox environment. Defaults to true. * @param {any} [extras={}] - Additional configuration options or parameters. * * @returns {ElavonEnvironment} The configured ElavonEnvironment instance. */ static initServer(merchantId, merchantUserId, merchantPIN, vendorId, useSandBox = true, extras = {}) { ElavonEnvironment.merchantId = merchantId; ElavonEnvironment.merchantUserId = merchantUserId; ElavonEnvironment.merchantPIN = merchantPIN; ElavonEnvironment.vendorId = vendorId; ElavonEnvironment.extras = extras; if (useSandBox) { ElavonEnvironment.authUrl = Endpoints_1.Endpoints.Base.Auth.SANDBOX_URL; ElavonEnvironment.baseUrl = Endpoints_1.Endpoints.Base.Api.SANDBOX_URL; ElavonEnvironment.environment = "sandbox"; } else { ElavonEnvironment.authUrl = Endpoints_1.Endpoints.Base.Auth.PRODUCTION_URL; ElavonEnvironment.baseUrl = Endpoints_1.Endpoints.Base.Api.PRODUCTION_URL; ElavonEnvironment.environment = "production"; } return this; } static getAuthorizationEnabled() { return ElavonEnvironment.authorizationEnabled; } /** * Gets the merchant identifier. * * @returns {string} The unique identifier for the merchant. */ static getMerchantId() { return ElavonEnvironment.merchantId; } /** * Gets the user identifier for the merchant. * * @returns {string} The user identifier for the merchant. */ static getMerchantUserId() { return ElavonEnvironment.merchantUserId; } /** * Gets the merchant's PIN. * * @returns {string} The PIN associated with the merchant account. */ static getMerchantPIN() { return ElavonEnvironment.merchantPIN; } /** * Gets the vendor identifier. * * @returns {string} The unique identifier for the vendor. */ static getVendorId() { return ElavonEnvironment.vendorId; } /** * Get any additional configuration options that were passed in the constructor. * @returns {Object} The additional configuration options. */ static getExtras() { return ElavonEnvironment.extras; } /** * Get the environment set for the CheckoutEnvironment. * For example, "sandbox" or "production". * @returns {string} The environment. */ static getEnvironment() { return ElavonEnvironment.environment; } /** * Returns the base url of the Checkout authentication service. * @returns {string} The base url of the Checkout authentication service. */ static getAuthUrl() { return ElavonEnvironment.authUrl; } /** * Returns the base url of the Checkout API service. * @returns {string} The base url of the Checkout API service. */ static getBaseUrl() { return ElavonEnvironment.baseUrl; } } exports.ElavonEnvironment = ElavonEnvironment; /** * The Converge API uses no auth as an authentication method. Your credentials are sent in the request body using content type x-www-form-urlencoded. * Your Converge credentials include: * Account ID (ssl_account_id) * User ID (ssl_user_id) * Converge PIN (ssl_pin) */ ElavonEnvironment.authorizationEnabled = false;