- 前端: React+Vite 首页/AI专区, 算法库(MARD色板/量化/背景去除), API对接 - 后端: Express+SQLite, 兑换码/订单/支付/chibi生成, 风控+云端同步 - CI/CD: GitHub Actions + Docker + nginx 配置 - 文档: PRD/DESIGN/LAUNCH/ROADMAP/E2E/竞品对照等 15 份 - 工程: 任务看板(taskboard) + 健康巡检(agent-health) + Git流程(gitflow)
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import type { PaymentProvider, PaymentRequest, PaymentResult } from "./types.js";
|
|
|
|
/**
|
|
* MockPaymentProvider — for local development WITHOUT real merchant accounts.
|
|
*
|
|
* - createPayment: returns a fake payment URL with the orderNo and amount embedded.
|
|
* - verifyCallback: always returns success (any callback is treated as valid).
|
|
*
|
|
* The fake URL is designed so the frontend can simulate the full payment flow:
|
|
* the user "visits" the URL, then the frontend calls the mock callback endpoint.
|
|
*/
|
|
export class MockPaymentProvider implements PaymentProvider {
|
|
createPayment(request: PaymentRequest): PaymentResult {
|
|
const { orderNo, amountCents, method } = request;
|
|
|
|
// Build a realistic-looking mock payment URL
|
|
const url = `https://pay.mock.local/pay?orderNo=${encodeURIComponent(orderNo)}&amount=${amountCents}&method=${method}`;
|
|
|
|
const result: PaymentResult = { url };
|
|
|
|
// Include a fake QR code URL for WeChat to make the frontend flow more realistic
|
|
if (method === "wechat") {
|
|
result.qrCode = `https://pay.mock.local/qr?orderNo=${encodeURIComponent(orderNo)}`;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
verifyCallback(
|
|
params: Record<string, string | string[] | undefined>,
|
|
): { orderNo: string; transactionId: string } | null {
|
|
const orderNo = typeof params["orderNo"] === "string" ? params["orderNo"] : undefined;
|
|
if (!orderNo) {
|
|
return null;
|
|
}
|
|
// Always succeed in mock mode
|
|
return {
|
|
orderNo,
|
|
transactionId: `MOCK${Date.now()}`,
|
|
};
|
|
}
|
|
} |