Problem with licenses creating for shop

hello anyone that is able to help me i am trying to make a shop with license so as example a month and lifetime but when i claim(buy) it its bought for everyone but i want that i am able to sell unlimited and that when someones redeems the license its get connected to his account (discord/email) can someone help i just started>
No description
27 Replies
Myjski
MyjskiOP2mo ago
for the code tag me just started so idk exactly how to do everything
mukomo
mukomo2mo ago
you need to tie the purchase to a specific account
Myjski
MyjskiOP2mo ago
how can i do it can u help me or something
mukomo
mukomo2mo ago
i don't want to get too into helping because i have my own demands on time but i can give ideas on how to help
Myjski
MyjskiOP2mo ago
sure tell me
mukomo
mukomo2mo ago
basically in whatever your database setup is, you need to link a user account and the license purchased by that account. then when you're on your website, you check the currently logged in user against that table in the database
Myjski
MyjskiOP2mo ago
could u take a look at my schema.prisma what the best options are to use for like anticheat licenses and stuff
Myjski
MyjskiOP2mo ago
i want to make it so u can just buy it and the license gets sent to your email and then when it gets redeemed it gets connected to that account
mukomo
mukomo2mo ago
you'll need a License model in your schema then
Myjski
MyjskiOP2mo ago
could u maybe fix that cause i dont understand it xD tried mutiple things
mukomo
mukomo2mo ago
how are you currently using your Item model?
Myjski
MyjskiOP2mo ago
what u mean?
Myjski
MyjskiOP2mo ago
this?
No description
mukomo
mukomo2mo ago
your Item model is supposed to show your purchased license, right?
Myjski
MyjskiOP2mo ago
im a beginner so i try my best sorry like this? model License { id String @id @default(cuid()) licenseKey String @unique itemId String item Item @relation(fields: [itemId], references: [id]) userId String? user User? @relation(fields: [userId], references: [id]) claimed Boolean @default(false) claimedAt DateTime? activated Boolean @default(false) activatedAt DateTime? } ----------------------- AND --------------------- model Item { id String @id @default(cuid()) name String type String // e.g. "1month" | "lifetime" licenses License[]
} like this? @mukomo
mukomo
mukomo2mo ago
No, that's incorrect
Myjski
MyjskiOP2mo ago
could u help out
mukomo
mukomo2mo ago
It'll be a bit. I'm out of the house
Myjski
MyjskiOP2mo ago
ah shit can u try? what about now?
model Item {
id String @id @default(cuid())
name String
type String // e.g. "1month" | "lifetime"
licenses License[]
}

model License {
id String @id @default(cuid())
licenseKey String @unique
itemId String
item Item @relation(fields: [itemId], references: [id])

userId String?
user User? @relation(fields: [userId], references: [id])

claimed Boolean @default(false)
claimedAt DateTime?
activated Boolean @default(false)
activatedAt DateTime?
}
model Item {
id String @id @default(cuid())
name String
type String // e.g. "1month" | "lifetime"
licenses License[]
}

model License {
id String @id @default(cuid())
licenseKey String @unique
itemId String
item Item @relation(fields: [itemId], references: [id])

userId String?
user User? @relation(fields: [userId], references: [id])

claimed Boolean @default(false)
claimedAt DateTime?
activated Boolean @default(false)
activatedAt DateTime?
}
@mukomo able to help now
mukomo
mukomo2mo ago
alright, let's try this again You want to be able to show a user on your website if they've purchased a license In your database, do you have that information?
Myjski
MyjskiOP2mo ago
i did try some more and it is kinda working rn but testing some more now people can buy infinite licenses and when redeemed it gets activated and put on that users userid
Myjski
MyjskiOP2mo ago
got to here
No description
Myjski
MyjskiOP2mo ago
@mukomo is it possible to get the basic layout header removed in a different page
No description
mukomo
mukomo2mo ago
yes i don't know exactly how but i know it's possible
Myjski
MyjskiOP2mo ago
could u maybe help find it worked got it fixed
Myjski
MyjskiOP2mo ago
how can i fix that the stuff that is here on the first screen goes to the output from a different file
Myjski
MyjskiOP2mo ago
these are both files @mukomo

Did you find this page helpful?