nopSolutions/nopCommerce · error · NopException

Cannot do void for order.

Error message

Cannot do void for order.

What it means

Thrown by OrderProcessingService.VoidAsync when CanVoidAsync(order) returns false. An online void is allowed only when OrderTotal > 0, PaymentStatus == Authorized, and the payment method supports void (SupportVoidAsync). It blocks voiding orders that are not in an authorized, voidable state or whose gateway cannot void (e.g., already-captured funds).

Source

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

            return true;

        return false;
    }

    /// <summary>
    /// Voids order (from admin panel)
    /// </summary>
    /// <param name="order">Order</param>
    /// <returns>
    /// A task that represents the asynchronous operation
    /// The task result contains the voided orders
    /// </returns>
    public virtual async Task<IList<string>> VoidAsync(Order order)
    {
        ArgumentNullException.ThrowIfNull(order);

        if (!await CanVoidAsync(order))
            throw new NopException("Cannot do void for order.");

        var request = new VoidPaymentRequest();
        VoidPaymentResult result = null;
        try
        {
            request.Order = order;
            result = await _paymentService.VoidAsync(request);

            if (result.Success)
            {
                //update order info
                order.PaymentStatus = result.NewPaymentStatus;
                await _orderService.UpdateOrderAsync(order);

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

                //raise event       

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Guard with: if (!await _orderProcessingService.CanVoidAsync(order)) return; and report why.
  2. Verify PaymentStatus == Authorized before offering Void; if Paid, offer Refund instead.
  3. Confirm _paymentService.SupportVoidAsync(order.PaymentMethodSystemName); otherwise use VoidOfflineAsync if the order is Authorized.
  4. For zero-total orders, void is not applicable.

Example fix

// before
var errors = await _orderProcessingService.VoidAsync(order);

// after
if (!await _orderProcessingService.CanVoidAsync(order))
    return new[] { "Void is not available for this order." };

var errors = await _orderProcessingService.VoidAsync(order);
Defensive patterns

Strategy: validation

Validate before calling

if (!await _orderProcessingService.CanVoidAsync(order))
    return Array.Empty<string>();

return await _orderProcessingService.VoidAsync(order);

Prevention

When it happens

Trigger: Calling VoidAsync when: OrderTotal == 0; PaymentStatus != Authorized (e.g., Paid, Voided, Refunded); or the payment method does not support void. Common from admin 'Void' on an already-captured or already-voided order.

Common situations: Order already captured (Paid) so the gateway cannot void; payment plugin lacking void support; order Pending (not yet authorized); staff confusing void with refund on a Paid order.

Related errors


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