bc-payments-sdk
Version:
BetterCommerce's Payments NodeJS SDK is a complete solution for storefront clients that integrate payments. `bc-payments-sdk` is a single point interface for storefront clients for interacting with payment gateways.
237 lines (236 loc) • 8.25 kB
TypeScript
/**
* Class {BCEnvironment}
*/
export declare class BCEnvironment {
/**
*
* @property {string}
*/
static baseAuthUrl: string;
/**
*
* @property {string}
*/
static baseApiUrl: string;
/**
*
* @property {string}
*/
static clientId: string;
/**
*
* @property {string}
*/
static sharedSecret: string;
/**
*
* @property {string}
*/
static apiToken: string;
/**
*
* @property {string}
*/
static refreshToken: string;
/**
*
* @property {string}
*/
static defaultCountry: string;
/**
*
* @property {string}
*/
static defaultCurrency: string;
/**
*
* @property {string}
*/
static defaultLanguage: string;
/**
*
* @property {number}
*/
static connectTimeout: number;
/**
*
* @property {number}
*/
static readTimeout: number;
/**
*
* @property {Object}
*/
static config: any;
/**
*
* @property {Object}
*/
static extras: any;
static enableProviderLogging: boolean;
/**
*
* @property {BCEnvironment}
*/
static thisObj: any;
/**
* Initializes the BCEnvironment object with the required parameters to make API calls.
*
* @param {string} clientId - The client ID of the BetterCommerce account.
* @param {string} sharedSecret - The shared secret of the BetterCommerce account.
* @param {Object} [config] - The configuration for payment gateways etc.
* @param {string} [baseAuthUrl] - The base URL for the authentication API.
* @param {string} [baseApiUrl] - The base URL for the API.
* @param {number} [connectTimeout] - The timeout for the connection in milliseconds.
* @param {number} [readTimeout] - The timeout for reading the response in milliseconds.
* @param {string} [defaultCountry] - The default country to use for the API.
* @param {string} [defaultCurrency] - The default currency to use for the API.
* @param {string} [defaultLanguage] - The default language to use for the API.
* @returns {BCEnvironment} - The initialized BCEnvironment object.
*/
static init(clientId: string, sharedSecret: string, config?: any, baseAuthUrl?: string, baseApiUrl?: string, connectTimeout?: number, readTimeout?: number, defaultCountry?: string, defaultCurrency?: string, defaultLanguage?: string): any;
/**
* Initializes the BCEnvironment object with the required parameters to make API calls.
* This method should be used when you already have a valid API token and refresh token.
* @param {string} apiToken - The API token to use for authentication.
* @param {string} refreshToken - The refresh token to use when the API token expires.
* @param {Object} [config] - The configuration for payment gateways etc.
* @param {string} [baseAuthUrl] - The base URL for the authentication API.
* @param {string} [baseApiUrl] - The base URL for the API.
* @param {number} [connectTimeout] - The timeout for the connection in milliseconds.
* @param {number} [readTimeout] - The timeout for reading the response in milliseconds.
* @param {string} [defaultCountry] - The default country to use for the API.
* @param {string} [defaultCurrency] - The default currency to use for the API.
* @param {string} [defaultLanguage] - The default language to use for the API.
* @returns {BCEnvironment} - The initialized BCEnvironment object.
*/
static initSession(apiToken: string, refreshToken: string, config?: any, baseAuthUrl?: string, baseApiUrl?: string, connectTimeout?: number, readTimeout?: number, defaultCountry?: string, defaultCurrency?: string, defaultLanguage?: string): any;
/**
* Static class to hold environment variables for BetterCommerce API
* and payment providers.
*
* @remarks
* The class is a singleton and should be initialized using the static
* method {@link BCEnvironment.init}.
*
* @example
* BCEnvironment.init(clientId, sharedSecret, config);
*
* @example
* const environment = BCEnvironment.init(clientId, sharedSecret, config);
* environment.addExtras({
* country: "GB",
* currency: "GBP",
* language: "en-GB",
* });
*
* @property {string} clientId - The BetterCommerce client ID.
* @property {string} sharedSecret - The BetterCommerce shared secret.
* @property {string} baseAuthUrl - The base URL for authentication.
* @property {string} baseApiUrl - The base URL for API requests.
* @property {number} connectTimeout - The timeout in milliseconds to wait for a connection to be established.
* @property {number} readTimeout - The timeout in milliseconds to wait for a response to be read.
* @property {string} defaultCountry - The default country code.
* @property {string} defaultCurrency - The default currency code.
* @property {string} defaultLanguage - The default language code.
* @property {object} config - The configuration object.
* @property {object} extras - Additional environment variables.
*/
static addExtras(extras: any): any;
/**
* Retrieves the base URL for authentication.
*
* @return {string} The base URL for authentication.
*/
static getBaseAuthUrl(): string;
/**
* Retrieves the base URL for API requests.
*
* @return {string} The base URL for API requests.
*/
static getBaseApiUrl(): string;
/**
* Retrieves the client ID associated with the BetterCommerce account.
*
* @return {string} The client ID.
*/
static getClientId(): string;
/**
* Retrieves the shared secret associated with the BetterCommerce account.
*
* @return {string} The shared secret.
*/
static getSharedSecret(): string;
/**
* Retrieves the API token used for authentication.
*
* @return {string} The API token.
*/
static getApiToken(): string;
/**
* Retrieves the refresh token used for authentication.
*
* @return {string} The refresh token.
*/
static getRefreshToken(): string;
/**
* Retrieves the default country associated with the BetterCommerce account.
*
* @return {string} The default country.
*/
static getDefaultCountry(): string;
/**
* Retrieves the default currency associated with the BetterCommerce account.
*
* @return {string} The default currency.
*/
static getDefaultCurrency(): string;
/**
* Retrieves the default language associated with the BetterCommerce account.
*
* @return {string} The default language.
*/
static getDefaultLanguage(): string;
/**
* Retrieves the connection timeout value for the BetterCommerce API.
*
* @return {number} The connection timeout in milliseconds.
*/
static getConnectTimeout(): number;
/**
* Retrieves the read timeout value for the BetterCommerce API.
*
* @return {number} The read timeout in milliseconds.
*/
static getReadTimeout(): number;
/**
* Retrieves the configuration object used for payment gateways and other settings.
*
* @return {Object} The configuration object.
*/
static getConfig(): Object;
/**
* Retrieves the additional environment variables.
*
* @return {Object} The extras object containing additional environment variables.
*/
static getExtras(): Object;
/**
* Retrieves the flag indicating whether provider logging is enabled.
*
* @return {boolean} True if provider logging is enabled, false otherwise.
*/
static getEnableProviderLogging(): boolean;
/**
* Sets the API token for the BetterCommerce API.
*
* @param {string} apiToken - The API token to set.
*/
static setApiToken(apiToken: string): void;
/**
* Sets the refresh token for the BetterCommerce API.
*
* @param {string} refreshToken - The refresh token to set.
*/
static setRefreshToken(refreshToken: string): void;
}