System components
The framework consists of several key components that work together:PaymentProviderService
ThePaymentProviderService is the main entry point for your connector. It extends VTEX’s base Service class and automatically sets up all required protocol routes.
Location: node/index.ts:5
The service automatically handles route registration, request parsing, and response formatting according to the Payment Provider Protocol.
PaymentProvider class
An abstract class that defines the interface your connector must implement. It provides:- Method signatures for all protocol endpoints
- Helper methods for retry logic
- Type-safe request/response handling
node/connector.ts:36
Builder system
The framework uses two VTEX IO builders:- paymentProvider builder
- node builder
The
paymentProvider builder (version 1.x) provides:- Automatic route generation for manifest and payment-methods endpoints
- Policy injection for Payment Gateway API callbacks
- Integration with VTEX’s payment infrastructure
manifest.json:8VBase storage
VBase is VTEX’s key-value storage system, used by connectors to persist payment data. Use case in connector:node/connector.ts:21
VBase persistence is essential for implementing the retry mechanism correctly. When VTEX retries an authorization request, your connector must return the same response consistently.
Request lifecycle
Here’s how a payment authorization flows through the system:VTEX Payment Gateway sends request
The gateway sends an HTTP POST to your connector’s
/payments endpoint.PaymentProviderService receives request
The service validates the request and routes it to your connector’s
authorize method.Connector processes payment
Your connector:
- Checks VBase for existing responses (idempotency)
- Determines the payment flow based on request data
- Executes the appropriate flow logic
- Persists the response to VBase
Response returned to gateway
The service formats your response according to the protocol and returns it to VTEX.
Configuration architecture
The framework uses a two-layer configuration system:Layer 1: manifest.json
Defines your app’s metadata and requirements. Location:manifest.json
Layer 2: configuration.json
Defines payment-specific configuration. Location:paymentProvider/configuration.json
Policies and permissions
Your connector requires specific policies to function:| Policy | Purpose |
|---|---|
vbase-read-write | Store and retrieve payment data |
colossus-fire-event | Emit events for logging and monitoring |
colossus-write-logs | Write application logs |
outbound-access | Call Payment Gateway callback endpoints |
The
paymentProvider builder automatically adds policies for Payment Gateway API callbacks. You only need to declare additional outbound access if calling external payment APIs.Extending the architecture
You can extend the base architecture by:Adding custom routes
Adding custom clients
Overriding default routes
Define custom paths innode/service.json:
Best practices
- Use VBase for all state: Never store payment data in memory; use VBase for persistence
- Handle idempotency: Always check for existing responses before processing
- Log extensively: Use the logging clients to track payment flows
- Test thoroughly: Use the test suite to validate your implementation
- Follow the protocol: Stick to the standard response formats and status values