Skip to content

Integration

1. Sister Services

SisterDirectionSurfaceAuthFailure Mode
@nx/sale (payment dispatches)HTTP webhook to POST /v1/api/sale/webhooks/paymentnone (Cilium network policy)Retry per WebhookConfig.metadata.maxRetries; failed dispatches logged
@nx/sale (initiator) (sale calls)HTTP — initiate transaction via @nx/mq-pay controllersJWTsale handles errors
@nx/identity (verify)HTTP — JWKS at /jw-certsnoneCached locally
@nx/identity (Casbin)HTTP — PolicyDefinitionServiceJWTRedis cache
@nx/signalWebSocket emitterbest-effort

2. External Systems

SystemDirectionSurfaceAuthNotes
VN Pay (QR MMS)HTTPS REST + IPNEncrypted credentials per merchant@nx/mq-pay provider
VN Pay (PhonePOS)HTTPS REST + IPNSame
VN Pay (SmartPOS) (placeholder)HTTPS RESTSameProvider declared, integration WIP
PostgreSQLDBpassword from envSchemas: mq_pay, shared Configuration + WebhookConfig
RedisTCPpassword from envBullMQ queues + cache

3. Critical Cross-Service Flows

3.1 Sale → Payment → Provider → Sale (full lifecycle)

3.2 Webhook subscriber registration

3.3 Mode-based deployment topology

Each WORKER pod must have a unique APP_ENV_NODE_ID (Snowflake worker ID) to avoid id collisions.

4. MQ-Pay Bridge Detail

@nx/mq-pay is not a separate service — it's a third-party package consumed by @nx/payment via MQPayComponent. Lifecycle:

StepWhat happens
BootApplicationPaymentComponent.binding() reads APP_ENV_MQ_PAY_MODE
ConfigureBuilds IMQPayOptions with: mode, credentialGetter, vnpay configs (decrypted), eventHandler
RegisterCalls application.component(MQPayComponent)
MQPayComponent bootValidates mode; sets up Redis/BullMQ; registers TransactionRepository, etc.; conditionally registers controllers (FULL/API) and workers (FULL/WORKER)
Event handler setAppRegistry.setEventHandler(WebhookEventHandlerHelper)
RuntimeWorkers emit events → AppRegistry.emit → WebhookEventHandlerHelper.handle

AppRegistry is a separate singleton (NOT IGNIS DI) that manages cross-cutting state for MQ-Pay (Redis, BullMQ, providers, event handler).

5. Contract Stability

SurfaceStabilityVersioning
Webhook payload (mq-pay:* events)stableadditive only
WebhookConfig REST (/webhook-configs)stableURL prefix /v1/
Configuration table (payment rows)stablecode namespace owned by payment
MQ-Pay endpointsstableURL prefix /v1/ (controller paths owned by @nx/mq-pay)
WebSocket topics observation/payment/*stableadditive

6. Crosscutting concerns

ConcernHandling
TrustIPN signed by provider (verified in MQ-Pay); webhook to subscribers signed via HMAC if WebhookConfig.signingMethod set
At-rest encryptionProvider creds encrypted with AES-256-GCM in Configuration.credential; key from APP_ENV_APPLICATION_SECRET
At-flight encryptionTLS at gateway; intra-cluster traffic plaintext
Mode coordinationAPI + WORKER pods share Redis (BullMQ) and PostgreSQL — must use same encryption key
Webhook retryWebhookDispatcherService per WebhookConfig.metadata.maxRetries (default 3) with exponential backoff

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