Architecture Diagram
Core Components
VaultClient
The main orchestration client that serves as the entry point for all operations:- Charge: Process one-time payments
- Authorize: Pre-authorize payments for later capture
- Capture: Capture previously authorized payments
- Refund: Process refunds for completed payments
- Void: Cancel authorized payments
- Status: Check transaction status
- Webhooks: Handle and normalize provider webhook events
The VaultClient is located at
src/client/vault-client.ts:65 and manages all provider adapters, routing logic, and platform integration.Router
Evaluates routing rules and provider capabilities to determine which payment provider should handle each transaction.The Router must include at least one rule with
match.default: true to serve as a fallback.Provider Adapters
Implement provider-specific API calls and webhook verification. Each adapter:- Translates normalized requests into provider-specific API calls
- Normalizes provider responses into canonical formats
- Handles webhook signature verification
- Declares supported payment methods, currencies, and countries
Error Mapper
Normalizes provider-specific and network failures into canonicalVaultError codes with consistent error shapes.
Error Mapping
Idempotency Store
Prevents duplicate operation execution for repeated idempotency keys.Idempotency Configuration
Platform Connector
Optional component for telemetry and remote routing integration with VaultSaaS platform.Platform Integration
When enabled, the Platform Connector sends transaction reports and webhook events for analytics, and can provide dynamic routing decisions.
Data Flow
Payment Processing Flow
- Application calls
vault.charge(request) - VaultClient validates configuration
- Router evaluates rules and selects provider
- Idempotency check (if
idempotencyKeyprovided) - Provider adapter executes API call
- Error mapper handles failures
- Response normalized and returned
- Transaction report queued to Platform Connector
Webhook Processing Flow
- Provider sends webhook to application endpoint
- Application calls
vault.handleWebhook(provider, payload, headers) - Adapter verifies signature (if supported)
- Event normalized to
VaultEventformat - Event returned to application
- Event queued to Platform Connector
Configuration Validation
The VaultClient validates configuration at initialization:src/client/vault-client.ts:76
Configuration validation ensures:
- At least one enabled provider exists
- All adapters are properly configured
- Routing rules include a default fallback
- Required credentials are present
Next Steps
Routing
Learn how to configure routing rules
Error Handling
Understand error types and handling
Idempotency
Implement safe retry logic
Webhooks
Handle provider webhooks