Skip to content

Tích hợp Bên thứ ba

BANA tích hợp với các dịch vụ bên ngoài thông qua các thành phần (components) module hóa. Mỗi tích hợp được thiết kế như một thành phần độc lập có thể dễ dàng cấu hình và gắn vào ứng dụng của bạn.

Các Tích hợp Có sẵn

ModuleGóiMô tảNhà cung cấp
MQ-Pay@nx-3rd/mq-payXử lý thanh toán đa nhà cung cấpVNPAY, Nội bộ
IIAPI@nx-3rd/iiapiQuản lý hóa đơn điện tửNhiều T-VAN
T-VAN@nx-3rd/t-vanTích hợp cơ quan thuếCQT Việt Nam

Kiến trúc Tích hợp

Tất cả các tích hợp bên thứ ba đều tuân theo mô hình Thành phần IGNIS:

📱 Ứng dụng Của Bạn
preConfigure() {
  // 1. Bind tùy chọn cấu hình
  this.bind<IOptions>({ key: BindingKeys.OPTIONS })
    .toValue({ ... });

  // 2. Tải thành phần
  this.component(IntegrationComponent);
}
▼ Tải
🧩 Thành phần Tích hợp
🔗setupCustomBindings()Providers, Registries
⚙️setupServices()Dịch vụ logic nghiệp vụ
🌐setupControllers()REST API endpoints
▼ Đăng ký
📦 Tài nguyên Có sẵn
DI Container
services.*Dịch vụ có thể inject
repositories.*Lớp truy cập dữ liệu
controllers.*REST endpoints
AppRegistry (Singleton)
redis:*Kết nối Redis
payment-provider:*Nhà cung cấp thanh toán
bullmq:queue:*Hàng đợi công việc

Mẫu Cấu hình Chung

Tất cả các tích hợp tuân theo một mẫu cấu hình tương tự:

typescript
// 1. Import thành phần và các loại
import {
  IntegrationComponent,
  BindingKeys,
  IOptions
} from '@nx-3rd/integration';

// 2. Cấu hình trong preConfigure() của ứng dụng
class MyApplication extends BaseApplication {
  preConfigure() {
    // Bind tùy chọn trước khi tải thành phần
    this.bind<IOptions>({ key: BindingKeys.OPTIONS })
      .toValue({
        enableControllers: true,  // Tự động đăng ký REST endpoints
        clients: [
          {
            name: 'default',
            provider: 'PROVIDER_NAME',
            // Cấu hình riêng của nhà cung cấp...
          },
        ],
      });

    // Tải thành phần
    this.component(IntegrationComponent);
  }
}

Biến Môi trường

Mỗi tích hợp sử dụng một tiền tố cụ thể cho các biến môi trường:

Tích hợpTiền tốVí dụ
MQ-PayAPP_ENV_MQ_PAY_*APP_ENV_MQ_PAY_POSTGRES_HOST
IIAPIAPP_ENV_IIAPI_*APP_ENV_IIAPI_API_KEY
T-VANAPP_ENV_TVAN_*APP_ENV_TVAN_TAX_CODE

Truy cập Dịch vụ Tích hợp

Qua 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 },
    });
  }
}

Qua AppRegistry (cho Redis, Providers)

typescript
import { AppRegistry } from '@nx-3rd/mq-pay';

// Lấy instance Redis
const registry = AppRegistry.getInstance();
const redis = registry.getRedis({ name: 'redis:@nx-3rd/mq-pay/redis-cache' });

// Lấy Payment Provider
const provider = registry.getPaymentProvider({ name: 'VNPAY_QR_MMS' });

Các bước Tiếp theo

Chọn một tích hợp để tìm hiểu thêm:

  • MQ-Pay - Xử lý thanh toán với VNPAY, Tiền mặt, Thẻ
  • IIAPI - Quản lý hóa đơn điện tử
  • T-VAN - Tuân thủ cơ quan thuế

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.