diff --git a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte index 6d6151d98..1a694540b 100644 --- a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte @@ -76,6 +76,10 @@ .getPaymentMethod($organization.paymentMethodId) .then((res) => (defaultPaymentMethod = res)); } + + $: if (!showReplace) { + isSelectedBackup = false; + } diff --git a/src/routes/console/organization-[organization]/billing/replaceCard.svelte b/src/routes/console/organization-[organization]/billing/replaceCard.svelte index a78e57c48..0d1a39571 100644 --- a/src/routes/console/organization-[organization]/billing/replaceCard.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceCard.svelte @@ -5,7 +5,7 @@ import { sdk } from '$lib/stores/sdk'; import { organization } from '$lib/stores/organization'; import { Dependencies } from '$lib/constants'; - import { initializeStripe, submitStripeCard } from '$lib/stores/stripe'; + import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe'; import { onMount } from 'svelte'; import type { PaymentList } from '$lib/sdk/billing'; import { getCreditCardImage } from '$lib/stores/billing'; @@ -26,15 +26,17 @@ selectedPaymentMethodId = isBackup ? $organization.backupPaymentMethodId : $organization.paymentMethodId; - // await initializeStripe(); }); + // TODO: fix new payment method replacement async function handleSubmit() { try { + console.log(selectedPaymentMethodId); if (!selectedPaymentMethodId) { const method = await submitStripeCard(name); selectedPaymentMethodId = method.$id; } + console.log(selectedPaymentMethodId); isBackup ? await addBackupPaymentMethod(selectedPaymentMethodId) : await addPaymentMethod(selectedPaymentMethodId); @@ -83,28 +85,30 @@ } } - $: if (selectedPaymentMethodId === null && show) { + $: if (selectedPaymentMethodId === null && !$isStripeInitialized && show) { initializeStripe(); } $: filteredMethods = methods?.paymentMethods.filter((method) => !!method?.last4); + + $: if (show) { + isStripeInitialized.set(false); + } + + $: if (!show) { + selectedPaymentMethodId = null; + } - + Replace payment method +

Replace the existing payment method for your organization.

{#if methods?.total} {#each filteredMethods as method}
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte index 2762c449a..cfd4ac6e5 100644 --- a/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte +++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte @@ -55,7 +55,7 @@ {#each filteredMethods as method}