Third-Party Integrations
BANA integrates with external services through modular components. Each integration is designed as a self-contained component that can be easily configured and mounted to your application.
Available Integrations
| Module | Package | Description | Provider |
|---|---|---|---|
| MQ-Pay | @nx-3rd/mq-pay | Multi-provider payment processing | VNPAY, Internal |
| IIAPI | @nx-3rd/iiapi | Electronic invoice management | Multiple T-VAN |
| T-VAN | @nx-3rd/t-van | Tax authority integration | CQT Vietnam |
Integration Architecture
All third-party integrations follow the IGNIS Component pattern:
Your Application
preConfigure() {
// 1. Bind configuration options
this.bind<IOptions>({ key: BindingKeys.OPTIONS })
.toValue({ ... });
// 2. Load the component
this.component(IntegrationComponent);
}
// 1. Bind configuration options
this.bind<IOptions>({ key: BindingKeys.OPTIONS })
.toValue({ ... });
// 2. Load the component
this.component(IntegrationComponent);
}
▼ Loads
Integration Component
setupCustomBindings()→Providers, Registries
setupServices()→Business logic services
setupControllers()→REST API endpoints
▼ Registers
Available Resources
DI Container
services.*→Injectable services
repositories.*→Data access layer
controllers.*→REST endpoints
AppRegistry (Singleton)
redis:*→Redis connections
payment-provider:*→Payment providers
bullmq:queue:*→Job queues
Common Configuration Pattern
All integrations follow a similar configuration pattern:
typescript
// 1. Import the component and types
import {
IntegrationComponent,
BindingKeys,
IOptions
} from '@nx-3rd/integration';
// 2. Configure in your application's preConfigure()
class MyApplication extends BaseApplication {
preConfigure() {
// Bind options before loading component
this.bind<IOptions>({ key: BindingKeys.OPTIONS })
.toValue({
enableControllers: true, // Auto-register REST endpoints
clients: [
{
name: 'default',
provider: 'PROVIDER_NAME',
// Provider-specific config...
},
],
});
// Load the component
this.component(IntegrationComponent);
}
}Environment Variables
Each integration uses a specific prefix for environment variables:
| Integration | Prefix | Example |
|---|---|---|
| MQ-Pay | APP_ENV_MQ_PAY_* | APP_ENV_MQ_PAY_POSTGRES_HOST |
| IIAPI | APP_ENV_IIAPI_* | APP_ENV_IIAPI_API_KEY |
| T-VAN | APP_ENV_TVAN_* | APP_ENV_TVAN_TAX_CODE |
Accessing Integration Services
Via Dependency Injection
typescript
import { inject } from '@venizia/ignis';
import { PaymentService } from '@nx-3rd/mq-pay';
export class SaleOrderService {
constructor(
@inject({ key: 'services.PaymentService' })
private paymentService: PaymentService,
) {}
async checkout(orderId: string) {
return this.paymentService.makePayment({
source: { type: 'SaleOrder', id: orderId },
payment: { provider: 'VNPAY_QR_MMS', total: 100000 },
});
}
}Via AppRegistry (for Redis, Providers)
typescript
import { AppRegistry } from '@nx-3rd/mq-pay';
// Get Redis instance
const registry = AppRegistry.getInstance();
const redis = registry.getRedis({ name: 'redis:@nx-3rd/mq-pay/redis-cache' });
// Get Payment Provider
const provider = registry.getPaymentProvider({ name: 'VNPAY_QR_MMS' });Next Steps
Choose an integration to learn more: