From 300f3cee8b5bf7068e014a852a7cadbf1374b8fd Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Tue, 7 Jul 2026 16:01:35 +0545 Subject: [PATCH] fix(premiumGeoDB): handle 3DS PaymentAuthentication in re-enable flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handleReEnable discarded the createPremiumGeoDBAddon return value and always reported success. If the endpoint returns a PaymentAuthentication (payment/3DS required) instead of an Addon, the challenge was never initiated — the addon would sit in `pending` while the UI claimed it was re-enabled. Mirror the enable modal: detect the `clientSecret` branch and drive confirmPayment (which redirects to ?type=confirm-addon so the existing onMount handler completes the payment). Matches BAA.svelte's handleReEnable pattern. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../settings/premiumGeoDB.svelte | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/routes/(console)/project-[region]-[project]/settings/premiumGeoDB.svelte b/src/routes/(console)/project-[region]-[project]/settings/premiumGeoDB.svelte index 7d8a0b073..c2124d428 100644 --- a/src/routes/(console)/project-[region]-[project]/settings/premiumGeoDB.svelte +++ b/src/routes/(console)/project-[region]-[project]/settings/premiumGeoDB.svelte @@ -11,6 +11,7 @@ import { Dependencies } from '$lib/constants'; import { addNotification } from '$lib/stores/notifications'; import { sdk } from '$lib/stores/sdk'; + import { confirmPayment } from '$lib/stores/stripe'; import { formatCurrency } from '$lib/helpers/numbers'; import { Badge } from '@appwrite.io/pink-svelte'; import type { Models } from '@appwrite.io/console'; @@ -137,9 +138,30 @@ async function handleReEnable() { reEnabling = true; try { - await sdk.forConsoleIn(page.params.region).projects.createPremiumGeoDBAddon({ - projectId: page.params.project - }); + const result: Models.Addon | Models.PaymentAuthentication = await sdk + .forConsoleIn(page.params.region) + .projects.createPremiumGeoDBAddon({ + projectId: page.params.project + }); + + // Re-enabling a scheduled-for-removal addon is normally free (already paid for + // the cycle), but the endpoint can still return a PaymentAuthentication if a + // charge is required. Mirror the enable modal so 3DS is not silently dropped. + if ('clientSecret' in result) { + const paymentAuth = result as unknown as Models.PaymentAuthentication; + const settingsUrl = resolve('/(console)/project-[region]-[project]/settings', { + region: page.params.region, + project: page.params.project + }); + await confirmPayment({ + clientSecret: paymentAuth.clientSecret, + paymentMethodId: $organization.paymentMethodId, + orgId: $organization.$id, + route: `${settingsUrl}?type=confirm-addon&addonId=${paymentAuth.addonId}` + }); + return; + } + await Promise.all([invalidate(Dependencies.ADDONS), invalidate(Dependencies.PROJECT)]); addNotification({ message: 'Premium Geo DB addon has been re-enabled',