Prisma and Stripe subscription authorisation

I am working on a side project that has different tiers of subscriptions. I'm using Stripe and have set up everything to sync up subscriptions, prices and products from Stripe with my database. Now depending on the tier of the subscription users have certain restrictions. For example (completely random), imagine restricting people to X blog posts, Y tweets per day or access to feature Z . Would you guys put this information on the metadata of the Stripe product like
{"blogLimit": 5, "tweetDailyLimit": 10, "featureYEnabled": true}
{"blogLimit": 5, "tweetDailyLimit": 10, "featureYEnabled": true}
or create a new table in your database like
model ProductConfiguration {
id String @id @default(cuid())
blogLimit Int
tweetDailyLimit Int
featureYEnabled Boolean

product Product @relation(fields: [productId], references: [id])
productId String @unique //
}
model ProductConfiguration {
id String @id @default(cuid())
blogLimit Int
tweetDailyLimit Int
featureYEnabled Boolean

product Product @relation(fields: [productId], references: [id])
productId String @unique //
}
The benefit to the metadata is you can directly edit it from Stripe, while the benefit of the table is that you actually know what it contains. Thoughts? How do you guys handle this stuff?
1 Reply
Leonidas
Leonidas3y ago
I would create a separate table for this permissions - which is related to a user and thereby to the stripe subscription Since permissions are a own responsibility, they should be stored sepeerate - since maybe you will change your payment provider, add more or want to add a few users who do not have to pay In all these scenarios a more well defined responsibility and boundary between these „data slices“ is benetifial in my opinion
Want results from more Discord servers?
Add your server