Skip to content

Pricing in Commerce

Feature deep dive. Service identity and async surface live in Commerce Overview and API Events.

Pricing lives in a separate package

Dynamic pricing (fares, fare rules, price evaluation) is handled by the @nx/pricing package, not by @nx/commerce. This page documents only the pricing-related features that exist within the commerce package itself.

What Commerce Does for Pricing

Commerce handles pricing at two integration points:

1. Variant-Level Pricing Data

When creating or updating a product variant via the aggregate endpoints, an optional pricing field can be included:

typescript
// POST /product-variants/aggregate
{
  productId: "...",
  info: { name: { en: "Large", vi: "Lớn" } },
  pricing: { /* PricingSchema */ },  // optional
  sku: "SKU-001",
}

If pricing is present it is persisted with the variant. Propagation to the pricing service is CDC-driven — Debezium captures public.ProductVariant writes and the pricing service initializes/updates fare rules from them. Commerce does not application-emit product-variant.* Kafka topics (the enqueue is commented out in product-variant.service.ts).

SourceSignalConsumed by
public.ProductVariant (incl. pricing data)CDC (Debezium)Pricing service → fare rule init/update

2. Provider Integration Configuration

The ConfigurationController manages encrypted provider credentials (for payment, invoice, etc.) which may include pricing-related provider configs:

MethodPathPermission
POST/configurations/provider-integrationsConfiguration.createProviderIntegration
PATCH/configurations/provider-integrations/{id}Configuration.updateProviderIntegration
GET/configurations/provider-integrations/{id}Configuration.getProviderIntegration
DELETE/configurations/provider-integrations/{id}Configuration.deleteProviderIntegration
GET/configurations/provider-integrationsConfiguration.findProviderIntegrations

Credentials are encrypted via EncryptService (AES-256-GCM) and masked in responses (27 asterisks + last 5 characters visible).

Integration code format: {type}:{provider}:{credentialAction}:{credentialType}

3. Tax Group Assignment

Products have an optional taxGroupId field. When set or changed, the write to public.Product is captured by CDC and the Taxation service provisions/deprovisions tax rules accordingly. There is no application-level product.* Kafka emit. See Taxation.

What Commerce Does NOT Do

  • No PricingService in commerce — pricing logic is in @nx/pricing
  • No /pricing/calculate endpoint — price calculation is a pricing service concern
  • No fare sets, fare rules, or price evaluation in commerce source code
  • No REST endpoints for fares or fare rules — those are in the pricing package
PageDescription
Commerce OverviewService identity + catalog
API EventsCDC seam to pricing/taxation
Pricing PackageDynamic pricing engine (fares, rules, evaluation)
TaxationTax group provisioning
ProductsProduct aggregate with taxGroupId
VariantsVariant aggregate with pricing field

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