Skip to content

Integration

1. Sister Services

Direction: calls / called by / bidir.

SisterDirectionSurfaceContractAuthFailure Mode
@nx/saleKafka PAYMENT_SUCCESSTSalePaymentSuccessat-least-once; guard on non-COMPLETED / existing invoice
@nx/commerceKafka Merchant CDC (Debezium)TDebeziumMessage<TMerchantPgRow> (metadata.tax)at-least-once; op=u diff-skip
@nx/commerceHTTP webhook /webhooks (commerce callback)HMAC-SHA256 signedWEBHOOK_INTERNAL_SECRETreject on bad/missing signature
@nx/identityJWT verification via JWKSVerifierApplicationJWT (ES256)request rejected if unverifiable

2. External Systems

Two adapter layers wrap the external e-invoice providers; the DB provider enum maps to the iiapi enum via InvoiceProviderMapper (src/common/providers.ts).

SystemLayerDirectionSurfaceAuthCredential source
VNIS@nx/iiapie-invoice issuanceclient id/secretcore Configuration row VNIS_DEFAULT_CONNECTION (encrypted) + APP_ENV_VNIS_* defaults
VNPAY@nx/iiapiissuance + inbound webhook callbacksper-merchant username/passwordInvoiceProvider row (AES-256-GCM encrypted)
T-VAN (VNPAY provider)@nx/t-vantransaction-VAN gatewayAPI keycore Configuration row TVAN_DEFAULT_CONNECTION (encrypted credential)

Adapter registration (at boot):

ComponentRegistersWith
InvoiceProviderConnectionComponentVNIS + per-merchant InvoiceProvider clients@nx/iiapi
TVanConnectionComponentT-VAN client from TVAN_DEFAULT_CONNECTION@nx/t-van

Provider mapping (InvoiceProviderMapper):

DB (InvoiceProviders)iiapi (IIAPIProviders)
VNPAYVNPAY

Only VNPAY is in the DB↔iiapi map today; toIIAPI/toDB throw on unknown providers.

3. Critical Cross-Service Flows

3.1 Merchant tax-info (MST) — input → authoritative TaxInfo

Contract:

  • metadata.tax in commerce is the input; TaxInfo (principalType=Merchant) is the authoritative record.
  • Change detection diffs against the persisted TaxInfo, not Debezium's before-image (correct regardless of REPLICA IDENTITY).
  • The frontend reads the merchant.taxInfo relation, never metadata.tax.
  • op=u upsert is tax-only; op=c/r also creates the profile and (if metadata.eInvoice present and merchant eligible) a VNPAY InvoiceProvider.

3.2 Issuance via provider adapters

Contract: eligibility is gated by (businessType, taxMethod)ALLOWED_INVOICE_TYPES. REAL_TIME / BUYER_SELF_SERVICE modes require TaxMethods.DIRECT.

3.3 Inbound webhooks

WebhookSecret envVerification
VNPAY/iiapi callback (vnpayIIAPICallback)APP_ENV_INVOICE_WEBHOOK_SECRETprovider signature header
Commerce callback (commerceCallback)APP_ENV_INVOICE_WEBHOOK_INTERNAL_SECRETHMAC-SHA256 verifyWebhookSignature

4. Contract Stability

SurfaceStabilityVersioning
HTTP /v1/api/*stableURL prefix /v1/
Kafka PAYMENT_SUCCESS (consume)stablefield-additive
Kafka Merchant CDC (consume)stableDebezium envelope
iiapi / t-van adapterexternalprovider-versioned (VNIS/VNPAY/T-VAN APIs)
Webhook /webhooksstablesignature header

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