diff --git a/src/lib/components/billing/alerts/missingPaymentMethod.svelte b/src/lib/components/billing/alerts/missingPaymentMethod.svelte
new file mode 100644
index 000000000..54689ac48
--- /dev/null
+++ b/src/lib/components/billing/alerts/missingPaymentMethod.svelte
@@ -0,0 +1,27 @@
+
+
+{#if ($orgMissingPaymentMethod.billingPlan === BillingPlan.PRO || $orgMissingPaymentMethod.billingPlan === BillingPlan.SCALE) && !$orgMissingPaymentMethod.paymentMethodId && !$orgMissingPaymentMethod.backupPaymentMethodId && !$page.url.pathname.includes('/console/account')}
+
+
+ Add a payment method to {$orgMissingPaymentMethod.name} before {toLocaleDate(
+ $orgMissingPaymentMethod.billingCurrentInvoiceDate
+ )} to avoid service interruptions to your projects.
+
+
+
+
+
+{/if}
diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts
index 22b873828..f05d13381 100644
--- a/src/lib/stores/billing.ts
+++ b/src/lib/stores/billing.ts
@@ -11,9 +11,10 @@ import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequi
import { addNotification, notifications } from './notifications';
import { goto } from '$app/navigation';
import { base } from '$app/paths';
-import { activeHeaderAlert } from '$routes/console/store';
+import { activeHeaderAlert, orgMissingPaymentMethod } from '$routes/console/store';
import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte';
import { BillingPlan } from '$lib/constants';
+import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte';
export type Tier = 'tier-0' | 'tier-1' | 'tier-2';
@@ -265,3 +266,20 @@ export function checkForMarkedForDeletion(org: Organization) {
});
}
}
+
+export async function checkForMissingPaymentMethod() {
+ const orgs = await sdk.forConsole.teams.list([
+ Query.notEqual('billingPlan', BillingPlan.STARTER),
+ Query.isNull('paymentMethodId'),
+ Query.isNull('backupPaymentMethodId')
+ ]);
+ if (orgs?.total) {
+ orgMissingPaymentMethod.set(orgs.teams[0] as Organization);
+ headerAlert.add({
+ id: 'missingPaymentMethod',
+ component: MissingPaymentMethod,
+ show: true,
+ importance: 8
+ });
+ }
+}
diff --git a/src/routes/console/+layout.svelte b/src/routes/console/+layout.svelte
index dccfe71a4..2bca1c71d 100644
--- a/src/routes/console/+layout.svelte
+++ b/src/routes/console/+layout.svelte
@@ -19,7 +19,8 @@
checkPaymentAuthorizationRequired,
calculateTrialDay,
paymentExpired,
- checkForMarkedForDeletion
+ checkForMarkedForDeletion,
+ checkForMissingPaymentMethod
} from '$lib/stores/billing';
import { goto } from '$app/navigation';
import { CommandCenter, registerCommands, registerSearchers } from '$lib/commandCenter';
@@ -245,6 +246,7 @@
if (isCloud && hasStripePublicKey) {
$stripe = await loadStripe(VARS.STRIPE_PUBLIC_KEY);
+ await checkForMissingPaymentMethod();
}
});
diff --git a/src/routes/console/store.ts b/src/routes/console/store.ts
index 3dabf7951..662572c6f 100644
--- a/src/routes/console/store.ts
+++ b/src/routes/console/store.ts
@@ -1,5 +1,6 @@
import { page } from '$app/stores';
import type { HeaderAlert } from '$lib/stores/headerAlert';
+import type { Organization } from '$lib/stores/organization';
import type { Models } from '@appwrite.io/console';
import { derived, writable } from 'svelte/store';
@@ -10,3 +11,4 @@ export const consoleVariables = derived(
);
export const activeHeaderAlert = writable(null);
+export const orgMissingPaymentMethod = writable(null);