import type { PaymentDto } from '@gruperly/shared'; /* Where Mercado Pago sends whoever paid a Checkout Pro link: the student app (without a student session it falls through to /access). */ export const CHECKOUT_BACK_PATH = '/student/payments'; export type PaymentRecord = { id: string; groupId: string; attendeeId: string; amount: { toString(): string } | number; currency: string; status: PaymentDto['status']; description: string | null; checkoutUrl: string | null; dueDate: Date; paidAt: Date | null; createdAt: Date; updatedAt: Date; group: { name: string; price: unknown }; attendee: { person: { fullName: string } }; }; export function toPaymentDto(record: PaymentRecord): PaymentDto { return { id: record.id, groupId: record.groupId, groupName: record.group.name, attendeeId: record.attendeeId, attendeeName: record.attendee.person.fullName, amount: Number(record.amount.toString()), currency: record.currency, status: record.status, description: record.description, checkoutUrl: record.checkoutUrl, dueDate: record.dueDate.toISOString(), paidAt: record.paidAt ? record.paidAt.toISOString() : null, createdAt: record.createdAt.toISOString(), updatedAt: record.updatedAt.toISOString(), }; }