Overview
Revstack’s provider system is fully extensible. You can build custom providers to integrate with any payment processor, billing system, or financial API by implementing the standardIProvider interface.
Why Build a Custom Provider?
Custom providers enable you to:- Integrate with regional or niche payment processors not officially supported
- Connect to internal billing systems or legacy payment infrastructure
- Add custom business logic or data transformations
- Implement provider-specific features not available in standard implementations
Architecture Overview
A provider consists of three main components:- Manifest - Declares capabilities, configuration schema, and metadata
- Provider Class - Implements the
IProviderinterface - API Client - Handles communication with the external payment API
Step 1: Create the Manifest
Start by defining your provider’s manifest. This describes what your provider can do:See providers/core/src/manifest.ts:223 for the complete
ProviderManifest schema.Step 2: Implement the Provider Class
Create a class that extendsBaseProvider and implements the required methods:
See providers/official/stripe/src/provider.ts:45 for a complete reference implementation.
Step 3: Implement Feature Interfaces
If your provider supports additional features, implement the corresponding interfaces:Customer Management
Subscription Management
See providers/core/src/interfaces/features/ for all available feature interfaces.
Step 4: Create the API Client
Implement a client to communicate with the external payment API:Step 5: Register Your Provider
Register your custom provider with Revstack:See providers/registry/src/registry.ts:6 for the registration API.
Testing Your Provider
Create comprehensive tests for your provider:Best Practices
Error Handling
Error Handling
- Always return
AsyncActionResultwith proper error codes - Map provider-specific errors to Revstack error codes
- Include helpful error messages and details
- Log errors for debugging but don’t expose sensitive data
Security
Security
- Never log or expose sensitive credentials
- Mark sensitive fields as
secure: truein the manifest - Implement proper webhook signature verification
- Use HTTPS for all API communication
Performance
Performance
- Implement proper rate limiting per manifest configuration
- Use connection pooling for API clients
- Cache configuration data when appropriate
- Support pagination for list operations
Compatibility
Compatibility
- Follow semantic versioning for your provider
- Mark breaking changes with
breaking: truein releases - Test against multiple Revstack core versions
- Document provider-specific limitations
Not Implemented Features
For features your provider doesn’t support, return aNotImplemented error:
Example: Complete Provider
For a complete working example, see the official Stripe provider:Resources
IProvider Interface
Complete interface documentation
Provider Registry
All provider types and interfaces
Stripe Provider
Reference implementation
Provider Overview
Standard provider reference
Next Steps
After building your provider:- Write comprehensive tests
- Document provider-specific configuration and features
- Submit to the Revstack provider marketplace (optional)
- Monitor performance and error rates in production
Provider Overview
Back to provider architecture overview