feat: implement background payment sync worker and admin trigger UI
This commit is contained in:
22
app/api/admin/sync-payments/route.ts
Normal file
22
app/api/admin/sync-payments/route.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user