Update soul-content project
This commit is contained in:
20
app/api/payment/notify/[gateway]/route.js
Normal file
20
app/api/payment/notify/[gateway]/route.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Order } from '../../../../models/Order';
|
||||
import { connectDB } from '../../../../lib/db';
|
||||
|
||||
export async function POST(req, { params }) {
|
||||
await connectDB();
|
||||
const { gateway } = await params;
|
||||
const data = await req.json();
|
||||
// 根据gateway处理通知并更新订单状态
|
||||
// 这是一个简化版本,实际需要验证签名和处理不同gateway的逻辑
|
||||
const orderId = data.out_trade_no || data.order_id || data.metadata?.order_id;
|
||||
|
||||
if (orderId) {
|
||||
const order = await Order.findById(orderId);
|
||||
if (order) {
|
||||
order.status = 'paid';
|
||||
await order.save();
|
||||
}
|
||||
}
|
||||
return Response.json({ success: true });
|
||||
}
|
||||
Reference in New Issue
Block a user