{"record":{"id":"4ad625eeb8558e8d","repo":"nopSolutions/nopCommerce","slug":"you-can-t-mark-this-order-as-paid","errorCode":null,"errorMessage":"You can't mark this order as paid","messagePattern":"You can't mark this order as paid","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Orders/OrderProcessingService.cs","lineNumber":2590,"sourceCode":"        if (order.PaymentStatus == PaymentStatus.Paid ||\r\n            order.PaymentStatus == PaymentStatus.Refunded ||\r\n            order.PaymentStatus == PaymentStatus.Voided)\r\n            return false;\r\n\r\n        return true;\r\n    }\r\n\r\n    /// <summary>\r\n    /// Marks order as paid\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 MarkOrderAsPaidAsync(Order order)\r\n    {\r\n        ArgumentNullException.ThrowIfNull(order);\r\n\r\n        if (!CanMarkOrderAsPaid(order))\r\n            throw new NopException(\"You can't mark this order as paid\");\r\n\r\n        order.PaymentStatusId = (int)PaymentStatus.Paid;\r\n        order.PaidDateUtc = DateTime.UtcNow;\r\n        await _orderService.UpdateOrderAsync(order);\r\n\r\n        //add a note\r\n        await AddOrderNoteAsync(order, \"Order has been marked as paid\");\r\n\r\n        await CheckOrderStatusAsync(order);\r\n\r\n        if (order.PaymentStatus == PaymentStatus.Paid)\r\n            await ProcessOrderPaidAsync(order);\r\n    }\r\n\r\n    /// <summary>\r\n    /// Gets a value indicating whether refund from admin panel is allowed\r\n    /// </summary>\r\n    /// <param name=\"order\">Order</param>\r","sourceCodeStart":2572,"sourceCodeEnd":2608,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Orders/OrderProcessingService.cs#L2572-L2608","documentation":"Thrown by OrderProcessingService.MarkOrderAsPaidAsync when CanMarkOrderAsPaid(order) returns false. The order cannot be marked paid if OrderStatus == Cancelled, or if PaymentStatus is already Paid, Refunded, or Voided. It prevents an admin from manually marking an order paid when it is in a terminal/cancelled payment state.","triggerScenarios":"Calling MarkOrderAsPaidAsync when order is Cancelled, or when PaymentStatus is Paid, Refunded, or Voided. Happens on duplicate 'Mark as paid' actions, marking paid a cancelled order, or marking paid an order that a refund/void already settled.","commonSituations":"Admin double-clicking 'Mark as paid'; an integration re-firing the paid event; attempting to mark paid an order that was refunded offline; marking paid a cancelled order.","solutions":["Guard with the helper: if (!_orderProcessingService.CanMarkOrderAsPaid(order)) return; or check status before calling.","Make the mark-paid endpoint idempotent and disable the UI action when PaymentStatus == Paid.","If the order was wrongly cancelled, investigate the cancel flow before marking paid rather than forcing payment.","Ensure integrations only call MarkOrderAsPaidAsync for orders in Pending payment status."],"exampleFix":"// before\nawait _orderProcessingService.MarkOrderAsPaidAsync(order);\n\n// after\nif (!_orderProcessingService.CanMarkOrderAsPaid(order))\n    return;\n\nawait _orderProcessingService.MarkOrderAsPaidAsync(order);","handlingStrategy":"validation","validationCode":"if (!_orderProcessingService.CanMarkOrderAsPaid(order))\n    return;\n\nawait _orderProcessingService.MarkOrderAsPaidAsync(order);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable 'Mark as paid' when PaymentStatus is Paid/Refunded/Voided or order is Cancelled.","Make the mark-paid endpoint idempotent.","Integrations should only mark paid orders in Pending payment status."],"tags":["payment","order","paid","order-processing"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}