diff --git a/app/api/crypto-sweep/route.ts b/app/api/crypto-sweep/route.ts index ead8226..305212d 100644 --- a/app/api/crypto-sweep/route.ts +++ b/app/api/crypto-sweep/route.ts @@ -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 });