Files
pagodera/lib/payment-cache.ts
T
Evandro Fonseca Junior 8271d1fa31 feat(thank-you-page): convert to client component with confetti and UI enhancements
- Changed from server to client component to enable interactive features like confetti animation
- Removed server-side translations and hardcoded Portuguese text for simplicity
- Added confetti effect on page load and improved success icon with animations
- Updated buttons and share functionality for better user experience
- This enhances the donation thank you page with celebratory elements and client-side interactivity
2025-10-26 22:12:43 -03:00

48 lines
1.1 KiB
TypeScript

// Cache simples em memória (Map) para armazenar status de pagamentos
// Em produção, trocar por Redis ou banco de dados
interface PaymentStatus {
paid: boolean;
paidAt?: string;
amount: number;
anonymous: boolean;
customer?: any;
}
const paymentCache = new Map<string, PaymentStatus>();
export function markAsPaid(
pixId: string,
data: {
paidAt: string;
amount: number;
anonymous: boolean;
customer?: any;
}
) {
paymentCache.set(pixId, {
paid: true,
paidAt: data.paidAt,
amount: data.amount,
anonymous: data.anonymous,
customer: data.customer,
});
console.log(`✅ Pagamento marcado como pago no cache: ${pixId}`);
// Limpar após 1 hora
setTimeout(() => {
paymentCache.delete(pixId);
console.log(`🗑️ Cache expirado para: ${pixId}`);
}, 3600000);
}
export function getPaymentStatus(pixId: string): PaymentStatus | undefined {
return paymentCache.get(pixId);
}
// Limpar cache expirado periodicamente (a cada 5 minutos)
setInterval(() => {
console.log(`📊 Cache atual: ${paymentCache.size} pagamentos armazenados`);
}, 300000);