Log in
Factory

CreditmemoFactory

Magento\Sales\Model\Order\CreditmemoFactory

What it does

The CreditmemoFactory creates credit memo (refund) objects in Magento 2 either from an order or an invoice.

Developers use this factory when processing refunds, allowing them to specify which items and quantities to refund, along with adjustments for shipping and other amounts.

It handles all the complex logic of calculating refundable quantities, respecting previous refunds, and properly initializing the credit memo with totals.

Public Methods

  • createByOrder()
  • createByInvoice()