| 4 | const prisma = new PrismaClient(); |
| 5 | |
| 6 | export const getPaymentListByEmail = async (email: string): Promise<Payment[]> => { |
| 7 | const payments = await prisma.payment.findMany({ |
| 8 | where: { email: email }, |
| 9 | orderBy: { createdAt: "desc" }, |
| 10 | }); |
| 11 | |
| 12 | const result: Payment[] = []; |
| 13 | for (const payment of payments) { |
| 14 | result.push({ |
| 15 | id: payment.id, |
| 16 | email: payment.email, |
| 17 | createdAt: payment.createdAt.getTime(), |
| 18 | amount: payment.amount, |
| 19 | currency: payment.currency, |
| 20 | receipt: payment.receipt, |
| 21 | description: payment.description, |
| 22 | }); |
| 23 | } |
| 24 | return result; |
| 25 | }; |