fix: improve transaction lookup by supporting internal UUID in sweep API

This commit is contained in:
mstfyldz
2026-03-13 02:37:37 +03:00
parent 53461ec478
commit 7c9fa48d0b

View File

@@ -16,8 +16,9 @@ export async function POST(request: Request) {
console.log(`[API] Processing sweep for TX: ${txId} on ${selectedNetwork} with ${selectedToken}`);
// 1. Fetch the transaction from DB to get the temporary wallet private key
const result = await db.query('SELECT * FROM transactions WHERE stripe_pi_id = $1', [txId]);
// 1. Fetch the transaction from DB
// Search by either the internal UUID (id) or the provider ID (stripe_pi_id)
const result = await db.query('SELECT * FROM transactions WHERE id::text = $1 OR stripe_pi_id = $1', [txId]);
if (result.rows.length === 0) {
return NextResponse.json({ success: false, error: "Transaction not found" }, { status: 404 });