Skip to content

ADR-0001. @nx/mq-pay consumed as component, not separate service

FieldValue
StatusAccepted
Date2026-01-15
Deciderspayment-team
Supersedes

Context

  • @nx/mq-pay is a multi-provider payment engine (VNPAY, etc.) with its own controllers, services, repositories, and BullMQ workers.
  • We needed to integrate it with BANA's auth, identity, and merchant scoping.
  • Two options:
    1. Run mq-pay as a separate microservice with its own deployment + REST surface.
    2. Run mq-pay as an in-process component of @nx/payment.

Decision

Consume mq-pay as a component (MQPayComponent) loaded by ApplicationPaymentComponent. @nx/payment is the deployable service; mq-pay is library code.

Payment provides the integration glue (encrypted credentials, webhook event handler, mode coordination) and reuses mq-pay's controllers, repos, services, workers via in-process registration.

Consequences

ProsCons
One service to deploy / monitor / securePayment + mq-pay versions tightly coupled
In-process = zero RPC latency between auth and mq-payHard to scale mq-pay independently as a separate service
Shared DB / Redis / BullMQ — no double instrumentationMemory footprint of payment includes mq-pay weight
Single Casbin permission catalogueBug in mq-pay can take down payment + IPN reception

Alternatives Considered

OptionProsConsWhy rejected
Separate @nx/mq-pay serviceIndependent scalingPer-request RPC; double infrastructureComplexity not worth it for our scale
Embed mq-pay code directly in paymentOne packageLoses MQ-Pay's portabilityWrong layer — mq-pay is reusable

References

  • src/components/payment.component.ts:76-140 (MQ-Pay setup)
  • @nx/mq-pay/src/component.ts (MQPayComponent)

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