The production-ready Medusa DTC Starter is outRead the announcement
I

Invoices medusa

Add invoices to Medusa v2

npm install @webbers/invoices-medusa
Category
Built by
Version
1.0.6
Last updated
5 months ago
Monthly downloads
Loading downloads

@webbers/invoices-medusa

A Medusa v2 plugin that automatically generates sequential PDF invoices for orders and credit notes for refunds. PDFs are uploaded to your private file storage bucket and served to customers and admins via presigned URLs.

Requirements

Installation

Configuration

Register the plugin in :

Configuration reference

OptionTypeRequiredDescription
NoFallback locale when is absent or invalid. Defaults to .
YesCompany name shown on the invoice.
YesFunction returning the company address. Receives the i18n country name map for the resolved locale.
YesChamber of Commerce number.
YesVAT registration number.
YesBank account number.
YesBilling contact e-mail.
NoSVG string or data URL used in the default header.
NoRendered logo width in points.
NoTable header fill color (CSS hex).
NoTable header text color (CSS hex).
Nopdfmake content block rendered as page header. Replaces the default logo header.
Nopdfmake content block rendered as page footer.

How it works

Invoice lifecycle

  1. Fulfillment created — the subscriber fires , which:
    • Creates a debit invoice record with an auto-incremented
    • Links it to the order via the link table
    • Generates the PDF and uploads it to the private storage bucket
    • Stores the file ID in
  2. Refund processed — follows the same steps for a credit invoice, referencing the original debit invoice as its parent.
  3. Download requested — the API route resolves to a presigned download URL via and redirects the client. Invoices without a stored PDF (created before this feature) are generated on-demand as a fallback.

Invoice numbering

is a PostgreSQL auto-increment sequence. Voided invoices (created by workflow compensation on failure) preserve their sequence number to avoid gaps.

Localization

The PDF language is determined by . The value is validated against the list of supported locales; if it is absent or unrecognised, from the plugin config is used.

Supported locales:

ValueLanguage
Dutch
Dutch (Belgium) — uses Dutch translations
English
German
French
Italian

Set the locale on an order at creation time:

API routes

Admin

GET /admin/orders/:id/invoice/:invoice_id

Requires admin authentication. Redirects to a presigned download URL for the invoice PDF.

Store

GET /store/orders/:id/invoice

Requires customer authentication. Returns the debit invoice PDF for the order. The order must belong to the authenticated customer.

Workflows

The workflows can be called directly from your own subscribers, jobs, or API routes.

Creates a debit invoice, links it to an order, and generates + uploads the PDF.

Creates a credit invoice for a refund.

Generates an invoice PDF on-demand and returns it as a base64 string. Useful for attaching to notification emails.

Backfill script

To generate and upload PDFs for invoices created before file storage was introduced: