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:
// 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).
| Source | Signal | Consumed 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:
| Method | Path | Permission |
|---|---|---|
POST | /configurations/provider-integrations | Configuration.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-integrations | Configuration.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
PricingServicein commerce — pricing logic is in@nx/pricing - No
/pricing/calculateendpoint — 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
Related Pages
| Page | Description |
|---|---|
| Commerce Overview | Service identity + catalog |
| API Events | CDC seam to pricing/taxation |
| Pricing Package | Dynamic pricing engine (fares, rules, evaluation) |
| Taxation | Tax group provisioning |
| Products | Product aggregate with taxGroupId |
| Variants | Variant aggregate with pricing field |