37 lines
966 B
TypeScript
37 lines
966 B
TypeScript
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(),
|
|
}
|
|
})
|