Overview
TheVaultConfig interface defines all configuration options accepted by new VaultClient(config). Configuration is validated on construction and will throw VaultConfigError if invalid.
VaultConfig
Root configuration object for VaultClient.providers
Map of provider names to their configurations. At least one enabled provider is required.
Example
routing
Local routing configuration. Optional if using platform routing.
RoutingRule
Each routing rule matches transaction attributes and routes to a specific provider.Conditions that must be met for this rule to apply
The provider name to route to (must match a key in
config.providers)Weight for probabilistic routing among multiple matching rules. Higher weights increase selection probability.
Routing Examples
idempotency
Idempotency configuration for preventing duplicate operations
IdempotencyStore Interface
Custom idempotency stores must implement:Example with Custom Redis Store
platformApiKey
API key for VaultSaaS platform integration. Enables platform routing, analytics, and monitoring.
Example
platform
Advanced platform connector configuration. Only relevant when
platformApiKey is set.Example
logging
Logging configuration for SDK operations
LoggerInterface
Custom loggers must implement:Example with Winston
timeout
Global timeout in milliseconds for all payment operations. Individual adapters may have their own timeouts.
Example
Validation
The SDK validates all configuration options on construction:Required Fields
- At least one provider must be configured
- At least one provider must be enabled
- Each provider must have a valid
adapterconstructor - Each provider must have a
configobject
Provider Validation
adaptermust be a constructor function with staticsupportedMethods,supportedCurrencies, andsupportedCountriesarraysconfigmust be a plain objectprioritymust be an integer (if provided)enabledmust be a boolean (if provided)
Routing Validation
- If
routingis provided,rulesmust be a non-empty array - Each rule must have a
providerthat references an enabled provider - Each rule must have a
matchobject - At least one rule must have
match.default: true amountMinandamountMaxmust be non-negative numbersamountMinmust not exceedamountMaxweightmust be a positive number (if provided)
Idempotency Validation
ttlMsmust be a positive integer (if provided)storemust implement all required methods:get,set,delete,clearExpired
Platform Validation
platformApiKeymust not be empty (if provided)baseUrlmust not be empty (if provided)timeoutMs,batchSize,flushIntervalMs,maxRetries,initialBackoffMsmust all be positive integers (if provided)
Logging Validation
levelmust be one of:'silent','error','warn','info','debug'loggermust implement all required methods:error,warn,info,debug