feat: migrate payment provider to easy-pay, add order history and refund support
- 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
This commit is contained in:
32
src/app/api/easy-pay/notify/route.ts
Normal file
32
src/app/api/easy-pay/notify/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { NextRequest } from 'next/server';
|
||||
import { handlePaymentNotify } from '@/lib/order/service';
|
||||
import type { EasyPayNotifyParams } from '@/lib/easy-pay/types';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const searchParams = request.nextUrl.searchParams;
|
||||
|
||||
const params: EasyPayNotifyParams = {
|
||||
pid: searchParams.get('pid') || '',
|
||||
name: searchParams.get('name') || '',
|
||||
money: searchParams.get('money') || '',
|
||||
out_trade_no: searchParams.get('out_trade_no') || '',
|
||||
trade_no: searchParams.get('trade_no') || '',
|
||||
param: searchParams.get('param') || '',
|
||||
trade_status: searchParams.get('trade_status') || '',
|
||||
type: searchParams.get('type') || '',
|
||||
sign: searchParams.get('sign') || '',
|
||||
sign_type: searchParams.get('sign_type') || '',
|
||||
};
|
||||
|
||||
const success = await handlePaymentNotify(params);
|
||||
return new Response(success ? 'success' : 'fail', {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('EasyPay notify error:', error);
|
||||
return new Response('fail', {
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user