{"record":{"id":"8417e9e8c8450022","repo":"nopSolutions/nopCommerce","slug":"failed-to-get-paypal-order-info","errorCode":null,"errorMessage":"Failed to get PayPal order info","messagePattern":"Failed to get PayPal order info","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs","lineNumber":1529,"sourceCode":"    /// <param name=\"orderId\">Order id</param>\n    /// <returns>\n    /// A task that represents the asynchronous operation\n    /// The task result contains the order; error message if exists\n    /// </returns>\n    public async Task<(Order Order, string Error)> GetOrderAsync(PayPalCommerceSettings settings, string orderId)\n    {\n        return await HandleFunctionAsync(async () =>\n        {\n            if (!IsConfigured(settings))\n                throw new NopException(\"Plugin not configured\");\n\n            var paymentRequest = await _orderProcessingService.GetProcessPaymentRequestAsync()\n                ?? throw new NopException(\"Order payment info not found\");\n\n            var orderIdKey = await _localizationService.GetResourceAsync(\"Plugins.Payments.PayPalCommerce.Order.Id\");\n            if (!paymentRequest.CustomValues.TryGetValue(orderIdKey, out var orderIdValue) ||\n                !string.Equals(orderIdValue.Value, orderId, StringComparison.InvariantCultureIgnoreCase))\n                throw new NopException(\"Failed to get PayPal order info\");\n\n            var placementKey = await _localizationService.GetResourceAsync(\"Plugins.Payments.PayPalCommerce.Order.Placement\");\n            if (!paymentRequest.CustomValues.TryGetValue(placementKey, out var placementValue) ||\n                !Enum.TryParse<ButtonPlacement>(placementValue.Value, out var placement))\n            {\n                throw new NopException(\"Failed to get PayPal order info\");\n            }\n\n            var order = await _httpClient.RequestAsync<GetOrderRequest, GetOrderResponse>(new GetOrderRequest { OrderId = orderId }, settings);\n\n            return order;\n        });\n    }\n\n    /// <summary>\n    /// Get a previously created order if exists\n    /// </summary>\n    /// <param name=\"settings\">Plugin settings</param>","sourceCodeStart":1511,"sourceCodeEnd":1547,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs#L1511-L1547","documentation":"Thrown in GetOrderAsync when the PayPal order ID cannot be found in the payment request's CustomValues, or the stored order ID does not match the requested orderId. The plugin stores the PayPal order ID as a custom value keyed by a localized resource string; if the key is missing or the value mismatches, the correlation fails.","triggerScenarios":"paymentRequest.CustomValues does not contain the orderIdKey (localized 'Plugins.Payments.PayPalCommerce.Order.Id'), or the value does not match the orderId argument (case-insensitive comparison).","commonSituations":"The localized resource key for the order ID was changed or is missing; the PayPal order ID stored during CreateOrder differs from what was passed to GetOrder (e.g., different order after session reuse); custom code that clears or modifies CustomValues; localization resource corruption after upgrade.","solutions":["Verify the localized resource 'Plugins.Payments.PayPalCommerce.Order.Id' exists and has not been renamed","Ensure the orderId passed to GetOrderAsync is the same one returned by CreateOrderAsync","Check that no custom code modifies paymentRequest.CustomValues between create and get","Re-synchronize localization resources if they were corrupted during an upgrade"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify order ID correlation before calling GetOrderAsync\nvar orderIdKey = await _localizationService\n    .GetResourceAsync(\"Plugins.Payments.PayPalCommerce.Order.Id\");\nvar paymentRequest = await _orderProcessingService.GetProcessPaymentRequestAsync();\nif (paymentRequest is null\n    || !paymentRequest.CustomValues.TryGetValue(orderIdKey, out var storedOrderId)\n    || !string.Equals(storedOrderId.Value, orderId, StringComparison.InvariantCultureIgnoreCase))\n{\n    return Error(\"Order ID mismatch — please restart checkout\");\n}","typeGuard":null,"tryCatchPattern":"var (order, error) = await manager.GetOrderAsync(settings, orderId);\nif (!string.IsNullOrEmpty(error) && error.Contains(\"Failed to get PayPal order info\"))\n    return RedirectToRoute(\"Checkout\");","preventionTips":["Do not modify paymentRequest.CustomValues between CreateOrder and GetOrder","Verify localization resource keys are stable across plugin upgrades","Use the same orderId value throughout the payment flow"],"tags":["order","custom-values","localization","paypal-commerce","nopcommerce","data-correlation"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}