diff --git a/src/lib/stores/campaigns.ts b/src/lib/stores/campaigns.ts index b74975962..46e25d80b 100644 --- a/src/lib/stores/campaigns.ts +++ b/src/lib/stores/campaigns.ts @@ -1,11 +1,14 @@ //campaign welcome and startup +import { BillingPlan } from '$lib/constants'; + export type CampaignData = { title: string; description: string; template: 'card' | 'review'; data?: Record; onlyNewOrgs?: boolean; + plan?: BillingPlan; footer?: boolean; }; @@ -22,7 +25,7 @@ campaigns template: 'card', title: 'Welcome to the Startups program!', description: - "We're excited to have you on board. Add the coupon code to your Appwrite Pro account to join." + "We're excited to have you on board. Add the coupon code to your Appwrite Scale account to join." }) .set('RenderATL2024', { template: 'card', @@ -52,10 +55,11 @@ campaigns template: 'review', title: 'Welcome to the Startups program', description: - "We're excited to have you on board. Add your credit code to your Appwrite Pro account to join.", + "We're excited to have you on board. Add your credit code to your Appwrite Scale account to join.", onlyNewOrgs: true, + plan: BillingPlan.SCALE, data: { - cta: 'Get everything out of Cloud with Pro', + cta: 'Get everything out of Cloud with Scale', claimed: 'Your credits will be valid for 12 months.', unclaimed: 'Apply your code to join the Startups program.', reviews: [ diff --git a/src/routes/console/apply-credit/+page.svelte b/src/routes/console/apply-credit/+page.svelte index 45489e763..231c8820f 100644 --- a/src/routes/console/apply-credit/+page.svelte +++ b/src/routes/console/apply-credit/+page.svelte @@ -70,6 +70,7 @@ let coupon: string; let couponData = data?.couponData; let campaign = campaigns.get(data?.couponData?.campaign ?? data?.campaign); + let billingPlan = BillingPlan.PRO; onMount(async () => { await loadPaymentMethods(); @@ -80,6 +81,9 @@ selectedOrgId = $page.url.searchParams.get('org'); canSelectOrg = false; } + if (campaign?.plan) { + billingPlan = campaign.plan; + } }); async function loadPaymentMethods() { @@ -101,15 +105,15 @@ org = await sdk.forConsole.billing.createOrganization( newOrgId, name, - BillingPlan.PRO, + billingPlan, paymentMethodId ); } // Upgrade existing org - else if (selectedOrg?.billingPlan !== BillingPlan.PRO) { + else if (selectedOrg?.billingPlan === BillingPlan.FREE) { org = await sdk.forConsole.billing.updatePlan( selectedOrg.$id, - BillingPlan.PRO, + billingPlan, paymentMethodId, null );