CreditmemoFactory
Magento\Sales\Model\Order\CreditmemoFactory
What it does
This factory class creates Credit Memo objects in Magento 2, either from an order or from an existing invoice.
Developers use this when implementing refund functionality, allowing them to generate credit memos with specific quantities, shipping amounts, and adjustment values.
It handles complex calculations including tax configurations, bundle products, and partial refunds while ensuring proper validation of refundable items.
Public Methods
- createByOrder()
- createByInvoice()