feat: implement Stripe checkout integration and add related API endpoints
This commit is contained in:
36
server/api/transactions.post.ts
Normal file
36
server/api/transactions.post.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody<{
|
||||
stripeSessionId: string
|
||||
designId: string
|
||||
templateId?: string
|
||||
amount: number
|
||||
currency: string
|
||||
customerEmail?: string
|
||||
assets?: {
|
||||
previewUrl?: string
|
||||
productionUrl?: string
|
||||
}
|
||||
}>(event)
|
||||
|
||||
if (!body?.stripeSessionId || !body?.designId) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Missing required fields' })
|
||||
}
|
||||
|
||||
// TODO: Persist the transaction to your database of choice.
|
||||
// Example shape:
|
||||
// await db.transaction.create({
|
||||
// stripeSessionId: body.stripeSessionId,
|
||||
// designId: body.designId,
|
||||
// templateId: body.templateId,
|
||||
// amount: body.amount,
|
||||
// currency: body.currency,
|
||||
// customerEmail: body.customerEmail,
|
||||
// previewUrl: body.assets?.previewUrl,
|
||||
// productionUrl: body.assets?.productionUrl,
|
||||
// })
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
receivedAt: new Date().toISOString(),
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user