{"record":{"id":"612c77baa16d5e2d","repo":"nopSolutions/nopCommerce","slug":"unable-to-assign-tracking-information-to-orders-wi","errorCode":null,"errorMessage":"Unable to assign tracking information to orders with the payment in {order.Status} status","messagePattern":"Unable to assign tracking information to orders with the payment in (.+?) status","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"warning","filePath":"src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs","lineNumber":2940,"sourceCode":"            customValues.FillByXml(nopOrder.CustomValuesXml);\n            var orderIdKey = await _localizationService.GetResourceAsync(\"Plugins.Payments.PayPalCommerce.Order.Id\");\n            if (!customValues.TryGetValue(orderIdKey, out var orderIdValue))\n                throw new NopException(\"Failed to get PayPal order info\");\n\n            var order = await _httpClient\n                .RequestAsync<GetOrderRequest, GetOrderResponse>(new GetOrderRequest { OrderId = orderIdValue.Value }, settings) as Order;\n            if (order.Status?.ToUpper() != OrderStatusType.COMPLETED.ToString())\n                throw new NopException($\"Unable to assign tracking information to orders in {order.Status} status\");\n\n            if (order.PurchaseUnits?.FirstOrDefault() is not PurchaseUnit unit || unit.Shipping is null)\n                throw new NopException(\"No shipping info found for PayPal order\");\n\n            if (unit.Payments?.Captures?.FirstOrDefault() is not Capture capture ||\n                (capture.Status?.ToUpper() != CaptureStatusType.COMPLETED.ToString() &&\n                capture.Status?.ToUpper() != CaptureStatusType.PARTIALLY_REFUNDED.ToString() &&\n                capture.Status?.ToUpper() != CaptureStatusType.PENDING.ToString()))\n            {\n                throw new NopException($\"Unable to assign tracking information to orders with the payment in {order.Status} status\");\n            }\n\n            var shipmentItems = await _shipmentService.GetShipmentItemsByShipmentIdAsync(shipment.Id);\n            var items = await shipmentItems.SelectAwait(async shipmentItem =>\n            {\n                var orderItem = await _orderService.GetOrderItemByIdAsync(shipmentItem.OrderItemId);\n                var product = await _productService.GetProductByIdAsync(orderItem.ProductId);\n                var sku = await _productService.FormatSkuAsync(product, orderItem.AttributesXml);\n                var url = await _nopUrlHelper.RouteGenericUrlAsync(product, _webHelper.GetCurrentRequestProtocol());\n                var picture = await _pictureService.GetProductPictureAsync(product, orderItem.AttributesXml);\n                var (imageUrl, _) = await _pictureService.GetPictureUrlAsync(picture);\n\n                return new Item\n                {\n                    Name = CommonHelper.EnsureMaximumLength(product.Name, 127),\n                    Description = CommonHelper.EnsureMaximumLength(product.ShortDescription, 127),\n                    Sku = CommonHelper.EnsureMaximumLength(sku, 127),\n                    Quantity = shipmentItem.Quantity.ToString(),","sourceCodeStart":2922,"sourceCodeEnd":2958,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs#L2922-L2958","documentation":"Thrown inside SetTrackingAsync when the first capture on the PayPal order's purchase unit is not in an acceptable status for tracking assignment. PayPal requires the payment capture to be COMPLETED, PARTIALLY_REFUNDED, or PENDING before tracking can be added. A capture in DENIED, DECLINED, or fully REFUNDED status makes tracking invalid. Note: the error message uses order.Status (order-level) rather than capture.Status, which may be misleading.","triggerScenarios":"unit.Payments.Captures is null or empty (no capture exists), or the first capture's status is not COMPLETED, PARTIALLY_REFUNDED, or PENDING — e.g. it is DENIED, REFUNDED, or FAILED.","commonSituations":"The capture was denied by PayPal risk/fraud check; the order was fully refunded before the shipment was created; the payment is still being reviewed and capture has not yet occurred; a payment dispute or chargeback changed the capture status.","solutions":["Check the capture status in the PayPal dashboard for the specific order","If the capture is DENIED or FAILED, do not attempt tracking sync — resolve the payment issue first","If the capture is REFUNDED, the order should not be shipped — verify with fulfillment team","For PENDING captures, retry tracking sync once the capture settles"],"exampleFix":"// before\nvar (result, error) = await _serviceManager.SetTrackingAsync(settings, shipment);\n\n// after — verify capture status before calling\nvar capture = paypalOrder.PurchaseUnits?.FirstOrDefault()?.Payments?.Captures?.FirstOrDefault();\nif (capture is null)\n    return;\nvar validStatuses = new[] { \"COMPLETED\", \"PARTIALLY_REFUNDED\", \"PENDING\" };\nif (!validStatuses.Contains(capture.Status?.ToUpper()))\n{\n    _logger.Information($\"Capture status {capture.Status} not eligible for tracking sync\");\n    return;\n}\nvar (result, error) = await _serviceManager.SetTrackingAsync(settings, shipment);","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// HandleFunctionAsync catches internally; use error to decide whether to retry or skip\nvar (result, error) = await _serviceManager.SetTrackingAsync(settings, shipment);\nif (!string.IsNullOrEmpty(error) && error.Contains(\"payment in\"))\n{\n    // Capture not in an eligible status — check if it is PENDING and retry later\n    if (await IsCapturePendingAsync(shipment.OrderId))\n        await ScheduleTrackingRetryAsync(shipment.Id, delayMinutes: 60);\n    else\n        _logger.Warning($\"Tracking sync permanently failed for shipment {shipment.Id}: {error}\");\n}","preventionTips":["Do not create shipments for orders with denied or failed captures","For PENDING captures, defer tracking sync until the capture settles","Monitor tracking sync failures and distinguish retryable (PENDING) from permanent (DENIED, REFUNDED) failures","Note: the error message reports order.Status rather than capture.Status — inspect the actual PayPal order for the true capture status"],"tags":["paypal","capture-status","shipment-tracking","refund","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}