From c2e0c40808b7f1e78eb3c35f8c401daede2b28d5 Mon Sep 17 00:00:00 2001 From: roo hutton Date: Wed, 29 Oct 2025 11:15:46 +0000 Subject: [PATCH] Merge pull request #29193 from overleaf/rh-stripe-addon-error Redirect to plans page if trying to add add-on to non-existing subscription GitOrigin-RevId: 65e0a88c32beca00d700292b14b2e7aa6e4dad20 --- .../Features/Subscription/SubscriptionController.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.mjs b/services/web/app/src/Features/Subscription/SubscriptionController.mjs index b19c300260..8f2432866e 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.mjs +++ b/services/web/app/src/Features/Subscription/SubscriptionController.mjs @@ -523,6 +523,12 @@ async function previewAddonPurchase(req, res) { '/user/subscription?redirect-reason=ai-assist-unavailable' ) } + if ( + err instanceof Error && + err.constructor.name === 'PaymentServiceResourceNotFoundError' + ) { + return res.redirect('/user/subscription/plans#ai-assist') + } throw err } @@ -543,6 +549,12 @@ async function previewAddonPurchase(req, res) { if (err instanceof DuplicateAddOnError) { return res.redirect('/user/subscription?redirect-reason=double-buy') } + if ( + err instanceof Error && + err.constructor.name === 'PaymentServiceResourceNotFoundError' + ) { + return res.redirect('/user/subscription/plans#ai-assist') + } throw err }