feat: enhance AbacatePay donation system with updated docs and form fields

Updated ABACATEPAY_SETUP.md with comprehensive setup guide, including environment variables, API key instructions, webhook configuration, donation flow, and field details for better integration clarity. Added required fields (phone, CPF/CNPJ) to the donation form in app/[locale]/apoiar/page.tsx to collect essential donor information and improve compliance. This ensures smoother setup and more robust donation processing.
This commit is contained in:
Evandro Fonseca Junior committed 2025-10-26 21:16:59 -03:00
1 parent 00501e6699
commit ef521876eb
9 files changed
+922 -168

No files matched your search

+37 -13
View File
@@ -15,23 +15,47 @@ export async function POST(request: NextRequest) {
const event = JSON.parse(payload);
if (event.type === "billing.paid") {
// Processar doação confirmada
console.log("Donation confirmed:", event.data.id);
console.log("🔔 Webhook recebido:", JSON.stringify(event, null, 2));
// Aqui você pode:
// 1. Salvar no banco de dados
// 2. Enviar email de agradecimento
// 3. Atualizar estatísticas
// 4. Notificar a equipe
// Capturar todos os tipos de eventos de pagamento
const isPaidEvent =
event.type === "pix.paid" ||
event.type === "billing.paid" ||
event.type === "payment.paid" ||
event.data?.status === "PAID";
// Por enquanto, apenas log
console.log("Donation details:", {
id: event.data.id,
if (isPaidEvent) {
console.log("✅ Doação confirmada via webhook:", event.data.id);
// Log estruturado para futura persistência em banco de dados
const donationRecord = {
type: "donation_paid",
pixId: event.data.id,
amount: event.data.amount,
customer: event.data.customer,
paidAt: event.data.paidAt || new Date().toISOString(),
createdAt: new Date().toISOString(),
metadata: event.data.metadata,
paidAt: event.data.paidAt,
});
};
console.log("📝 Registro de pagamento:", donationRecord);
// TODO: Quando implementar banco de dados, salvar aqui:
// await db.donations.create(donationRecord);
// TODO: Quando implementar email, enviar aqui:
// if (event.data.customer?.email) {
// await sendThankYouEmail({
// to: event.data.customer.email,
// donorName: event.data.customer.name,
// amount: event.data.amount,
// });
// }
// TODO: Atualizar estatísticas
// await updateDonationStats(event.data.amount);
} else {
console.log("ℹ️ Evento de webhook (não é pagamento):", event.type);
}
return NextResponse.json({ success: true });