- Replace zpay with easy-pay payment provider (new lib/easy-pay/ module) - Add order history page for users (pay/orders) - Add GET /api/orders/my endpoint to list user's own orders - Add GET /api/users/[id] endpoint for sub2api user lookup - Add order status tracking module (lib/order/status.ts) - Update config to support easy-pay credentials (merchant ID, key, gateway) - Update PaymentForm and PaymentQRCode components for easy-pay flow - Update pay page and admin page with new order management UI - Update order service to support easy-pay, cancellation, and refund
26 lines
833 B
TypeScript
26 lines
833 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { verifyAdminToken, unauthorizedResponse } from '@/lib/admin-auth';
|
|
import { adminCancelOrder, OrderError } from '@/lib/order/service';
|
|
|
|
export async function POST(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ id: string }> },
|
|
) {
|
|
if (!verifyAdminToken(request)) return unauthorizedResponse();
|
|
|
|
try {
|
|
const { id } = await params;
|
|
await adminCancelOrder(id);
|
|
return NextResponse.json({ success: true });
|
|
} catch (error) {
|
|
if (error instanceof OrderError) {
|
|
return NextResponse.json(
|
|
{ error: error.message, code: error.code },
|
|
{ status: error.statusCode },
|
|
);
|
|
}
|
|
console.error('Admin cancel order error:', error);
|
|
return NextResponse.json({ error: '取消订单失败' }, { status: 500 });
|
|
}
|
|
}
|