{"record":{"id":"460306b4ea4da31a","repo":"nopSolutions/nopCommerce","slug":"cannot-do-void-for-order","errorCode":null,"errorMessage":"Cannot do void for order.","messagePattern":"Cannot do void for order\\.","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Orders/OrderProcessingService.cs","lineNumber":3012,"sourceCode":"            return true;\r\n\r\n        return false;\r\n    }\r\n\r\n    /// <summary>\r\n    /// Voids order (from admin panel)\r\n    /// </summary>\r\n    /// <param name=\"order\">Order</param>\r\n    /// <returns>\r\n    /// A task that represents the asynchronous operation\r\n    /// The task result contains the voided orders\r\n    /// </returns>\r\n    public virtual async Task<IList<string>> VoidAsync(Order order)\r\n    {\r\n        ArgumentNullException.ThrowIfNull(order);\r\n\r\n        if (!await CanVoidAsync(order))\r\n            throw new NopException(\"Cannot do void for order.\");\r\n\r\n        var request = new VoidPaymentRequest();\r\n        VoidPaymentResult result = null;\r\n        try\r\n        {\r\n            request.Order = order;\r\n            result = await _paymentService.VoidAsync(request);\r\n\r\n            if (result.Success)\r\n            {\r\n                //update order info\r\n                order.PaymentStatus = result.NewPaymentStatus;\r\n                await _orderService.UpdateOrderAsync(order);\r\n\r\n                //add a note\r\n                await AddOrderNoteAsync(order, \"Order has been voided\");\r\n\r\n                //raise event       \r","sourceCodeStart":2994,"sourceCodeEnd":3030,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Orders/OrderProcessingService.cs#L2994-L3030","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar errors = await _orderProcessingService.VoidAsync(order);\n\n// after\nif (!await _orderProcessingService.CanVoidAsync(order))\n    return new[] { \"Void is not available for this order.\" };\n\nvar errors = await _orderProcessingService.VoidAsync(order);","handlingStrategy":"validation","validationCode":"if (!await _orderProcessingService.CanVoidAsync(order))\n    return Array.Empty<string>();\n\nreturn await _orderProcessingService.VoidAsync(order);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only offer Void when PaymentStatus == Authorized.","If Paid, offer Refund instead of Void.","Confirm the gateway supports void; otherwise use VoidOfflineAsync."],"tags":["void","payment","order-processing","payment-method"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}