You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Anil K Patel (Jira)" <ji...@apache.org> on 2026/06/19 08:38:00 UTC
[jira] [Commented] (OFBIZ-1454) refunds do not work with multiple captures
[ https://issues.apache.org/jira/browse/OFBIZ-1454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18090118#comment-18090118 ]
Anil K Patel commented on OFBIZ-1454:
-------------------------------------
This issue is no longer reproducible in current trunk.
The root cause was that `processRefundReturn()` attempted to match a refund amount against a specific `OrderPaymentPreference` record, failing when an order had been fulfilled across multiple shipments with separate payment captures — especially when one capture had already been partially refunded.
Fixed in commits *c53703cc3b* + *02969258c8* (2006-08-21/23, Si Chen, OFBIZ-155) and extended by *3f57e6e024* (2009-06-16, OFBIZ-2503):
> "New methods for figuring out amount of order paid and refunded to each payment method"
> "OFBIZ-155: Refactored processRefundReturn to handle any combination of payment methods"
The current implementation in `OrderReturnServices.java` (lines 1290-1380) works as follows:
1. `OrderReadHelper.getReceivedPaymentTotalsByPaymentMethod()` (line 282) sums all `PMNT_RECEIVED`/`PMNT_CONFIRMED` payment amounts across *all* `OrderPaymentPreference` records, grouped by `paymentMethodId`.
2. `getReturnedTotalsByPaymentMethod()` (line 329) sums all prior `ReturnItemResponse` amounts by the same key.
3. `availableForRefund = totalReceived - totalAlreadyRefunded` per payment method — correctly spanning multiple captures.
4. Refunds are distributed in priority order: billing account → gift card → credit card → EFT.
Multiple captures on the same card pool correctly. Prior partial refunds are fully accounted for. The exception described in the bug cannot occur.
Suggesting this issue be marked Resolved / Fixed.
> refunds do not work with multiple captures
> ------------------------------------------
>
> Key: OFBIZ-1454
> URL: https://issues.apache.org/jira/browse/OFBIZ-1454
> Project: OFBiz
> Issue Type: Bug
> Components: order
> Reporter: Si Chen
> Priority: Major
>
> This is a major problem with refunds: if an order were shipped in several shipments, then refunds will not work probably because PaymentGatewayServices cannot properly match the OrderPaymentPreferences to the amount which needs to be refunded. Sometimes it will turn out one of the captures has already been refunded, and sometimes it will need to piece together several capture payments for refund.
> It might be better to have a ReturnPayment/Preference entity to manage which capture to refund, so there is some way to control this, and then to replace ReturnItemResponse with a ReturnResponse so that the refund payments don't have to be explicitly 1 to 1 with each return item, in case a return item needs to be split on two captures that have to be refunded.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)