From 95f51c4d4631de4bf0ba85a6c697382884761ebb Mon Sep 17 00:00:00 2001 From: Kristina <7614497+khjrtbrg@users.noreply.github.com> Date: Thu, 24 Jul 2025 09:53:26 +0200 Subject: [PATCH] Merge pull request #27338 from overleaf/kh-restore-schedule-if-3ds-fails [web] restore previous subscription schedule when 3DS fails GitOrigin-RevId: 27977fb82695d5b212256431c57683abf8a93086 --- .../util/handle-stripe-payment-action.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/subscription/util/handle-stripe-payment-action.ts b/services/web/frontend/js/features/subscription/util/handle-stripe-payment-action.ts index 9912c39f89..61540551fa 100644 --- a/services/web/frontend/js/features/subscription/util/handle-stripe-payment-action.ts +++ b/services/web/frontend/js/features/subscription/util/handle-stripe-payment-action.ts @@ -12,9 +12,19 @@ export default async function handleStripePaymentAction( if (stripe) { const manualConfirmationFlow = await stripe.confirmCardPayment(clientSecret) - if (!manualConfirmationFlow.error) { + if (manualConfirmationFlow.error) { + const paymentIntentId = manualConfirmationFlow.error.payment_intent?.id try { - await postJSON(`/user/subscription/sync`) + await postJSON( + `/user/subscription/void-change?payment_intent_id=${paymentIntentId}` + ) + } catch (error) { + // do nothing + } + return { handled: false } + } else { + try { + await postJSON('/user/subscription/sync') } catch (error) { // if the sync fails, there may be stale data until the webhook is // processed but we can't do any special handling for that in here