diff --git a/webapps/console/components/Billing/BillingManager.tsx b/webapps/console/components/Billing/BillingManager.tsx index 0d51a1841..f13be1574 100644 --- a/webapps/console/components/Billing/BillingManager.tsx +++ b/webapps/console/components/Billing/BillingManager.tsx @@ -214,6 +214,16 @@ const CurrentSubscription: React.FC<{}> = () => { )} + {billing.settings?.futureSubscriptionDate && ( +
+ Your paid subscription starts on{" "} + {new Intl.DateTimeFormat("en-US", { + month: "long", + year: "numeric", + day: "numeric", + }).format(new Date(billing.settings?.futureSubscriptionDate))} +
+ )}
diff --git a/webapps/console/lib/schema/index.ts b/webapps/console/lib/schema/index.ts index e385243d2..56e08c578 100644 --- a/webapps/console/lib/schema/index.ts +++ b/webapps/console/lib/schema/index.ts @@ -36,6 +36,8 @@ export const BillingSettings = z.object({ destinationEvensPerMonth: z.number().default(200_000), expiresAt: z.string().optional(), renewAfterExpiration: z.boolean().default(false).optional(), + //if subscription starts some time in the future, for enterprise plans only + futureSubscriptionDate: z.string().optional(), }); export type BillingSettings = z.infer; diff --git a/webapps/ee-api/lib/stripe.ts b/webapps/ee-api/lib/stripe.ts index 844dc6fb2..bc03614e2 100644 --- a/webapps/ee-api/lib/stripe.ts +++ b/webapps/ee-api/lib/stripe.ts @@ -73,7 +73,22 @@ export async function getOrCreateCurrentSubscription( .log( `Custom billing is set for workspace ${workspaceId}: ${JSON.stringify(stripeOptions.customBilling, null, 2)}` ); + const startDate = new Date(stripeOptions.customBilling.start + "T00:00:00Z"); + getLog().atInfo().log(`Subscription start date for workspace ${workspaceId}: ${startDate.toISOString()}`); + if (startDate.getTime() > new Date().getTime()) { + getLog() + .atInfo() + .log(`Subscription start date for workspace ${workspaceId}: ${startDate.toISOString()} - future`); + return { + stripeCustomerId: stripeOptions.stripeCustomerId, + subscriptionStatus: { + //customBilling: true, + planId: "free", + futureSubscriptionDate: startDate, + }, + }; + } const startDay = startDate.getUTCDate(); const currentDay = new Date().getUTCDate(); const expiresAt = new Date();