From 5a80cfbbb34b2c58babde2d307835016baecdd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Jedlicska?= Date: Thu, 17 Oct 2024 06:54:18 +0200 Subject: [PATCH] feat(gatekeeper): add productId to the subscription domain --- .../modules/gatekeeper/domain/billing.ts | 27 ++++++++++++++++++- .../gatekeeper/domain/workspacePricing.ts | 1 - 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/server/modules/gatekeeper/domain/billing.ts b/packages/server/modules/gatekeeper/domain/billing.ts index e40500d8a..a58683889 100644 --- a/packages/server/modules/gatekeeper/domain/billing.ts +++ b/packages/server/modules/gatekeeper/domain/billing.ts @@ -74,6 +74,14 @@ export type GetCheckoutSession = (args: { sessionId: string }) => Promise +export type DeleteCheckoutSession = (args: { + checkoutSessionId: string +}) => Promise + +export type GetWorkspaceCheckoutSession = (args: { + workspaceId: string +}) => Promise + export type UpdateCheckoutSessionStatus = (args: { sessionId: string paymentStatus: SessionPaymentStatus @@ -91,6 +99,7 @@ export type CreateCheckoutSession = (args: { export type WorkspaceSubscription = { workspaceId: string createdAt: Date + currentBillingCycleEnd: Date billingInterval: WorkspacePlanBillingIntervals subscriptionData: SubscriptionData } @@ -100,7 +109,9 @@ export type SubscriptionData = { subscriptionId: string customerId: string products: { - workspacePlan: WorkspacePricingPlans + // we're going to use the productId to match with our + productId: string + subscriptionItemId: string priceId: string quantity: number }[] @@ -109,3 +120,17 @@ export type SubscriptionData = { export type SaveWorkspaceSubscription = (args: { workspaceSubscription: WorkspaceSubscription }) => Promise + +export type GetSubscriptionData = (args: { + subscriptionId: string +}) => Promise + +export type GetWorkspacePlanPrice = (args: { + workspacePlan: WorkspacePricingPlans + billingInterval: WorkspacePlanBillingIntervals +}) => string + +export type ReconcileWorkspaceSubscription = (args: { + workspaceSubscription: WorkspaceSubscription + applyProrotation: boolean +}) => Promise diff --git a/packages/server/modules/gatekeeper/domain/workspacePricing.ts b/packages/server/modules/gatekeeper/domain/workspacePricing.ts index d9c9e5230..e552fe102 100644 --- a/packages/server/modules/gatekeeper/domain/workspacePricing.ts +++ b/packages/server/modules/gatekeeper/domain/workspacePricing.ts @@ -136,7 +136,6 @@ const paidWorkspacePlanFeatures: Record< team, pro, business - // unlimited } export const unpaidWorkspacePlanFeatures: Record<