{"record":{"id":"be6cb745453cab42","repo":"nopSolutions/nopCommerce","slug":"you-can-t-void-this-order","errorCode":null,"errorMessage":"You can't void this order","messagePattern":"You can't void this order","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Orders/OrderProcessingService.cs","lineNumber":3096,"sourceCode":"        //    return false;\r\n\r\n        if (order.PaymentStatus == PaymentStatus.Authorized)\r\n            return true;\r\n\r\n        return false;\r\n    }\r\n\r\n    /// <summary>\r\n    /// Void order (offline)\r\n    /// </summary>\r\n    /// <param name=\"order\">Order</param>\r\n    /// <returns>A task that represents the asynchronous operation</returns>\r\n    public virtual async Task VoidOfflineAsync(Order order)\r\n    {\r\n        ArgumentNullException.ThrowIfNull(order);\r\n\r\n        if (!CanVoidOffline(order))\r\n            throw new NopException(\"You can't void this order\");\r\n\r\n        order.PaymentStatusId = (int)PaymentStatus.Voided;\r\n        await _orderService.UpdateOrderAsync(order);\r\n\r\n        //add a note\r\n        await AddOrderNoteAsync(order, \"Order has been marked as voided\");\r\n\r\n        //raise event       \r\n        await _eventPublisher.PublishAsync(new OrderVoidedEvent(order));\r\n\r\n        //check order status\r\n        await CheckOrderStatusAsync(order);\r\n    }\r\n\r\n    /// <summary>\r\n    /// Place order items in current user shopping cart.\r\n    /// </summary>\r\n    /// <param name=\"order\">The order</param>\r","sourceCodeStart":3078,"sourceCodeEnd":3114,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Orders/OrderProcessingService.cs#L3078-L3114","documentation":"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.","triggerScenarios":"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.","commonSituations":"Order already Paid (funds captured) so an offline void is invalid; order Pending (not authorized); order already voided; zero-total order.","solutions":["Guard with: if (!_orderProcessingService.CanVoidOffline(order)) return; and report the reason.","Verify PaymentStatus == Authorized before enabling Void; if Paid, use Refund/RefundOffline instead.","For zero-total orders, void is not applicable.","Disable the Void UI action once the order leaves Authorized status."],"exampleFix":"// before\nawait _orderProcessingService.VoidOfflineAsync(order);\n\n// after\nif (!_orderProcessingService.CanVoidOffline(order))\n    return;\n\nawait _orderProcessingService.VoidOfflineAsync(order);","handlingStrategy":"validation","validationCode":"if (!_orderProcessingService.CanVoidOffline(order))\n    return;\n\nawait _orderProcessingService.VoidOfflineAsync(order);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only offer offline Void when PaymentStatus == Authorized.","If Paid, use Refund/RefundOffline instead.","Skip for zero-total orders."],"tags":["void","offline","payment","order-processing"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}