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,30 @@
import { NextRequest, NextResponse } from 'next/server';
import { db } from '@/lib/db';
export async function POST(
req: NextRequest,
context: { params: Promise<{ id: string }> }
) {
try {
const { id } = await context.params;
const { network, token } = await req.json();
if (!id || !network || !token) {
return NextResponse.json({ error: 'Missing required fields' }, { status: 400 });
}
// Update metadata with intent
// Using jsonb_set to merge or set properly
await db.query(`
UPDATE transactions
SET metadata = metadata || jsonb_build_object('intent_network', $2::text, 'intent_token', $3::text)
WHERE id = $1
`, [id, network, token]);
return NextResponse.json({ success: true });
} catch (error: any) {
console.error("[Intent Update Error]:", error.message);
return NextResponse.json({ error: error.message }, { status: 500 });
}
}