Skip to content

Configuration

1. Environment Variables

Source: EnvironmentKeys in @nx/core/src/common/environments.ts + @nx/mq-pay/src/common/environments.ts.

Core runtime

NameTypeDefaultRequiredDescription
APP_ENV_PORTnumber3000HTTP listen port
APP_ENV_HOSTstring0.0.0.0Bind address
APP_ENV_BASE_PATHstring/v1/api/paymentRoute prefix
APP_ENV_NODE_IDnumberSnowflake worker ID — 4 (FULL) / 8 (API) / 91+ (WORKER)
APP_ENV_LOG_LEVELinfo|debug|warn|errorinfo
APP_ENV_NODE_ENVstringdevelopmentdotenv-flow loader
RUN_MODEmigrate|startupstartup triggers MQ-Pay component setup; non-startup skips MQ-Pay (e.g., during migrations)

Mode-based deployment

NameTypeDefaultRequiredDescription
APP_ENV_MQ_PAY_MODEFULL|API|WORKERFULLControls controller + worker registration. See Architecture §3

Database

NameTypeDefaultRequiredDescription
APP_ENV_DB_URLstringPostgreSQL connection URL
APP_ENV_DB_POOL_MAXnumber10

Redis (BullMQ + cache)

NameTypeDefaultRequiredDescription
APP_ENV_REDIS_HOSTstringBullMQ requires Redis (when MQ-Pay is active)
APP_ENV_REDIS_PORTnumber6379
APP_ENV_REDIS_PASSWORDstring
APP_ENV_REDIS_DBnumber0
APP_ENV_WEBSOCKET_REDIS_MODESINGLE|CLUSTERSINGLEWS emitter Redis mode

Encryption

NameTypeDefaultRequiredDescription
APP_ENV_APPLICATION_SECRETstringAES-256-GCM key for CryptoUtility; must match across all pods

Authentication

NameTypeDefaultRequiredDescription
APP_ENV_JWKS_URLurlIdentity service JWKS endpoint

2. Feature Flags

FlagStorageDefaultDescription
Provider enableConfiguration.tValuetruePer-provider enable flag (in encrypted JSON config)
Provider enableControllerConfiguration.tValuetrueWhether to register provider's HTTP controllers
Provider isProductionConfiguration.tValuefalseToggles VN Pay sandbox vs prod URL

3. Seeded Data

3 migration processes in src/migrations/processes/. Run on bootstrap.

FileScopeNotes
payment-0001-seed-vnpay-qr-mms-configuration.tsVNPAY QR MMS provider configEncrypts { enable, isDefault, enableController, appId: 'MERCHANT', masterMerchantCode: 'A000000775', isProduction: false } and stores in Configuration (code: VNPAY_QR_MMS, group: INTEGRATION, environment: DEVELOPMENT)
payment-0002-seed-vnpay-phone-pos-configuration.tsVNPAY PhonePOS provider configEncrypts { enable, isDefault: false, enableController, isProduction: false } and stores similarly
payment-0003-seed-permissions.tsAll PaymentPermissionsalwaysRun: true — re-runs on every migration. Aggregates WebhookConfigPermissions (8 CRUD codes) + 5 sets from @nx/mq-pay (Transaction, TransactionItem, PaymentAttempt, PaymentResult, PaymentOperation)

Per-merchant credentials are NOT seeded — they're created by merchants at onboarding via the Configuration API or admin UI.

4. Configuration Table Usage by Payment

Configuration kindCodeGroupEncryptionSource
VNPAY QR MMS providerVNPAY_QR_MMSINTEGRATIONtValue (AES-256-GCM)seed payment-0001
VNPAY PhonePOS providerVNPAY_PHONE_POSINTEGRATIONtValue (AES-256-GCM)seed payment-0002
Per-merchant payment credentialsper-merchant codeINTEGRATION, principalType=MERCHANT, principalId=<merchantId>credential (AES-256-GCM)runtime via getPaymentCredential

getPaymentCredential queries the table directly (bypasses CRUD repo) because the credential column is hidden from standard CRUD reads.

5. Boot Order

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