/** * 支付验证接口 * 开发: 卡若 * 技术支持: 存客宝 */ import { type NextRequest, NextResponse } from "next/server" export async function POST(request: NextRequest) { try { const body = await request.json() const { orderId, paymentMethod, transactionId } = body if (!orderId) { return NextResponse.json({ code: 400, message: "缺少订单号" }, { status: 400 }) } // In production, verify with payment gateway API // For now, simulate verification console.log("[Karuo] Verifying payment:", { orderId, paymentMethod, transactionId }) // Simulate verification delay await new Promise((resolve) => setTimeout(resolve, 500)) // Mock verification result (95% success rate) const isVerified = Math.random() > 0.05 if (isVerified) { return NextResponse.json({ code: 0, message: "支付验证成功", data: { orderId, status: "completed", verifiedAt: new Date().toISOString(), }, }) } else { return NextResponse.json({ code: 1, message: "支付未完成,请稍后再试", data: { orderId, status: "pending", }, }) } } catch (error) { console.error("[Karuo] Verify payment error:", error) return NextResponse.json({ code: 500, message: "服务器错误" }, { status: 500 }) } }