From 72a57fbc9cdd4d0494f8dc823d72865f950a8ee5 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 8 May 2024 15:12:15 +0200 Subject: [PATCH 1/7] initial commit --- .../change-plan/+page.svelte | 283 ++++++++++++++++++ 1 file changed, 283 insertions(+) create mode 100644 src/routes/console/organization-[organization]/change-plan/+page.svelte diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte new file mode 100644 index 000000000..18607f9c6 --- /dev/null +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -0,0 +1,283 @@ + + + + Change plan - Appwrite + + + + Change plan + +
+ +

+ For more details on our plans, visit our + . +

+
    +
  • + + +
    +

    + {tierFree.name} + {#if $organization.billingPlan === BillingPlan.STARTER} + Current plan + {/if} +

    +

    {tierFree.description}

    +

    + {formatCurrency(freePlan?.price ?? 0)} +

    +
    +
    +
    +
  • + +
  • + + +
    +

    + {tierPro.name} + {#if $organization.billingPlan === BillingPlan.PRO} + Current plan + {/if} +

    +

    + {tierPro.description} +

    +

    + {formatCurrency(proPlan?.price ?? 0)} per member/month + usage +

    +
    +
    +
    +
  • +
+ {#if billingPlan === BillingPlan.PRO} + + + + + {#if !couponData?.code} + + {/if} + {/if} +
+ + {#if billingPlan !== BillingPlan.STARTER} + + {:else} + + {/if} + +
+ + + + + +
+ + From ba74ffee95351281146643582fa555e7c8a14c6b Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 9 May 2024 22:18:38 +0200 Subject: [PATCH 2/7] feat: change tier functrion --- src/lib/sdk/billing.ts | 2 +- .../change-plan/+page.svelte | 178 +++++++++++++----- 2 files changed, 136 insertions(+), 44 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 1036feda1..a298eace4 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -356,7 +356,7 @@ export class Billing { organizationId: string, billingPlan: string, paymentMethodId: string, - billingAddressId: string + billingAddressId: string = undefined ): Promise { const path = `/organizations/${organizationId}/plan`; const params = { diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index 18607f9c6..e36ba90fe 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -24,7 +24,8 @@ import { addNotification } from '$lib/stores/notifications'; import { organization, organizationList, type Organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; - import { ID } from '@appwrite.io/console'; + import { user } from '$lib/stores/user'; + import { VARS } from '$lib/system'; import { onMount } from 'svelte'; import { writable } from 'svelte/store'; @@ -87,31 +88,103 @@ paymentMethodId = methods.paymentMethods.find((method) => !!method?.last4)?.$id ?? null; } - async function create() { - try { - let org: Organization; + const feedbackDowngradeOptions = [ + { + value: 'availableFeatures', + label: "The available features don't meet my needs" + }, + { + value: 'traction', + label: "My project isn't getting traction" + }, + { + value: 'bugs', + label: 'I experienced bugs or unexpected outages while using the console' + }, + { + value: 'starter', + label: 'The Starter plan is enough for my projects' + }, + { + value: 'budget', + label: "I don't have the budget" + }, + { + value: 'tryOut', + label: 'I just wanted to try it out' + }, + { + value: 'alternative', + label: 'I found an alternative/competitor to meet my needs' + }, + { + value: 'other', + label: 'Other' + } + ]; - if (billingPlan === BillingPlan.STARTER) { - org = await sdk.forConsole.billing.createOrganization( - ID.unique(), - name, - BillingPlan.STARTER, - null, - null - ); - } else { - org = await sdk.forConsole.billing.createOrganization( - ID.unique(), - name, + let feedbackDowngradeReason: string; + let feedbackMessage: string; + + async function update() { + //Downgrade + if (billingPlan === BillingPlan.STARTER) { + try { + await sdk.forConsole.billing.updatePlan( + $organization.$id, billingPlan, paymentMethodId, - '663a2ebf0ac1f0348a58' //TODO: change hardcoded address when it's not mandatory anymore + null ); - //Add budget - if (billingBudget) { - await sdk.forConsole.billing.updateBudget(org.$id, billingBudget, [75]); - } + await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + from: tierToPlan($organization.billingPlan).name, + to: tierToPlan(billingPlan).name, + email: $user.email, + reason: feedbackDowngradeOptions.find( + (option) => option.value === feedbackDowngradeReason + )?.label, + orgId: $organization.$id, + userId: $user.$id, + message: feedbackMessage ?? '' + }) + }); + + addNotification({ + type: 'success', + isHtml: true, + message: ` + ${$organization.name} has been changed to ${ + tierToPlan(billingPlan).name + } plan.` + }); + + trackEvent(Submit.OrganizationDowngrade, { + plan: tierToPlan(billingPlan)?.name + }); + } catch (e) { + addNotification({ + type: 'error', + message: e.message + }); + trackError( + e, + isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade + ); + } + } else { + try { + const org = await sdk.forConsole.billing.updatePlan( + $organization.$id, + billingPlan, + paymentMethodId, + null + ); //Add coupon if (couponData?.code) { @@ -119,6 +192,11 @@ trackEvent(Submit.CreditRedeem); } + //Add budget + if (billingBudget) { + await sdk.forConsole.billing.updateBudget(org.$id, billingBudget, [75]); + } + //Add collaborators if (collaborators?.length) { collaborators.forEach(async (collaborator) => { @@ -133,34 +211,48 @@ }); } - // Add tax ID + //Add tax ID if (taxId) { await sdk.forConsole.billing.updateTaxId(org.$id, taxId); } + + await invalidate(Dependencies.ACCOUNT); + await invalidate(Dependencies.ORGANIZATION); + + await goto(`/console/organization-${org.$id}`); + if (isUpgrade) { + addNotification({ + type: 'success', + message: 'Your organization has been upgraded' + }); + } else { + addNotification({ + type: 'success', + isHtml: true, + message: ` + ${$organization.name} will change to ${ + tierToPlan(billingPlan).name + } plan at the end of the current billing cycle.` + }); + } + trackEvent(isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade, { + plan: tierToPlan(billingPlan)?.name + }); + } catch (e) { + addNotification({ + type: 'error', + message: e.message + }); + trackError( + e, + isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade + ); } - - trackEvent(Submit.OrganizationCreate, { - plan: tierToPlan(billingPlan)?.name, - budget_cap_enabled: !!billingBudget, - members_invited: collaborators?.length - }); - - await invalidate(Dependencies.ACCOUNT); - await preloadData(`${base}/console/organization-${org.$id}`); - await goto(`${base}/console/organization-${org.$id}`); - addNotification({ - type: 'success', - message: `${name ?? 'Organization'} has been created` - }); - } catch (e) { - addNotification({ - type: 'error', - message: e.message - }); - trackError(e, Submit.OrganizationCreate); } } + $: isUpgrade = billingPlan > $organization.billingPlan; + $: freePlan = $plansInfo.get(BillingPlan.STARTER); $: proPlan = $plansInfo.get(BillingPlan.PRO); $: if (billingPlan === BillingPlan.PRO) { @@ -175,7 +267,7 @@ Change plan -
+

For more details on our plans, visit our From 34103f9787cafb4ceaac2ebda3532f6a9b8d557e Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 13 May 2024 10:42:21 +0200 Subject: [PATCH 3/7] more fixes --- .../organization-[organization]/change-plan/+page.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index e36ba90fe..1f1064969 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -1,5 +1,5 @@ - +

{currentPlan.name} plan

{formatCurrency(currentPlan.price)}

diff --git a/src/lib/components/billing/paymentModal.svelte b/src/lib/components/billing/paymentModal.svelte index 2b5ef5d1b..56bcdab20 100644 --- a/src/lib/components/billing/paymentModal.svelte +++ b/src/lib/components/billing/paymentModal.svelte @@ -68,7 +68,12 @@ } - + - + diff --git a/src/lib/components/billing/planComparisonBox.svelte b/src/lib/components/billing/planComparisonBox.svelte index d9ae9326e..85443bcfb 100644 --- a/src/lib/components/billing/planComparisonBox.svelte +++ b/src/lib/components/billing/planComparisonBox.svelte @@ -25,25 +25,25 @@
{#if selectedTab === 'tier-0'}

{plan.name} plan

-
    -
  • +
      +
    • Limited to {plan.databases} Database, {plan.buckets} Buckets, {plan.functions} Functions per project
    • -
    • Limited to 1 organization member
    • -
    • {plan.bandwidth}GB bandwidth
    • -
    • {plan.storage}GB storage
    • -
    • {formatNum(plan.executions)} executions
    • +
    • Limited to 1 organization member
    • +
    • {plan.bandwidth}GB bandwidth
    • +
    • {plan.storage}GB storage
    • +
    • {formatNum(plan.executions)} executions
    {:else if selectedTab === 'tier-1'}

    {plan.name} plan

    -
      -
    • Everything in the Starter plan, plus:
    • -
    • Unlimited databases, buckets, functions
    • -
    • {plan.bandwidth}GB bandwidth
    • -
    • {plan.storage}GB storage
    • -
    • {formatNum(plan.executions)} executions
    • -
    • Email support
    • +
        +
      • Everything in the Starter plan, plus:
      • +
      • Unlimited databases, buckets, functions
      • +
      • {plan.bandwidth}GB bandwidth
      • +
      • {plan.storage}GB storage
      • +
      • {formatNum(plan.executions)} executions
      • +
      • Email support
      {/if}
diff --git a/src/lib/components/billing/selectPaymentMethod.svelte b/src/lib/components/billing/selectPaymentMethod.svelte index 3e4d9269c..fd3ed238f 100644 --- a/src/lib/components/billing/selectPaymentMethod.svelte +++ b/src/lib/components/billing/selectPaymentMethod.svelte @@ -73,7 +73,7 @@ {:else} - +

diff --git a/src/lib/constants.ts b/src/lib/constants.ts index fd4a80b82..3d994e792 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -350,3 +350,38 @@ export enum BillingPlan { PRO = 'tier-1', SCALE = 'tier-2' } + +export const feedbackDowngradeOptions = [ + { + value: 'availableFeatures', + label: "The available features don't meet my needs" + }, + { + value: 'traction', + label: "My project isn't getting traction" + }, + { + value: 'bugs', + label: 'I experienced bugs or unexpected outages while using the console' + }, + { + value: 'starter', + label: 'The Starter plan is enough for my projects' + }, + { + value: 'budget', + label: "I don't have the budget" + }, + { + value: 'tryOut', + label: 'I just wanted to try it out' + }, + { + value: 'alternative', + label: 'I found an alternative/competitor to meet my needs' + }, + { + value: 'other', + label: 'Other' + } +]; diff --git a/src/lib/layout/wizardSecondaryHeader.svelte b/src/lib/layout/wizardSecondaryHeader.svelte index e7971f533..91a5bda0e 100644 --- a/src/lib/layout/wizardSecondaryHeader.svelte +++ b/src/lib/layout/wizardSecondaryHeader.svelte @@ -5,8 +5,8 @@

-
- +
+ diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index 1f1064969..ca73b4ae6 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -3,15 +3,23 @@ import { base } from '$app/paths'; import { page } from '$app/stores'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; - import { LabelCard } from '$lib/components'; + import { Alert, LabelCard } from '$lib/components'; import { EstimatedTotalBox, PlanComparisonBox, SelectPaymentMethod } from '$lib/components/billing'; import ValidateCreditModal from '$lib/components/billing/validateCreditModal.svelte'; - import { BillingPlan, Dependencies } from '$lib/constants'; - import { Button, Form, FormList, InputTags, Label } from '$lib/elements/forms'; + import { BillingPlan, Dependencies, feedbackDowngradeOptions } from '$lib/constants'; + import { + Button, + Form, + FormList, + InputSelect, + InputTags, + InputTextarea, + Label + } from '$lib/elements/forms'; import { formatCurrency } from '$lib/helpers/numbers'; import { WizardSecondaryContainer, @@ -19,16 +27,23 @@ WizardSecondaryFooter, WizardSecondaryHeader } from '$lib/layout'; - import type { Coupon, PaymentList } from '$lib/sdk/billing'; + import { type Coupon, type PaymentList } from '$lib/sdk/billing'; import { plansInfo, tierFree, tierPro, tierToPlan, type Tier } from '$lib/stores/billing'; import { addNotification } from '$lib/stores/notifications'; - import { organization, organizationList, type Organization } from '$lib/stores/organization'; + import { + organization, + organizationList, + type Organization, + type OrganizationList + } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; import { user } from '$lib/stores/user'; import { VARS } from '$lib/system'; import { onMount } from 'svelte'; import { writable } from 'svelte/store'; + export let data; + $: anyOrgFree = $organizationList.teams?.find( (org) => (org as Organization)?.billingPlan === BillingPlan.STARTER ); @@ -41,21 +56,29 @@ let formComponent: Form; let isSubmitting = writable(false); - let methods: PaymentList; let billingPlan: Tier = $organization.billingPlan; let paymentMethodId: string; - let collaborators: string[] = []; + let collaborators: string[] = + data?.members?.memberships + ?.map((m) => { + if (m.userEmail !== $user.email) return m.userEmail; + }) + ?.filter(Boolean) ?? []; let couponData: Partial = { code: null, status: null, credits: null }; let taxId: string; - let billingBudget: number; let showCreditModal = false; + let feedbackDowngradeReason: string; + let feedbackMessage: string; + + let orgList: OrganizationList; + onMount(async () => { if ($page.url.searchParams.has('coupon')) { const coupon = $page.url.searchParams.get('coupon'); @@ -70,9 +93,6 @@ }; } } - if ($page.url.searchParams.has('name')) { - name = $page.url.searchParams.get('name'); - } if ($page.url.searchParams.has('plan')) { const plan = $page.url.searchParams.get('plan'); if (plan && plan in BillingPlan) { @@ -80,183 +100,163 @@ } } billingPlan = $organization.billingPlan; + + if (anyOrgFree && billingPlan === BillingPlan.PRO) { + orgList = await sdk.forConsole.billing.listOrganization(); + } }); async function loadPaymentMethods() { methods = await sdk.forConsole.billing.listPaymentMethods(); - paymentMethodId = methods.paymentMethods.find((method) => !!method?.last4)?.$id ?? null; + + paymentMethodId = + $organization?.paymentMethodId ?? + methods.paymentMethods.find((method) => !!method?.last4)?.$id ?? + null; } - const feedbackDowngradeOptions = [ - { - value: 'availableFeatures', - label: "The available features don't meet my needs" - }, - { - value: 'traction', - label: "My project isn't getting traction" - }, - { - value: 'bugs', - label: 'I experienced bugs or unexpected outages while using the console' - }, - { - value: 'starter', - label: 'The Starter plan is enough for my projects' - }, - { - value: 'budget', - label: "I don't have the budget" - }, - { - value: 'tryOut', - label: 'I just wanted to try it out' - }, - { - value: 'alternative', - label: 'I found an alternative/competitor to meet my needs' - }, - { - value: 'other', - label: 'Other' - } - ]; - - let feedbackDowngradeReason: string; - let feedbackMessage: string; - - async function update() { - //Downgrade + async function handleSubmit() { if (billingPlan === BillingPlan.STARTER) { - try { - await sdk.forConsole.billing.updatePlan( - $organization.$id, - billingPlan, - paymentMethodId, - null + await downgrade(); + } else { + await upgrade(); + } + } + + async function downgrade() { + try { + await sdk.forConsole.billing.updatePlan( + $organization.$id, + billingPlan, + paymentMethodId, + null + ); + + await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + from: tierToPlan($organization.billingPlan).name, + to: tierToPlan(billingPlan).name, + email: $user.email, + reason: feedbackDowngradeOptions.find( + (option) => option.value === feedbackDowngradeReason + )?.label, + orgId: $organization.$id, + userId: $user.$id, + message: feedbackMessage ?? '' + }) + }); + + addNotification({ + type: 'success', + isHtml: true, + message: ` + ${$organization.name} has been changed to ${ + tierToPlan(billingPlan).name + } plan.` + }); + + trackEvent(Submit.OrganizationDowngrade, { + plan: tierToPlan(billingPlan)?.name + }); + } catch (e) { + addNotification({ + type: 'error', + message: e.message + }); + trackError(e, isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade); + } + } + + async function upgrade() { + try { + const org = await sdk.forConsole.billing.updatePlan( + $organization.$id, + billingPlan, + paymentMethodId, + null + ); + + //Add coupon + if (couponData?.code) { + await sdk.forConsole.billing.addCredit(org.$id, couponData.code); + trackEvent(Submit.CreditRedeem); + } + + //Add budget + if (billingBudget) { + await sdk.forConsole.billing.updateBudget(org.$id, billingBudget, [75]); + } + + //Add collaborators + if (collaborators?.length) { + const newCollaborators = collaborators.filter( + (collaborator) => + !data?.members?.memberships?.find((m) => m.userEmail === collaborator) ); - - await fetch(`${VARS.GROWTH_ENDPOINT}/feedback/billing`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - from: tierToPlan($organization.billingPlan).name, - to: tierToPlan(billingPlan).name, - email: $user.email, - reason: feedbackDowngradeOptions.find( - (option) => option.value === feedbackDowngradeReason - )?.label, - orgId: $organization.$id, - userId: $user.$id, - message: feedbackMessage ?? '' - }) + newCollaborators.forEach(async (collaborator) => { + await sdk.forConsole.teams.createMembership( + org.$id, + ['owner'], + collaborator, + undefined, + undefined, + `${$page.url.origin}/console/organization-${org.$id}` + ); }); + } + //Add tax ID + if (taxId) { + await sdk.forConsole.billing.updateTaxId(org.$id, taxId); + } + + await invalidate(Dependencies.ACCOUNT); + await invalidate(Dependencies.ORGANIZATION); + + await goto(`/console/organization-${org.$id}`); + if (isUpgrade) { + addNotification({ + type: 'success', + message: 'Your organization has been upgraded' + }); + } else { addNotification({ type: 'success', isHtml: true, message: ` - ${$organization.name} has been changed to ${ - tierToPlan(billingPlan).name - } plan.` - }); - - trackEvent(Submit.OrganizationDowngrade, { - plan: tierToPlan(billingPlan)?.name - }); - } catch (e) { - addNotification({ - type: 'error', - message: e.message - }); - trackError( - e, - isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade - ); - } - } else { - try { - const org = await sdk.forConsole.billing.updatePlan( - $organization.$id, - billingPlan, - paymentMethodId, - null - ); - - //Add coupon - if (couponData?.code) { - await sdk.forConsole.billing.addCredit(org.$id, couponData.code); - trackEvent(Submit.CreditRedeem); - } - - //Add budget - if (billingBudget) { - await sdk.forConsole.billing.updateBudget(org.$id, billingBudget, [75]); - } - - //Add collaborators - if (collaborators?.length) { - collaborators.forEach(async (collaborator) => { - await sdk.forConsole.teams.createMembership( - org.$id, - ['owner'], - collaborator, - undefined, - undefined, - `${$page.url.origin}/console/organization-${org.$id}` - ); - }); - } - - //Add tax ID - if (taxId) { - await sdk.forConsole.billing.updateTaxId(org.$id, taxId); - } - - await invalidate(Dependencies.ACCOUNT); - await invalidate(Dependencies.ORGANIZATION); - - await goto(`/console/organization-${org.$id}`); - if (isUpgrade) { - addNotification({ - type: 'success', - message: 'Your organization has been upgraded' - }); - } else { - addNotification({ - type: 'success', - isHtml: true, - message: ` ${$organization.name} will change to ${ tierToPlan(billingPlan).name } plan at the end of the current billing cycle.` - }); - } - trackEvent(isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade, { - plan: tierToPlan(billingPlan)?.name }); - } catch (e) { - addNotification({ - type: 'error', - message: e.message - }); - trackError( - e, - isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade - ); } + trackEvent(isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade, { + plan: tierToPlan(billingPlan)?.name + }); + } catch (e) { + addNotification({ + type: 'error', + message: e.message + }); + trackError(e, isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade); } } $: isUpgrade = billingPlan > $organization.billingPlan; - $: freePlan = $plansInfo.get(BillingPlan.STARTER); $: proPlan = $plansInfo.get(BillingPlan.PRO); $: if (billingPlan === BillingPlan.PRO) { loadPaymentMethods(); } + $: isButtonDisabled = + $organization.billingPlan === billingPlan + ? true + : isUpgrade + ? !paymentMethodId + : !feedbackDowngradeReason; @@ -266,12 +266,20 @@ Change plan - +

For more details on our plans, visit our .

+ {#if anyOrgFree && billingPlan === BillingPlan.PRO} + + You are limited to one Starter organization per account. Consider upgrading or + deleting . + + {/if}
    @@ -346,6 +354,22 @@ {/if} {/if} + {#if !isUpgrade && billingPlan === BillingPlan.STARTER} + + + + + {/if} {#if billingPlan !== BillingPlan.STARTER} @@ -365,7 +389,7 @@ diff --git a/src/routes/console/organization-[organization]/change-plan/+page.ts b/src/routes/console/organization-[organization]/change-plan/+page.ts new file mode 100644 index 000000000..cde580678 --- /dev/null +++ b/src/routes/console/organization-[organization]/change-plan/+page.ts @@ -0,0 +1,10 @@ +import { Dependencies } from '$lib/constants'; + +export const load = async ({ depends, parent }) => { + const { members } = await parent(); + depends(Dependencies.ORGANIZATION); + + return { + members + }; +}; From 6470cc014cd91e63b5f63824a5b15853cecd00dd Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 14 May 2024 11:40:06 +0200 Subject: [PATCH 5/7] fix: error --- .../change-plan/+page.svelte | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index ca73b4ae6..9ff13282a 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -30,12 +30,7 @@ import { type Coupon, type PaymentList } from '$lib/sdk/billing'; import { plansInfo, tierFree, tierPro, tierToPlan, type Tier } from '$lib/stores/billing'; import { addNotification } from '$lib/stores/notifications'; - import { - organization, - organizationList, - type Organization, - type OrganizationList - } from '$lib/stores/organization'; + import { organization, organizationList, type Organization } from '$lib/stores/organization'; import { sdk } from '$lib/stores/sdk'; import { user } from '$lib/stores/user'; import { VARS } from '$lib/system'; @@ -77,8 +72,6 @@ let feedbackDowngradeReason: string; let feedbackMessage: string; - let orgList: OrganizationList; - onMount(async () => { if ($page.url.searchParams.has('coupon')) { const coupon = $page.url.searchParams.get('coupon'); @@ -100,10 +93,6 @@ } } billingPlan = $organization.billingPlan; - - if (anyOrgFree && billingPlan === BillingPlan.PRO) { - orgList = await sdk.forConsole.billing.listOrganization(); - } }); async function loadPaymentMethods() { From e130543aa5f7a668ada0a38caedae0d321ea9baf Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 14 May 2024 11:44:21 +0200 Subject: [PATCH 6/7] fix: hide fields when current plan selected --- .../organization-[organization]/change-plan/+page.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/console/organization-[organization]/change-plan/+page.svelte b/src/routes/console/organization-[organization]/change-plan/+page.svelte index 9ff13282a..c14595e39 100644 --- a/src/routes/console/organization-[organization]/change-plan/+page.svelte +++ b/src/routes/console/organization-[organization]/change-plan/+page.svelte @@ -320,7 +320,7 @@
- {#if billingPlan === BillingPlan.PRO} + {#if billingPlan === BillingPlan.PRO && $organization.billingPlan !== BillingPlan.PRO} {/if} {/if} - {#if !isUpgrade && billingPlan === BillingPlan.STARTER} + {#if !isUpgrade && billingPlan === BillingPlan.STARTER && $organization.billingPlan !== BillingPlan.STARTER} - {#if billingPlan !== BillingPlan.STARTER} + {#if billingPlan !== BillingPlan.STARTER && $organization.billingPlan !== BillingPlan.PRO} Date: Tue, 14 May 2024 15:01:37 +0200 Subject: [PATCH 7/7] feat: add missing alerts --- .../components/billing/selectPaymentMethod.svelte | 13 ++++++++++++- .../change-plan/+page.svelte | 7 +++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lib/components/billing/selectPaymentMethod.svelte b/src/lib/components/billing/selectPaymentMethod.svelte index fd3ed238f..1e2db6a94 100644 --- a/src/lib/components/billing/selectPaymentMethod.svelte +++ b/src/lib/components/billing/selectPaymentMethod.svelte @@ -4,7 +4,7 @@ import { sdk } from '$lib/stores/sdk'; import { hasStripePublicKey, isCloud } from '$lib/system'; import { onMount } from 'svelte'; - import { Card, CreditCardBrandImage } from '..'; + import { Alert, Card, CreditCardBrandImage } from '..'; import PaymentModal from './paymentModal.svelte'; import { capitalize } from '$lib/helpers/string'; @@ -27,9 +27,20 @@ }); $: filteredMethods = methods?.paymentMethods?.filter((method) => !!method?.last4); + + $: selectedPaymentMethod = methods?.paymentMethods?.find((method) => method.$id === value); {#if filteredMethods?.length} + {#if selectedPaymentMethod?.country === 'in'} + + Indian credit or debit card-holders + To comply with RBI regulations in India, Appwrite will ask for verification to charge up + to $150 USD on your payment method. We will never charge more than the cost of your plan + and the resources you use, or your budget cap limit. For higher usage limits, please contact + us. + + {/if} pricing page.

{#if anyOrgFree && billingPlan === BillingPlan.PRO} - + You are limited to one Starter organization per account. Consider upgrading or deleting - +
{#if !couponData?.code}