mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-03-10 08:01:20 +00:00
* PW-6846: Add Balance Platform to generator * PW-6846: Models * PW-6846: Add configuration options * PW-6846: Account holders * PW-6846: Add AccountHolders tests * PW-6846: Add query string parameters * PW-6846: Make `AccountHolder.id` optional The `AccountHolder.id` field is required at the specs level. It should be optional (or not exist) when sending an update request. * PW-6846: Add Balance accounts endpoints * PW-6846: General endpoints * PW-6846: Add Payment Instruments endpoints * PW-6846: Add Payment Instrument Groups endpoints * PW-6846: Add Transaction Rules endpoints * PW-6846: Fix linting issues
112 lines
4.8 KiB
TypeScript
112 lines
4.8 KiB
TypeScript
/*
|
|
* ######
|
|
* ######
|
|
* ############ ####( ###### #####. ###### ############ ############
|
|
* ############# #####( ###### #####. ###### ############# #############
|
|
* ###### #####( ###### #####. ###### ##### ###### ##### ######
|
|
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
|
|
* ###### ###### #####( ###### #####. ###### ##### ##### ######
|
|
* ############# ############# ############# ############# ##### ######
|
|
* ############ ############ ############# ############ ##### ######
|
|
* ######
|
|
* #############
|
|
* ############
|
|
* Adyen NodeJS API Library
|
|
* Copyright (c) 2020 Adyen B.V.
|
|
* This file is open source and available under the MIT license.
|
|
* See the LICENSE file for more info.
|
|
*/
|
|
interface ConfigConstructor {
|
|
username?: string;
|
|
password?: string;
|
|
merchantAccount?: string;
|
|
environment?: Environment;
|
|
endpoint?: string;
|
|
marketPayEndpoint?: string;
|
|
applicationName?: string;
|
|
apiKey?: string;
|
|
connectionTimeoutMillis?: number;
|
|
readTimeoutMillis?: number;
|
|
certificatePath?: string;
|
|
hppEndpoint?: string;
|
|
skinCode?: string;
|
|
hmacKey?: string;
|
|
checkoutEndpoint?: string;
|
|
terminalApiCloudEndpoint?: string;
|
|
terminalApiLocalEndpoint?: string;
|
|
paymentEndpoint?: string;
|
|
storedValueEndpoint?: string;
|
|
terminalManagementEndpoint?: string;
|
|
managementEndpoint?: string;
|
|
balancePlatformEndpoint?: string;
|
|
}
|
|
|
|
class Config {
|
|
public username?: string;
|
|
public password?: string;
|
|
public merchantAccount?: string;
|
|
public environment?: Environment;
|
|
public endpoint?: string;
|
|
public marketPayEndpoint?: string;
|
|
public applicationName?: string;
|
|
public apiKey?: string;
|
|
public connectionTimeoutMillis?: number;
|
|
public readTimeoutMillis?: number;
|
|
public certificatePath?: string;
|
|
|
|
public hppEndpoint?: string;
|
|
public skinCode?: string;
|
|
public hmacKey?: string;
|
|
|
|
protected _checkoutEndpoint?: string;
|
|
|
|
public terminalApiCloudEndpoint?: string;
|
|
public terminalApiLocalEndpoint?: string;
|
|
|
|
public paymentEndpoint?: string;
|
|
public storedValueEndpoint?: string;
|
|
public terminalManagementEndpoint?: string;
|
|
public managementEndpoint?: string;
|
|
public balancePlatformEndpoint?: string;
|
|
|
|
public constructor(options: ConfigConstructor = {}) {
|
|
if (options.username) this.username = options.username;
|
|
if (options.password) this.password = options.password;
|
|
if (options.merchantAccount) this.merchantAccount = options.merchantAccount;
|
|
if (options.environment) this.environment = options.environment;
|
|
if (options.endpoint) this.endpoint = options.endpoint;
|
|
if (options.marketPayEndpoint) this.marketPayEndpoint = options.marketPayEndpoint;
|
|
if (options.applicationName) this.applicationName = options.applicationName;
|
|
if (options.apiKey) this.apiKey = options.apiKey;
|
|
if (options.connectionTimeoutMillis) this.connectionTimeoutMillis = options.connectionTimeoutMillis || 30000;
|
|
if (options.readTimeoutMillis) this.readTimeoutMillis = options.readTimeoutMillis || 3000;
|
|
if (options.certificatePath) this.certificatePath = options.certificatePath;
|
|
if (options.hppEndpoint) this.hppEndpoint = options.hppEndpoint;
|
|
if (options.skinCode) this.skinCode = options.skinCode;
|
|
if (options.hmacKey) this.hmacKey = options.hmacKey;
|
|
if (options.checkoutEndpoint) this._checkoutEndpoint = options.checkoutEndpoint;
|
|
if (options.terminalApiCloudEndpoint) this.terminalApiCloudEndpoint = options.terminalApiCloudEndpoint;
|
|
if (options.terminalApiLocalEndpoint) this.terminalApiLocalEndpoint = options.terminalApiLocalEndpoint;
|
|
if (options.paymentEndpoint) this.paymentEndpoint = options.paymentEndpoint;
|
|
if (options.storedValueEndpoint) this.storedValueEndpoint = options.storedValueEndpoint;
|
|
if (options.terminalManagementEndpoint) this.terminalManagementEndpoint = options.terminalManagementEndpoint;
|
|
if (options.managementEndpoint) this.managementEndpoint = options.managementEndpoint;
|
|
if (options.balancePlatformEndpoint) this.balancePlatformEndpoint = options.balancePlatformEndpoint;
|
|
}
|
|
|
|
public set checkoutEndpoint(checkoutEndpoint: string | undefined) {
|
|
this._checkoutEndpoint = checkoutEndpoint;
|
|
}
|
|
|
|
public get checkoutEndpoint(): string | undefined {
|
|
if (!this._checkoutEndpoint) {
|
|
const message = "Please provide your unique live url prefix on the setEnvironment() call on the Client or provide checkoutEndpoint in your config object.";
|
|
throw new Error(message);
|
|
} else {
|
|
return this._checkoutEndpoint;
|
|
}
|
|
}
|
|
}
|
|
|
|
export default Config;
|