Log in
Factory

CreditmemoDocumentFactory

Magento\Sales\Model\Order\CreditmemoDocumentFactory

What it does

This factory class creates credit memo (refund) documents in Magento 2, either from an existing order or from an invoice.

Developers use this class when implementing custom refund logic or creating credit memos programmatically through the API, as it handles the complex process of preparing credit memo data, calculating quantities, and attaching comments with proper customer notifications.

Public Methods

  • createFromOrder()
  • createFromInvoice()