nopSolutions/nopCommerce · error · NopException

Failed to get PayPal order info

Error message

Failed to get PayPal order info

What it means

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.

Source

Thrown at src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs:1529

    /// <param name="orderId">Order id</param>
    /// <returns>
    /// A task that represents the asynchronous operation
    /// The task result contains the order; error message if exists
    /// </returns>
    public async Task<(Order Order, string Error)> GetOrderAsync(PayPalCommerceSettings settings, string orderId)
    {
        return await HandleFunctionAsync(async () =>
        {
            if (!IsConfigured(settings))
                throw new NopException("Plugin not configured");

            var paymentRequest = await _orderProcessingService.GetProcessPaymentRequestAsync()
                ?? throw new NopException("Order payment info not found");

            var orderIdKey = await _localizationService.GetResourceAsync("Plugins.Payments.PayPalCommerce.Order.Id");
            if (!paymentRequest.CustomValues.TryGetValue(orderIdKey, out var orderIdValue) ||
                !string.Equals(orderIdValue.Value, orderId, StringComparison.InvariantCultureIgnoreCase))
                throw new NopException("Failed to get PayPal order info");

            var placementKey = await _localizationService.GetResourceAsync("Plugins.Payments.PayPalCommerce.Order.Placement");
            if (!paymentRequest.CustomValues.TryGetValue(placementKey, out var placementValue) ||
                !Enum.TryParse<ButtonPlacement>(placementValue.Value, out var placement))
            {
                throw new NopException("Failed to get PayPal order info");
            }

            var order = await _httpClient.RequestAsync<GetOrderRequest, GetOrderResponse>(new GetOrderRequest { OrderId = orderId }, settings);

            return order;
        });
    }

    /// <summary>
    /// Get a previously created order if exists
    /// </summary>
    /// <param name="settings">Plugin settings</param>

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Verify the localized resource 'Plugins.Payments.PayPalCommerce.Order.Id' exists and has not been renamed
  2. Ensure the orderId passed to GetOrderAsync is the same one returned by CreateOrderAsync
  3. Check that no custom code modifies paymentRequest.CustomValues between create and get
  4. Re-synchronize localization resources if they were corrupted during an upgrade
Defensive patterns

Strategy: validation

Validate before calling

// Verify order ID correlation before calling GetOrderAsync
var orderIdKey = await _localizationService
    .GetResourceAsync("Plugins.Payments.PayPalCommerce.Order.Id");
var paymentRequest = await _orderProcessingService.GetProcessPaymentRequestAsync();
if (paymentRequest is null
    || !paymentRequest.CustomValues.TryGetValue(orderIdKey, out var storedOrderId)
    || !string.Equals(storedOrderId.Value, orderId, StringComparison.InvariantCultureIgnoreCase))
{
    return Error("Order ID mismatch — please restart checkout");
}

Try / catch

var (order, error) = await manager.GetOrderAsync(settings, orderId);
if (!string.IsNullOrEmpty(error) && error.Contains("Failed to get PayPal order info"))
    return RedirectToRoute("Checkout");

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/8417e9e8c8450022. Report an issue: GitHub.