{"record":{"id":"b72b7d3095bf7d29","repo":"nopSolutions/nopCommerce","slug":"shopping-cart-has-no-recurring-items","errorCode":null,"errorMessage":"Shopping cart has no recurring items","messagePattern":"Shopping cart has no recurring items","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs","lineNumber":2621,"sourceCode":"    /// <param name=\"settings\">Plugin settings</param>\n    /// <returns>\n    /// A task that represents the asynchronous operation\n    /// The task result contains the setup token; error message if exists\n    /// </returns>\n    public async Task<(PaymentToken PaymentToken, string Error)> CreateSetupTokenAsync(PayPalCommerceSettings settings)\n    {\n        return await HandleFunctionAsync(async () =>\n        {\n            if (!IsConfigured(settings))\n                throw new NopException(\"Plugin not configured\");\n\n            if (!settings.UseVault)\n                throw new NopException(\"Vault disabled\");\n\n            var details = await PrepareCartDetailsAsync(ButtonPlacement.PaymentMethod);\n\n            if (!await _shoppingCartService.ShoppingCartIsRecurringAsync(details.Cart))\n                throw new NopException(\"Shopping cart has no recurring items\");\n\n            if (await _customerService.IsGuestAsync(details.Customer))\n                throw new NopException(\"Anonymous checkout disabled for recurring items\");\n\n            var (error, cycleLength, cyclePeriod, totalCycles) = await _shoppingCartService.GetRecurringCycleInfoAsync(details.Cart);\n            if (!string.IsNullOrEmpty(error))\n                throw new NopException(error);\n\n            var orderGuid = Guid.NewGuid().ToString();\n            var items = await PrepareOrderItemsAsync(details);\n            var orderAmount = await PrepareOrderMoneyAsync(details, items);\n            var shipping = await PrepareShippingDetailsAsync(details, details.ShippingOption?.Name);\n\n            var context = PrepareRecurringPaymentContext(details);\n            var payer = await PrepareBillingDetailsAsync(settings, details);\n\n            //prepare subscription (billing plan) details\n            var billingCycle = new BillingCycle","sourceCodeStart":2603,"sourceCodeEnd":2639,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Services/PayPalCommerceServiceManager.cs#L2603-L2639","documentation":"Thrown by CreateSetupTokenAsync when the current shopping cart has no recurring items (ShoppingCartIsRecurringAsync returns false). Setup tokens are meaningful only for recurring/billing-agreement purchases, so a one-time cart is rejected before contacting PayPal. It is surfaced as the Error string.","triggerScenarios":"The setup-token entry point is reached for a cart containing only standard (non-recurring) products; a recurring product was removed from the cart leaving only one-time items.","commonSituations":"Front-end routing calls the recurring setup-token flow for all checkouts regardless of cart type; a recurring product was misconfigured (no recurring cycle) so it no longer counts as recurring.","solutions":["Only invoke CreateSetupTokenAsync when the cart actually contains recurring products.","Pre-check await _shoppingCartService.ShoppingCartIsRecurringAsync(cart) before showing the recurring checkout button.","Verify recurring products have valid recurring cycle settings so they are recognized as recurring."],"exampleFix":"// before\nvar (token, err) = await _serviceManager.CreateSetupTokenAsync(settings);\n\n// after\nvar details = await PrepareCartDetailsAsync(ButtonPlacement.PaymentMethod);\nif (!await _shoppingCartService.ShoppingCartIsRecurringAsync(details.Cart))\n{\n    NotifyError(\"This flow is only for recurring orders\");\n    return;\n}\nvar (token, err) = await _serviceManager.CreateSetupTokenAsync(settings);","handlingStrategy":"validation","validationCode":"if (!await _shoppingCartService.ShoppingCartIsRecurringAsync(cart))\n    return;","typeGuard":"static async Task<bool> HasRecurring(IShoppingCartService svc, IList<ShoppingCartItem> cart) =>\n    await svc.ShoppingCartIsRecurringAsync(cart);","tryCatchPattern":"var (token, error) = await mgr.CreateSetupTokenAsync(settings);\nif (!string.IsNullOrEmpty(error))\n    NotifyError(error);","preventionTips":["Only route to the setup-token flow for carts with recurring items.","Ensure recurring products have valid cycle settings."],"tags":["validation","payments","paypal-commerce","recurring","shopping-cart"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}