This project is not covered by Drupal’s security advisory policy.
A module that allows you to store refund information as order items on the order.
Users get a nice interface to check a box next to each order item, broken out by quantity.
You can control who can refund what product types via permissions.
If you partially refund an order item, this will split the order item in two, leaving the unrefunded quantity as one order item, and creating an extra refunded order item with the refunded details.
This allows for easy reporting/reconciliation with finance systems or payment providers which may want to have e.g. a line for each sale and a separate line for each refund.
It will additionally:
- Automatically return stock if commerce_stock is in use
- Automatically remove items from shipments if commerce_shipping is in use
Installing
If you just want to track refunds without any interaction with your payment gateway, the module will allow that out of the box for any payments and order items.
To refund via your gateway, your payment gateway will need to implement two functions - refundFromGateway and undoRefundFromGateway.
To add to your payment gateway, add to 'forms' in the @CommercePaymentGateway annotation:
/**
* @CommercePaymentGateway(
...
* forms = {
...
* "refund-payment" =
* "Drupal\commerce_refund_order_item\PluginForm\PaymentRefundForm",
...
* },
...
* },
* )
*/
Then in that payment gateway, have a function called refundPayment(PaymentInterface $payment, Price $amount = NULL, $itemsWithQuantity = NULL, $adjustments = NULL).
(This will be called when the refund form is submitted).
That function should call:
$refundService = \Drupal::service('commerce_order_item_refund.refund');
$refundService->refundFromGateway($order, $itemsWithQuantity, $amount, $payment, $adjustments);
And also do whatever you need to do in terms of contacting your gateway or payment processor to refund the payment.
Project information
- Project categories: E-commerce
- Ecosystem: Commerce
3 sites report using this module
- Created by maxwellkeeble on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.

