PaymentAdapter interface.
Overview
A payment adapter is a class that translates VaultSaaS SDK’s unified payment interface into provider-specific API calls. Adapters handle:- Payment operations (charge, authorize, capture, refund, void)
- Transaction status queries
- Payment method enumeration
- Webhook signature verification and event parsing
Adapters are stateless and configured per-provider instance. Each adapter receives its configuration via the constructor.
Adapter Interface
All adapters must implement thePaymentAdapter interface defined in /home/daytona/workspace/source/src/types/adapter.ts:23:
Adapter Metadata
Adapters must declare supported capabilities via metadata:Building a Custom Adapter
Implement Payment Operations
Each payment operation should:
- Transform SDK request to provider API format
- Make HTTP request to provider
- Normalize provider response to SDK format
- Handle errors appropriately
Complete Example
Here’s a simplified but complete custom adapter:Using Your Custom Adapter
Register your custom adapter with VaultClient:Reference Implementations
Study the built-in adapters for production-ready patterns:- Stripe Adapter:
/home/daytona/workspace/source/src/adapters/stripe-adapter.ts:268- Full-featured with webhook verification - DLocal Adapter:
/home/daytona/workspace/source/src/adapters/dlocal-adapter.ts:236- Custom authentication headers and HMAC signing
Testing Your Adapter
Use the compliance harness to validate your adapter:Best Practices
Validate Config
Always validate configuration in constructor and throw
VaultConfigError for invalid values.Normalize Responses
Map provider-specific statuses and field names to VaultSaaS canonical formats.
Handle Errors
Catch provider errors and re-throw with VaultSaaS error types for consistent error handling.
Test Thoroughly
Use compliance harness and mock HTTP clients to test all adapter methods.