Merge pull request #966 from appwrite/fix-upgrade-wizard-flow

chore: fix-upgrade-wizard-flow
This commit is contained in:
Christy Jacob authored and GitHub committed 2024-03-15 02:52:43 +05:30
commit 5c05a2b7bb
1 file changed
+3 -9
@@ -10,7 +10,6 @@
import { Dependencies } from '$lib/constants';
import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
import { organization } from '$lib/stores/organization';
import { symmetricDifference } from '$lib/helpers/array';
import { showUsageRatesModal } from '$lib/stores/billing';
import { PaymentBoxes } from '$lib/components/billing';
import { page } from '$app/stores';
@@ -49,15 +48,10 @@
}
} else {
try {
await submitStripeCard(name, $page?.params?.organization ?? null);
const latestMethods = await sdk.forConsole.billing.listPaymentMethods();
const paymentMethod = symmetricDifference(
methods.paymentMethods,
latestMethods.paymentMethods
)[0] as PaymentMethodData;
const card = await sdk.forConsole.billing.getPaymentMethod(paymentMethod.$id);
const method = await submitStripeCard(name, $page?.params?.organization ?? null);
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
if (card?.last4) {
$changeOrganizationTier.paymentMethodId = paymentMethod.$id;
$changeOrganizationTier.paymentMethodId = method.$id;
} else {
throw new Error(
'The payment method you selected is not valid. Please select a different one.'