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

medusa-config.ts
{
  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: "" },
    },
  },
}
OptionDefaultNotes
defaultLocaleplFallback 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.windowDays30Can be longer, never shorter: values below 30 are raised to 30.
omnibus.gradualReductionsper_changePolish law. keep_first only where art. 6a(5) of Directive 98/6/EC was adopted.
omnibus.reductionDetectionsale_price_listlower_than_original also counts override lists below the regular price.
omnibus.priceContextsone 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.retentionDays400At least windowDays + 1. History a running reduction needs is kept regardless.
withdrawal.periodDays14Can be longer (a more generous policy), never shorter.
withdrawal.rejectOutsidePeriodfalsetrue refuses late statements at the API instead of flagging them.
withdrawal.extendOverNonWorkingDaystrueArt. 115 of the Civil Code.
withdrawal.digitalOnlyfalseEvery 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.digitalConsentMetadataKeydigital_content_consent_atOrder metadata key with the consent timestamp (art. 38 ust. 1 pkt 13).
withdrawal.confirmationTtlMinutes60How long step one stays confirmable.
withdrawal.notificationChannelemailChannel for the acknowledgement.
withdrawal.notificationTemplateas abovePassed to providers that render templates; ready content is always included.
withdrawal.merchantNotificationEmailnullGets a copy of each acknowledgement.
withdrawal.selleremptyPrinted on the acknowledgement.

Jobs and events

NameScheduleWhat
consumer-compliance-price-sweep17 * * * *Records every variant's current price; catches scheduled price list starts and ends.
Hook completeCartWorkflow.validateon cart completionBlocks 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-housekeeping41 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 pathWhat
GET /products/:idCompliance record, GPSR gaps, operators, unit pricing per variant.
POST /products/:idCreate 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/backfillRecords all current prices in the background (202).
GET /operators, POST /operatorsList and create economic operators.
POST /operators/:id, DELETE /operators/:idUpdate; delete (refused while assigned).
GET /settings, POST /settingsDisclosure texts, plus the effective options.
GET /gpsr-report?offset=0Published products with GPSR gaps, 50 per page.
GET /withdrawals?status=&order_id=&offset=&limit=The register.
GET /withdrawals/:id, POST /withdrawals/:idRead; set status to processed, rejected or back to confirmed, with note.
POST /withdrawals/:id/resendSend the acknowledgement again.
GET /consents, POST /consentsConsent definitions with version history; create.
POST /consents/:id, DELETE /consents/:idUpdate (a text or link change bumps the version); delete.
GET /orders/:id/consentsThe consents frozen onto an order, or external_marketplace_order for a marketplace order.
GET /order-consents?order_id=&key=&from=&to=&format=csvExport of all order consents, JSON or CSV.

On this page