-
Notifications
You must be signed in to change notification settings - Fork 805
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add plan, price, and subscription models
- Loading branch information
1 parent
a2248b5
commit 5d4a7a3
Showing
10 changed files
with
106 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { prisma } from '@/lib/prisma'; | ||
|
||
export const getAllPlans = async () => { | ||
const plans = await prisma.plan.findMany({}); | ||
return plans; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { prisma } from '@/lib/prisma'; | ||
|
||
export const getAllPrices = async () => { | ||
const prices = await prisma.stripePrice.findMany({}); | ||
const prices = await prisma.price.findMany({}); | ||
return prices; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { prisma } from '@/lib/prisma'; | ||
|
||
export const createStripeSubscription = async ( | ||
customerId: string, | ||
id: string, | ||
active: boolean, | ||
startDate: Date, | ||
endDate: Date, | ||
priceId: string | ||
) => { | ||
const subscription = await prisma.subscription.create({ | ||
data: { | ||
customerId, | ||
id, | ||
active, | ||
startDate, | ||
endDate, | ||
priceId, | ||
}, | ||
}); | ||
return subscription; | ||
}; | ||
|
||
export const deleteStripeSubscription = async (id: string) => { | ||
const subscription = await prisma.subscription.deleteMany({ | ||
where: { | ||
id, | ||
}, | ||
}); | ||
return subscription; | ||
}; | ||
|
||
export const updateStripeSubscription = async (id: string, data: any) => { | ||
const subscription = await prisma.subscription.updateMany({ | ||
where: { | ||
id, | ||
}, | ||
data, | ||
}); | ||
return subscription; | ||
}; | ||
|
||
export const getByCustomerId = async (customerId: string) => { | ||
const subscription = await prisma.subscription.findMany({ | ||
where: { | ||
customerId, | ||
}, | ||
}); | ||
return subscription; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters