nopSolutions/nopCommerce · error · NopException

You can't void this order

Error message

You can't void this order

What it means

Thrown by OrderProcessingService.VoidOfflineAsync when CanVoidOffline(order) returns false. An offline void is allowed only when OrderTotal > 0 and PaymentStatus == Authorized. It does not consult the payment gateway, so it only checks that the order is in an authorized (not yet captured) state with a non-zero total.

Source

Thrown at src/Libraries/Nop.Services/Orders/OrderProcessingService.cs:3096

        //    return false;

        if (order.PaymentStatus == PaymentStatus.Authorized)
            return true;

        return false;
    }

    /// <summary>
    /// Void order (offline)
    /// </summary>
    /// <param name="order">Order</param>
    /// <returns>A task that represents the asynchronous operation</returns>
    public virtual async Task VoidOfflineAsync(Order order)
    {
        ArgumentNullException.ThrowIfNull(order);

        if (!CanVoidOffline(order))
            throw new NopException("You can't void this order");

        order.PaymentStatusId = (int)PaymentStatus.Voided;
        await _orderService.UpdateOrderAsync(order);

        //add a note
        await AddOrderNoteAsync(order, "Order has been marked as voided");

        //raise event       
        await _eventPublisher.PublishAsync(new OrderVoidedEvent(order));

        //check order status
        await CheckOrderStatusAsync(order);
    }

    /// <summary>
    /// Place order items in current user shopping cart.
    /// </summary>
    /// <param name="order">The order</param>

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Guard with: if (!_orderProcessingService.CanVoidOffline(order)) return; and report the reason.
  2. Verify PaymentStatus == Authorized before enabling Void; if Paid, use Refund/RefundOffline instead.
  3. For zero-total orders, void is not applicable.
  4. Disable the Void UI action once the order leaves Authorized status.

Example fix

// before
await _orderProcessingService.VoidOfflineAsync(order);

// after
if (!_orderProcessingService.CanVoidOffline(order))
    return;

await _orderProcessingService.VoidOfflineAsync(order);
Defensive patterns

Strategy: validation

Validate before calling

if (!_orderProcessingService.CanVoidOffline(order))
    return;

await _orderProcessingService.VoidOfflineAsync(order);

Prevention

When it happens

Trigger: Calling VoidOfflineAsync when: OrderTotal == 0; or PaymentStatus != Authorized (Paid, Voided, Refunded, Pending). Common when an admin voids an order that was already captured (Paid) or already voided.

Common situations: Order already Paid (funds captured) so an offline void is invalid; order Pending (not authorized); order already voided; zero-total order.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/be6cb745453cab42. Report an issue: GitHub.