feat: implement background payment sync worker and admin trigger UI

This commit is contained in:
mstfyldz
2026-03-13 05:29:17 +03:00
parent d7bd2afc29
commit 67d0c61adb
7 changed files with 306 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import { NextResponse } from 'next/server';
import { syncPendingPayments } from '@/lib/sync-worker';
export async function POST(request: Request) {
try {
// Authenticate admin (simple check for now, can be hardened)
// In a real app, check session or API key
const results = await syncPendingPayments();
return NextResponse.json({
success: true,
message: "Sync completed",
processedCount: results.length,
results: results
});
} catch (error: any) {
console.error('[Sync API Error]:', error.message);
return NextResponse.json({ success: false, error: error.message }, { status: 500 });
}
}