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
- Guard with: if (!await _orderProcessingService.CanVoidAsync(order)) return; and report why.
- Verify PaymentStatus == Authorized before offering Void; if Paid, offer Refund instead.
- Confirm _paymentService.SupportVoidAsync(order.PaymentMethodSystemName); otherwise use VoidOfflineAsync if the order is Authorized.
- 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
- Only offer Void when PaymentStatus == Authorized.
- If Paid, offer Refund instead of Void.
- Confirm the gateway supports void; otherwise use VoidOfflineAsync.
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
- Cannot do capture for order.
- Cannot do refund for order.
- You can't void this order
- You can't mark this order as paid
- You can't refund this order
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/460306b4ea4da31a.
Report an issue: GitHub.