Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bootstrap stripe webhook #59

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"next": "^14.1.3",
"next-auth": "^4.24.6",
"nodemailer": "^6.9.13",
"pino": "^9.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-email": "2.1.1",
Expand Down
2 changes: 2 additions & 0 deletions prisma/migrations/20240426110344_add_new_status/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "MembershipStatus" ADD VALUE 'WAITING';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use pending ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to think about it... I am not sure also it is the right name, but it is something like, when you create a membership it isn't paid yet. So, I think a different status just to differentiate from who's paid and its waiting for approval and other users that they didn't have finished their payment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid of having orphans member in these scenario. It could be helpful to have a column per member to identify the payment status as it could be unrelated from the member status as it is a consequence (especially in a renewal case).

To me the waiting status is an over head

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have lastPaymentAt which ensures the subscription has been successfully paid... I don't know what can be better when we operate with those users.

23 changes: 12 additions & 11 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ model Session {
}

model User {
id String @id @default(cuid())
name String?
role UserRole @default(member)
email String? @unique
emailVerified DateTime?
image String?
stripeCustomerId String?
accounts Account[]
sessions Session[]
memberships Membership[]
id String @id @default(cuid())
name String?
role UserRole @default(member)
email String? @unique
emailVerified DateTime?
image String?
stripeCustomerId String?
accounts Account[]
sessions Session[]
memberships Membership[]
}

enum UserRole{
enum UserRole {
member
admin
}
Expand All @@ -88,6 +88,7 @@ model VerificationToken {

enum MembershipStatus {
PENDING
WAITING
ACTIVE
REJECTED
UNSUBSCRIBED
Expand Down
Loading
Loading