This commit is contained in:
eric
2026-03-08 03:40:53 -05:00
parent f589b71b19
commit 51eeea3be3
8 changed files with 747 additions and 138 deletions

View File

@@ -0,0 +1,22 @@
import { NextRequest, NextResponse } from "next/server";
import { PAYMENT_API_URL } from "../../../lib/env";
export async function GET(request: NextRequest) {
const orderId = request.nextUrl.searchParams.get("order_id");
if (!orderId) {
return NextResponse.json({ ok: false, error: "缺少 order_id" }, { status: 400 });
}
if (!PAYMENT_API_URL) {
return NextResponse.json({ ok: false, error: "未配置 PAYMENT_API_URL" }, { status: 500 });
}
try {
const res = await fetch(
`${PAYMENT_API_URL}/zpay_order_status?out_trade_no=${encodeURIComponent(orderId)}`,
{ cache: "no-store" }
);
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 });
}
}