From 4def1d0579427084a6c5455ec0065e1ab6e30166 Mon Sep 17 00:00:00 2001 From: shemzz Date: Fri, 11 Oct 2024 13:22:42 +0100 Subject: [PATCH 1/3] remove checkoutSessionId from project --- .../app_diff/migrations/20231213174854_init/migration.sql.diff | 1 - opensaas-sh/app_diff/schema.prisma.diff | 1 - opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff | 1 - opensaas-sh/blog/src/content/docs/general/user-overview.md | 3 --- template/app/schema.prisma | 1 - template/app/src/server/scripts/dbSeeds.ts | 1 - 6 files changed, 8 deletions(-) diff --git a/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff b/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff index 461896d5..0749b825 100644 --- a/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff +++ b/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff @@ -15,7 +15,6 @@ + "emailVerificationSentAt" TIMESTAMP(3), + "passwordResetSentAt" TIMESTAMP(3), + "stripeId" TEXT, -+ "checkoutSessionId" TEXT, + "hasPaid" BOOLEAN NOT NULL DEFAULT false, + "subscriptionTier" TEXT, + "subscriptionStatus" TEXT, diff --git a/opensaas-sh/app_diff/schema.prisma.diff b/opensaas-sh/app_diff/schema.prisma.diff index 1e9959bd..6f5edec4 100644 --- a/opensaas-sh/app_diff/schema.prisma.diff +++ b/opensaas-sh/app_diff/schema.prisma.diff @@ -13,6 +13,5 @@ - paymentProcessorUserId String? @unique - lemonSqueezyCustomerPortalUrl String? // You can delete this if you're not using Lemon Squeezy as your payments processor. + stripeId String? @unique - checkoutSessionId String? subscriptionStatus String? // 'active', 'canceled', 'past_due', 'deleted' subscriptionPlan String? // 'hobby', 'pro' diff --git a/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff b/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff index 469fc950..8350787a 100644 --- a/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff +++ b/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff @@ -8,7 +8,6 @@ - paymentProcessorUserId: hasUserPaidOnStripe ? `cus_test_${faker.string.uuid()}` : null, + stripeId: hasUserPaidOnStripe ? `cus_test_${faker.string.uuid()}` : null, datePaid: hasUserPaidOnStripe ? faker.date.between({ from: createdAt, to: lastActiveTimestamp }) : null, - checkoutSessionId: hasUserPaidOnStripe ? `cs_test_${faker.string.uuid()}` : null, subscriptionPlan: subscriptionStatus ? faker.helpers.arrayElement(getSubscriptionPaymentPlanIds()) : null, + // For the demo app, we want to default isMockUser to true so that our admin dash only shows mock users + // and not real users signing up to test the app diff --git a/opensaas-sh/blog/src/content/docs/general/user-overview.md b/opensaas-sh/blog/src/content/docs/general/user-overview.md index b0aa27d0..b05df275 100644 --- a/opensaas-sh/blog/src/content/docs/general/user-overview.md +++ b/opensaas-sh/blog/src/content/docs/general/user-overview.md @@ -21,7 +21,6 @@ entity User {=psl lastActiveTimestamp DateTime @default(now()) isAdmin Boolean @default(false) stripeId String? - checkoutSessionId String? subscriptionPlan String? subscriptionStatus String? sendEmail Boolean @default(false) @@ -45,7 +44,6 @@ entity User {=psl id Int @id @default(autoincrement()) //... stripeId String? - checkoutSessionId String? subscriptionPlan String? subscriptionStatus String? datePaid DateTime? @@ -55,7 +53,6 @@ psl=} ``` - `stripeId`: The Stripe customer ID. This is created by Stripe on checkout and used to identify the customer. -- `checkoutSessionId`: The Stripe checkout session ID. This is created by Stripe on checkout and used to identify the checkout session. - `subscriptionPlan`: The subscription plan the user is on. This is set by the app and is used to determine what features the user has access to. By default, we have two plan: `hobby` and `pro`. - `subscriptionStatus`: The subscription status of the user. This is set by Stripe and is used to determine whether the user has access to the app or not. By default, we have four statuses: `active`, `past_due`, `canceled`, and `deleted`. - `credits` (optional): By default, a user is given 3 credits to trial your product before they have to pay. You can create a one-time purchase product in Stripe to allow users to purchase more credits if they run out. diff --git a/template/app/schema.prisma b/template/app/schema.prisma index 017fef24..c242febb 100644 --- a/template/app/schema.prisma +++ b/template/app/schema.prisma @@ -18,7 +18,6 @@ model User { paymentProcessorUserId String? @unique lemonSqueezyCustomerPortalUrl String? // You can delete this if you're not using Lemon Squeezy as your payments processor. - checkoutSessionId String? subscriptionStatus String? // 'active', 'canceled', 'past_due', 'deleted' subscriptionPlan String? // 'hobby', 'pro' sendNewsletter Boolean @default(false) diff --git a/template/app/src/server/scripts/dbSeeds.ts b/template/app/src/server/scripts/dbSeeds.ts index b411a844..c6f06f90 100644 --- a/template/app/src/server/scripts/dbSeeds.ts +++ b/template/app/src/server/scripts/dbSeeds.ts @@ -41,7 +41,6 @@ function generateMockUserData(): MockUserData { lemonSqueezyCustomerPortalUrl: null, paymentProcessorUserId: hasUserPaidOnStripe ? `cus_test_${faker.string.uuid()}` : null, datePaid: hasUserPaidOnStripe ? faker.date.between({ from: createdAt, to: lastActiveTimestamp }) : null, - checkoutSessionId: hasUserPaidOnStripe ? `cs_test_${faker.string.uuid()}` : null, subscriptionPlan: subscriptionStatus ? faker.helpers.arrayElement(getSubscriptionPaymentPlanIds()) : null, }; } From fd3e7e1fb64dc0f0211b06f533717e71d3cb0c98 Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:44:58 +0200 Subject: [PATCH 2/3] fix app_diff --- .../app_diff/migrations/20231213174854_init/migration.sql.diff | 1 + opensaas-sh/app_diff/schema.prisma.diff | 1 + opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff b/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff index 0749b825..461896d5 100644 --- a/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff +++ b/opensaas-sh/app_diff/migrations/20231213174854_init/migration.sql.diff @@ -15,6 +15,7 @@ + "emailVerificationSentAt" TIMESTAMP(3), + "passwordResetSentAt" TIMESTAMP(3), + "stripeId" TEXT, ++ "checkoutSessionId" TEXT, + "hasPaid" BOOLEAN NOT NULL DEFAULT false, + "subscriptionTier" TEXT, + "subscriptionStatus" TEXT, diff --git a/opensaas-sh/app_diff/schema.prisma.diff b/opensaas-sh/app_diff/schema.prisma.diff index 6f5edec4..b2892f77 100644 --- a/opensaas-sh/app_diff/schema.prisma.diff +++ b/opensaas-sh/app_diff/schema.prisma.diff @@ -15,3 +15,4 @@ + stripeId String? @unique subscriptionStatus String? // 'active', 'canceled', 'past_due', 'deleted' subscriptionPlan String? // 'hobby', 'pro' + sendNewsletter Boolean @default(false) diff --git a/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff b/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff index 8350787a..daf65ec7 100644 --- a/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff +++ b/opensaas-sh/app_diff/src/server/scripts/dbSeeds.ts.diff @@ -1,6 +1,6 @@ --- template/app/src/server/scripts/dbSeeds.ts +++ opensaas-sh/app/src/server/scripts/dbSeeds.ts -@@ -38,10 +38,12 @@ +@@ -38,9 +38,11 @@ sendNewsletter: false, credits, subscriptionStatus, From 4f042ec657068e336fcfa9b28a0419fa40309bbe Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:55:29 +0200 Subject: [PATCH 3/3] Update schema.prisma.diff --- opensaas-sh/app_diff/schema.prisma.diff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensaas-sh/app_diff/schema.prisma.diff b/opensaas-sh/app_diff/schema.prisma.diff index b2892f77..f56a673d 100644 --- a/opensaas-sh/app_diff/schema.prisma.diff +++ b/opensaas-sh/app_diff/schema.prisma.diff @@ -13,6 +13,6 @@ - paymentProcessorUserId String? @unique - lemonSqueezyCustomerPortalUrl String? // You can delete this if you're not using Lemon Squeezy as your payments processor. + stripeId String? @unique - subscriptionStatus String? // 'active', 'canceled', 'past_due', 'deleted' + subscriptionStatus String? // 'active', 'cancel_at_period_end', 'past_due', 'deleted' subscriptionPlan String? // 'hobby', 'pro' sendNewsletter Boolean @default(false)