Options and admin API
Every plugin option with its default and legal floor, the scheduled jobs, the event the plugin emits, and the admin API routes.
Options
{
resolve: "@zanreal/medusa-consumer-compliance",
options: {
defaultLocale: "pl",
externalSalesChannelIds: [],
externalOrderMetadataKeys: ["allegro_checkout_form_id"],
omnibus: {
windowDays: 30,
gradualReductions: "per_change",
reductionDetection: "sale_price_list",
priceContexts: undefined,
ignoredPriceListIds: [],
retentionDays: 400,
},
withdrawal: {
periodDays: 14,
rejectOutsidePeriod: false,
extendOverNonWorkingDays: true,
digitalOnly: false,
digitalConsentMetadataKey: "digital_content_consent_at",
confirmationTtlMinutes: 60,
notificationChannel: "email",
notificationTemplate: "consumer-compliance-withdrawal-acknowledgement",
merchantNotificationEmail: null,
seller: { name: "", address: "", email: "" },
},
},
}| Option | Default | Notes |
|---|---|---|
defaultLocale | pl | Fallback for localised texts. |
externalSalesChannelIds | [] | Sales channels whose orders belong to a marketplace (env CONSUMER_COMPLIANCE_EXTERNAL_SALES_CHANNELS in our backend). Such orders get no consent snapshot, no missing-consent flag, and the withdrawal lookup answers external_marketplace_order. |
externalOrderMetadataKeys | ["allegro_checkout_form_id"] | Order metadata keys marking a marketplace order. The Allegro key is always included. |
omnibus.windowDays | 30 | Can be longer, never shorter: values below 30 are raised to 30. |
omnibus.gradualReductions | per_change | Polish law. keep_first only where art. 6a(5) of Directive 98/6/EC was adopted. |
omnibus.reductionDetection | sale_price_list | lower_than_original also counts override lists below the regular price. |
omnibus.priceContexts | one per region | [{ currency_code: "pln", region_id?: "reg_..." }] to record specific contexts instead. |
omnibus.ignoredPriceListIds | [] | Lists never treated as a reduction (for example B2B). |
omnibus.retentionDays | 400 | At least windowDays + 1. History a running reduction needs is kept regardless. |
withdrawal.periodDays | 14 | Can be longer (a more generous policy), never shorter. |
withdrawal.rejectOutsidePeriod | false | true refuses late statements at the API instead of flagging them. |
withdrawal.extendOverNonWorkingDays | true | Art. 115 of the Civil Code. |
withdrawal.digitalOnly | false | Every order line is digital content (ESD codes). With consent recorded there is no right of withdrawal (art. 38 ust. 1 pkt 13); without it the 14-day right stands and the register flags it. See Withdrawal. |
withdrawal.digitalConsentMetadataKey | digital_content_consent_at | Order metadata key with the consent timestamp (art. 38 ust. 1 pkt 13). |
withdrawal.confirmationTtlMinutes | 60 | How long step one stays confirmable. |
withdrawal.notificationChannel | email | Channel for the acknowledgement. |
withdrawal.notificationTemplate | as above | Passed to providers that render templates; ready content is always included. |
withdrawal.merchantNotificationEmail | null | Gets a copy of each acknowledgement. |
withdrawal.seller | empty | Printed on the acknowledgement. |
Jobs and events
| Name | Schedule | What |
|---|---|---|
consumer-compliance-price-sweep | 17 * * * * | Records every variant's current price; catches scheduled price list starts and ends. |
Hook completeCartWorkflow.validate | on cart completion | Blocks completion while a required checkout consent is missing or outdated. Only the cart path: orders created with createOrderWorkflow (Allegro imports) are never checked. |
consumer-compliance-housekeeping | 41 3 * * * | Expires unconfirmed withdrawal requests, removes history past retention. |
Subscribers listen to product, variant, price and price list events (price
history) and to product.deleted (removes the product's compliance data; the
history is kept until retention), and to order.placed (freezes checkout
consents onto the order, skipping marketplace orders). Every subscriber is
fail-safe: an error is logged and never reaches the event emitter. The plugin emits
consumer_compliance.withdrawal.confirmed with { id, order_id }.
Workflows
Exported from @zanreal/medusa-consumer-compliance/workflows:
recordPriceHistoryWorkflow, upsertProductComplianceWorkflow,
upsertUnitPricingWorkflow, upsertEconomicOperatorWorkflow,
deleteEconomicOperatorWorkflow, updateComplianceSettingsWorkflow,
requestWithdrawalWorkflow, confirmWithdrawalWorkflow,
resendWithdrawalAcknowledgementWorkflow, updateWithdrawalStatusWorkflow,
upsertConsentDefinitionWorkflow, deleteConsentDefinitionWorkflow,
recordConsentAcceptancesWorkflow, snapshotOrderConsentsWorkflow.
Admin API
All under /admin/consumer-compliance, authenticated like every admin route.
| Method and path | What |
|---|---|
GET /products/:id | Compliance record, GPSR gaps, operators, unit pricing per variant. |
POST /products/:id | Create or update the compliance record. |
POST /products/:id/unit-pricing | { variants: [{ variant_id, net_quantity, net_unit, reference_unit, drained_quantity, exempt_reason, deposit_amount }] } |
GET /variants/:id/price-history?context_key=pln|reg_... | History, evaluation as of now, available contexts. |
POST /variants/:id/price-history/external | { context_key, amount, valid_from, valid_to, note }: an external price window. |
POST /price-history/backfill | Records all current prices in the background (202). |
GET /operators, POST /operators | List and create economic operators. |
POST /operators/:id, DELETE /operators/:id | Update; delete (refused while assigned). |
GET /settings, POST /settings | Disclosure texts, plus the effective options. |
GET /gpsr-report?offset=0 | Published products with GPSR gaps, 50 per page. |
GET /withdrawals?status=&order_id=&offset=&limit= | The register. |
GET /withdrawals/:id, POST /withdrawals/:id | Read; set status to processed, rejected or back to confirmed, with note. |
POST /withdrawals/:id/resend | Send the acknowledgement again. |
GET /consents, POST /consents | Consent definitions with version history; create. |
POST /consents/:id, DELETE /consents/:id | Update (a text or link change bumps the version); delete. |
GET /orders/:id/consents | The consents frozen onto an order, or external_marketplace_order for a marketplace order. |
GET /order-consents?order_id=&key=&from=&to=&format=csv | Export of all order consents, JSON or CSV. |