{"record":{"id":"a27eb58fec822703","repo":"Significant-Gravitas/AutoGPT","slug":"no-payment-method-on-file-the-plan-was-not-change","errorCode":null,"errorMessage":"No payment method on file. The plan was not changed; please add a payment method and try again.","messagePattern":"No payment method on file\\. The plan was not changed; please add a payment method and try again\\.","errorType":"http","errorClass":"HTTPException","httpStatus":402,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":1248,"sourceCode":"        # param, sometimes without (the raw \"no attached payment source\"\n        # message has empty param). Map it to 402 either way.\n        if e.code in {\"resource_missing\", \"missing\"} and (\n            e.param\n            in {\n                \"default_payment_method\",\n                \"payment_method\",\n                \"invoice_settings.default_payment_method\",\n            }\n            or \"no attached payment source\" in msg_lower\n            or \"default payment method\" in msg_lower\n            or \"no payment method\" in msg_lower\n        ):\n            logger.warning(\n                \"No payment method on subscription upgrade for user %s: %s\",\n                user_id,\n                e,\n            )\n            raise HTTPException(\n                status_code=402,\n                detail=(\n                    \"No payment method on file. The plan was not changed;\"\n                    \" please add a payment method and try again.\"\n                ),\n            )\n        # Stripe rejects schedule modify when phases mix currencies, e.g. the\n        # active sub was checked out in GBP but the target tier's Price is\n        # USD-only. e.param is \"currency\" on the schedule API but may be\n        # \"phases\" or absent on older error shapes — substring fallback keeps\n        # the 422 firing instead of dropping to the generic 502.\n        if e.param == \"currency\" or \"currency\" in msg_lower:\n            logger.warning(\n                \"Currency mismatch on tier change for user %s: %s\", user_id, e\n            )\n            raise HTTPException(\n                status_code=422,\n                detail=(","sourceCodeStart":1230,"sourceCodeEnd":1266,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L1230-L1266","documentation":"HTTP 402 raised when the subscription upgrade fails with stripe.InvalidRequestError matching the no-payment-method shapes: e.param in {payment_method, invoice_settings.default_payment_method}, or the message containing 'no attached payment source'/'default payment method'/'no payment method'. With error_if_incomplete, a modify with no default payment method presents as InvalidRequestError rather than CardError, so it is matched by param/substring and mapped to 402.","triggerScenarios":"Upgrading from an admin-granted paid tier (or a subscription created without a card) where the Stripe customer has no default payment method; the auto-charge on modify cannot find a source to charge.","commonSituations":"Admin comped a tier and the user never added a card; a subscription started with a trial requiring no card; payment method was detached in the Stripe dashboard; legacy customers predating mandatory cards.","solutions":["Add a payment method in the billing portal first, then retry the upgrade","Verify in Stripe that invoice_settings.default_payment_method is set on the customer","As an operator: enforce card collection before granting paid tiers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const status = await api.getSubscriptionStatus();\nif (req.tier !== \"BASIC\" && !status.hasPaymentMethod) await redirectToAddPaymentMethod();","typeGuard":null,"tryCatchPattern":"try { await api.setSubscription(req); }\ncatch (e) {\n  if (e.status === 402 && /No payment method on file/.test(e.detail)) openAddCardFlow();\n  else throw e;\n}","preventionTips":["Collect a payment method before exposing upgrades","Check default payment method presence via billing status"],"tags":["stripe","payment-method","subscription","http-402"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}