This commit is contained in:
eric
2026-03-11 23:10:18 -05:00
parent 26f1de5fb6
commit efe816915d
3 changed files with 9 additions and 6 deletions

View File

@@ -11,13 +11,15 @@ export async function GET(request: NextRequest) {
return NextResponse.json({ ok: false, error: "未配置 PAYMENT_API_URL" }, { status: 500 });
}
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 25000);
const res = await fetch(
`${config.apiUrl}/zpay_order_status?out_trade_no=${encodeURIComponent(orderId)}`,
{ cache: "no-store" }
);
{ cache: "no-store", signal: controller.signal }
).finally(() => clearTimeout(timeout));
const data = await res.json().catch(() => ({}));
return NextResponse.json({ ok: true, paid: !!data?.paid });
} catch (e) {
return NextResponse.json({ ok: false, paid: false, error: String(e) }, { status: 500 });
} catch {
return NextResponse.json({ ok: true, paid: false });
}
}