{"record":{"id":"80e17e622bfe56dc","repo":"Significant-Gravitas/AutoGPT","slug":"your-card-was-declined-the-plan-was-not-changed","errorCode":null,"errorMessage":"Your card was declined. The plan was not changed; please update your payment method and try again.","messagePattern":"Your card was declined\\. The plan was not changed; please update your payment method and try again\\.","errorType":"http","errorClass":"HTTPException","httpStatus":402,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/v1.py","lineNumber":1216,"sourceCode":"            \"authentication_required\",\n            \"subscription_payment_intent_requires_action\",\n        }:\n            logger.warning(\n                \"SCA required on subscription upgrade for user %s: %s\", user_id, e\n            )\n            raise HTTPException(\n                status_code=402,\n                detail=(\n                    \"Your bank requires extra authentication for this charge.\"\n                    \" The plan was not changed; please retry from the billing\"\n                    \" portal so you can complete authentication, or contact\"\n                    \" support.\"\n                ),\n            )\n        logger.warning(\n            \"Card declined on subscription upgrade for user %s: %s\", user_id, e\n        )\n        raise HTTPException(\n            status_code=402,\n            detail=(\n                \"Your card was declined. The plan was not changed; please\"\n                \" update your payment method and try again.\"\n            ),\n        )\n    except stripe.InvalidRequestError as e:\n        # Stripe's e.param is documented as nullable, so we match by typed\n        # field first and fall back to substring when param is absent.\n        msg_lower = (e.user_message or str(e)).lower()\n        # \"No payment method\" presents as InvalidRequestError (not CardError)\n        # when error_if_incomplete fires with no default PM. Stripe signals\n        # this with code=resource_missing/missing — sometimes with a typed\n        # 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 {","sourceCodeStart":1198,"sourceCodeEnd":1234,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/v1.py#L1198-L1234","documentation":"HTTP 402 raised when the subscription modify auto-charge fails with a Stripe CardError that is NOT an SCA code - i.e. a hard decline (card_declined, insufficient_funds, expired_card, etc.). error_if_incomplete guarantees the modify was rolled back, so the plan is unchanged and the user must fix the payment method and retry.","triggerScenarios":"Upgrading a tier with an expired card, a card with insufficient funds, or a card the issuer outright declines.","commonSituations":"Expired/replace card still set as default; insufficient credit limit; issuer fraud blocks on unexpected charges; test cards like 4000000000000002 in non-test mode.","solutions":["Update the payment method (add a valid card) in the billing portal, then retry the upgrade","Check for sufficient funds / contact the issuing bank if declines persist","Verify you are using Stripe test cards only against test-mode keys"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await api.setSubscription(req); }\ncatch (e) {\n  if (e.status === 402 && /declined/.test(e.detail)) promptUpdateCard();\n  else throw e;\n}","preventionTips":["Prompt for a new card on the declined message instead of retrying","Pre-validate cards with a small setup-intent flow where possible"],"tags":["stripe","card-declined","subscription","http-402","payment"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}