Multiple Partial Refunds on the Same Order Don't Work

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 лет назад
Version: 4.1

In previous versions of nopCommerce (3.8 was the last version we used), you were able to issue multiple partial refunds to the same order.  

However, this is not working in 4.1.  We believe we have traced it to an issue in the CanRefund method (code snippet pasted below).  The problem is with line if (order.RefundedAmount > decimal.Zero).  It results in any order that's been partially refunded returning that you can't issue another partial refund again.  Given what the note says and that this worked in previous versions, this seems to be a bug.

public virtual bool CanRefund(Order order)
        {
            if (order == null)
                throw new ArgumentNullException(nameof(order));

            if (order.OrderTotal == decimal.Zero)
                return false;

            //refund cannot be made if previously a partial refund has been already done. only other partial refund can be made in this case
            if (order.RefundedAmount > decimal.Zero)
                return false;

            //uncomment the lines below in order to disallow this operation for cancelled orders
            //if (order.OrderStatus == OrderStatus.Cancelled)
            //    return false;

            if (order.PaymentStatus == PaymentStatus.Paid &&
                _paymentService.SupportRefund(order.PaymentMethodSystemName))
                return true;

            return false;
        }
5 лет назад
japaneseginger wrote:
public virtual bool CanRefund(Order order)
...
//refund cannot be made if previously a partial refund has been already done. only other partial refund can be made in this case

Actually you invoke "full refund", not partial one
5 лет назад
Sorry I'm still a little confused.  Here's an example of what we were doing.  $100 order. First we initiate a $10 partial refund that works fine. Then we initiate a $5 partial refund that returns refund failed and doesn't work.  After speaking to my developer, he informed me it is because it is hitting that if statement and returning False for CanRefund because in that case order.RefundedAmount = 10. So even though we should be able to refund up to $90 we can't refund any amount.
5 лет назад
japaneseginger wrote:
Sorry I'm still a little confused.  Here's an example of what we were doing.  $100 order. First we initiate a $10 partial refund that works fine. Then we initiate a $5 partial refund that returns refund failed and doesn't work.  After speaking to my developer, he informed me it is because it is hitting that if statement and returning False for CanRefund because in that case order.RefundedAmount = 10. So even though we should be able to refund up to $90 we can't refund any amount.


Yes, you are trying to do a full refund on a partially refunded order..

The code you send is part of FULL REFUND logic.

The partial refund method calls other validations, take a look:


public virtual IList<string> PartiallyRefund(Order order, decimal amountToRefund)
        {
            if (order == null)
                throw new ArgumentNullException(nameof(order));

            if (!CanPartiallyRefund(order, amountToRefund))
                throw new NopException("Cannot do partial refund for order.");

            var request = new RefundPaymentRequest();
            RefundPaymentResult result = null;
            try
.....

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.