erio
eafb7e49fa
feat: 渠道展示、订阅套餐、系统配置全功能
...
- 新增 Channel / SubscriptionPlan / SystemConfig 三个数据模型
- Order 模型扩展支持订阅订单(order_type, plan_id, subscription_group_id)
- Sub2API client 新增分组查询、订阅分配/续期、用户订阅查询
- 订单服务支持订阅履约流程(CAS 锁 + 分组消失安全处理)
- 管理后台:渠道管理、订阅套餐管理、系统配置、Sub2API 分组同步
- 用户页面:双 Tab UI(按量付费/包月订阅)、渠道卡片、充值弹窗、订阅确认
- PaymentForm 支持 fixedAmount 固定金额模式
- 订单状态 API 返回 failedReason 用于订阅异常展示
- 数据库迁移脚本
2026-03-13 19:06:25 +08:00
erio
9f621713c3
style: 统一代码格式 (prettier)
2026-03-10 18:20:36 +08:00
erio
1cb82d8fd7
fix: 消除 buildOrderStatusUrl 重复定义,修复轮询回调引用稳定性
...
- 将 buildOrderStatusUrl 提取到 status-url.ts(客户端安全模块),
删除 OrderStatus/PaymentQRCode/result 三处重复定义
- OrderStatus.tsx 轮询 effect 使用 useRef 保存 onStateChange,
避免非 memoized 回调导致定时器不断重建
- result/page.tsx 增加 accessToken 最小长度校验,
避免无效参数触发无意义的 API 请求
2026-03-10 14:31:26 +08:00
daguimu
8b10bc3bd5
fix: harden alipay direct pay flow
2026-03-10 11:52:37 +08:00
erio
2492031e13
feat: 全站多语言支持 (i18n),lang=en 显示英文,其余默认中文
...
新增 src/lib/locale.ts 作为统一多语言入口,覆盖前台支付链路、
管理后台、API/服务层错误文案,共 35 个文件。URL 参数 lang 全链路透传,
包括 Stripe return_url、页面跳转、layout html lang 属性等。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-09 18:33:57 +08:00
erio
8a465ae625
feat: 支付结果页增加 5 秒倒计时自动返回和手动返回按钮
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-07 16:55:49 +08:00
erio
698df1ee47
Merge branch 'worktree-agent-afaec22d'
2026-03-07 04:16:38 +08:00
erio
d43b04cb5c
fix: 前端暗色模式补全、Unicode 可读化、UI 优化 12 项
...
- PaymentQRCode 13 处 Unicode 转义替换为可读中文
- RefundDialog 完整暗色模式 + Escape 键关闭
- PayResult 页面添加暗色模式支持
- OrderStatus 使用 dark prop 调整样式
- PaymentForm 选中态暗色对比度修复
- OrderDetail 英文标签改中文 + Escape 键
- Pay 页面错误提示暗色适配
- 倒计时最后 60 秒脉动提醒
- 全局 CSS 添加中文字体栈
- MobileOrderList HTML 实体替换
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-07 04:16:01 +08:00
erio
ac0772b0f4
fix: API 路由安全加固与架构优化 — 认证、错误处理、Registry 统一
...
- /api/user 添加 token 认证,防止用户枚举
- Admin token 支持 Authorization header
- /api/orders/my 区分认证失败和服务端错误
- Admin orders userId/date 参数校验
- Decimal 字段统一 Number() 转换
- 抽取 handleApiError/extractHeaders 工具函数
- Webhook 路由改用 Registry 获取 Provider
- PaymentRegistry lazy init 自动初始化
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-07 04:15:54 +08:00
erio
a5e07edda6
fix: PC 端易支付优先显示二维码;订单页移除 user_id 依赖改用 token
...
- PaymentQRCode: PC 端有 qrCode 时不跳转,优先展示二维码
- /pay/orders: 移除 user_id 参数,统一通过 token 认证
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-07 01:59:43 +08:00
erio
387bc96fc9
feat: 创建订单必须通过 token 认证,移除 user_id 参数
...
- POST /api/orders 改为通过 token 解析用户身份,移除 user_id
- 前端不再从 URL 读取 user_id,完全依赖 token
- 前端提交前检查 pending 订单数量,超过 3 个禁止提交并提示
- 后端 createOrder 保留 MAX_PENDING_ORDERS=3 的服务端校验
- PaymentForm 增加 pendingBlocked 状态提示和按钮禁用
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-06 23:05:12 +08:00
erio
7cab333213
merge: 合并 wxpay_direct 微信支付直连分支
...
解决冲突:保留 main 的常量化/provider 字段/ENABLED_PAYMENT_TYPES 移除,
合并 worktree 的微信支付直连实现、notifyUrl/returnUrl 传递、签名验证优化。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-06 19:00:16 +08:00
erio
d46793f072
feat: 支付宝直连 H5 端使用 wap.pay 唤起支付宝 APP
...
前端传递 is_mobile 参数,AlipayProvider 根据设备类型选择:
- PC: alipay.trade.page.pay (FAST_INSTANT_TRADE_PAY)
- H5: alipay.trade.wap.pay (QUICK_WAP_WAY)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-06 18:04:11 +08:00
erio
254ead1908
refactor: 常量化订单状态 + 支付渠道/提供商分离显示 + H5自动跳转
...
- 新增 src/lib/constants.ts,集中管理 ORDER_STATUS / PAYMENT_TYPE / PAYMENT_PREFIX 等常量
- 后端 service/status/timeout/limits 全量替换魔法字符串为 ORDER_STATUS.*
- PaymentTypeMeta 新增 provider 字段,分离 sublabel(选择器展示)与 provider(提供商名称)
- getPaymentDisplayInfo() 返回 { channel, provider } 用于用户端/管理端展示
- 支持通过 PAYMENT_SUBLABEL_* 环境变量覆盖默认 sublabel
- PaymentQRCode: H5 支付自动跳转(含易支付微信 weixin:// scheme 兜底)
- 订单列表/详情页:显示可读的渠道名+提供商,不再暴露内部标识符
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-06 17:34:42 +08:00
erio
3829d0e52e
refactor: 将支付类型硬编码抽取到 pay-utils 统一管理
...
- PaymentTypeMeta 新增 iconSrc、chartBar、buttonClass 字段
- 新增工具函数: getPaymentMeta、getPaymentIconSrc、
getPaymentChannelLabel、isStripeType、isRedirectPayment 等
- PaymentQRCode: 用 meta/工具函数替换散落的颜色和类型判断
- PaymentForm: 提交按钮颜色改用 meta.buttonClass
- PaymentMethodChart: 删除重复的 TYPE_CONFIG,改用 getPaymentMeta
- stripe-popup: 按钮颜色改用 meta.buttonClass
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-06 16:46:36 +08:00
erio
f53aa9e14c
feat: 支持官方支付宝与易支付支付宝同时展示
...
- PaymentType 改为 string 类型,支持复合 key(如 alipay_direct)
- 官方支付宝注册为 alipay_direct,易支付保持 alipay/wxpay
- 前端按 PAYMENT_TYPE_META 展示标签区分(官方直连/易支付)
- 管理后台显示统一改为 getPaymentTypeLabel 通用映射
- 修复 admin/OrderTable 中 wechat 拼写错误
2026-03-06 15:33:22 +08:00
erio
b0f1daf469
fix: 修复微信支付 Native/H5 判断逻辑,改为前端设备检测驱动
...
- 修复 clientIp 始终存在导致永远走 H5 的 bug,改用 isMobile 判断
- 前端通过 detectDeviceIsMobile() 传 is_mobile 给后端
- ENABLED_PAYMENT_TYPES 默认改为空,必须显式配置才启用
- 补充 .env.example 配置说明
2026-03-06 14:04:51 +08:00
erio
0a35ba9002
style: 全量 prettier 格式化
2026-03-05 23:10:44 +08:00
erio
ab961e669a
fix: 修复 lint errors(hooks 条件调用、未转义引号、effect 内 setState)
2026-03-05 23:08:48 +08:00
erio
448d36fe2b
feat: 移动端 H5 支付跳转 + 改进移动端检测
...
- PaymentQRCode: 移动端有 payUrl 时直接跳转支付,iframe 中新窗口打开
- detectDeviceIsMobile: 优先使用 navigator.userAgentData.mobile API
2026-03-05 16:21:12 +08:00
erio
f96f89b7bb
fix: 移除 body 硬编码背景色,修复 dark 模式底部白底问题
2026-03-04 21:23:48 +08:00
miwei
d7d91857c7
fix: Stripe 弹窗安全加固 + 清理未使用依赖
...
安全修复:
- client_secret 和 publishableKey 不再通过 URL 传递,改用 postMessage
弹窗发送 STRIPE_POPUP_READY 信号,父页面响应 STRIPE_POPUP_INIT 传递敏感数据
校验 event.origin 防止跨域消息伪造
- confirmAlipayPayment 改为显式调用,移除动态方法查找
- handleStripeSubmit 中 returnUrl 清理残留 query params
依赖清理:
- 移除未使用的 @stripe/react-stripe-js
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-03-04 15:27:51 +08:00
miwei
964a2aa6d9
feat: Stripe 改用 PaymentIntent + Payment Element,iframe 嵌入支付宝弹窗支付
...
Stripe 集成重构:
- 从 Checkout Session 改为 PaymentIntent + Payment Element 模式
- 前端内联渲染 Stripe 支付表单,支持信用卡、支付宝等多种方式
- Webhook 事件改为 payment_intent.succeeded / payment_intent.payment_failed
- provider/test 同步更新
iframe 嵌入模式 (ui_mode=embedded):
- 支付宝等需跳转的方式改为弹出新窗口处理,避免 X-Frame-Options 冲破 iframe
- 信用卡等无跳转方式仍在 iframe 内联完成
- 弹窗使用 confirmAlipayPayment 直接跳转,无需二次操作
- result 页面检测弹窗模式,支付成功后自动关闭窗口
Bug 修复:
- 修复配置加载前支付方式闪烁(初始值改为空数组 + loading)
- 修复桌面端 PaymentForm 缺少 methodLimits prop
- 修复 stripeError 隐藏表单导致无法重试
- 快捷金额增加 1000/2000 选项,过滤低于 minAmount 的选项
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-03-04 11:11:46 +08:00
erio
5be0616e78
feat: 支付手续费功能
...
- 支持提供商级别和渠道级别手续费率配置(FEE_RATE_PROVIDER_* / FEE_RATE_*)
- 用户多付手续费,到账金额不变(充值 ¥100 + 1.6% = 实付 ¥101.60)
- 前端显示手续费明细和实付金额
- 退款时按实付金额退款,余额扣减到账金额
2026-03-03 22:00:44 +08:00
erio
52aa484202
feat: 列表页占满宽度,充值页保持居中卡片,嵌入模式优化
...
- maxWidth 新增 'lg' 选项(max-w-6xl),'full' 改为无限制
- 充值页 PC 端使用 'lg',管理后台/我的订单使用 'full' 占满宽度
- 嵌入模式:减小外边距、隐藏装饰光斑、取消 min-h-screen
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-03 05:54:46 +08:00
erio
f4709b784f
fix: 有 src_host 时隐藏订单页「返回充值」按钮
...
从 iframe 嵌入(带 src_host)时不显示返回充值按钮,避免用户跳出。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-03 03:55:26 +08:00
erio
d952942627
feat: 订单来源追踪,保存 src_host / src_url 到订单记录
...
iframe 嵌入充值页面时 URL 自动附带来源参数,写入数据库用于追踪分析。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-03-02 20:40:16 +08:00
erio
c083880cbc
docs+feat: 完善 README 帮助内容配置说明,支持多行文字
...
- README (中/英) 修正 NEXT_PUBLIC_PAY_HELP_* → PAY_HELP_*
- 新增 PAYMENT_PROVIDERS 配置说明(两步配置服务商+渠道)
- 说明帮助图片支持外部 URL 或本地 uploads/ 两种方式
- PAY_HELP_TEXT 支持 \n 换行,渲染为多行段落
2026-03-02 04:17:51 +08:00
erio
a9ea9d4862
feat: 帮助图片点击放大(lightbox)
...
点击支付页右侧帮助区域的联系二维码图片,在屏幕正中以全屏遮罩放大展示;
点击背景或再次点击可关闭。
2026-03-02 03:39:49 +08:00
erio
e170d5451e
fix: 帮助内容改为服务端变量经 API 下发,运行时可配无需重新构建
2026-03-02 02:46:51 +08:00
erio
310fa1020f
fix: loadUserAndOrders 开始时重置 userNotFound,防止状态残留
2026-03-02 01:23:04 +08:00
erio
85239e97f8
fix: 用户不存在时前端提示错误;修正微信支付图标;beta compose 改用 Docker Hub 镜像
2026-03-02 01:05:01 +08:00
erio
136723b8af
feat: 支付渠道每日限额(渠道维度全平台统计)
...
- config.ts:新增 MAX_DAILY_AMOUNT_ALIPAY/WXPAY/STRIPE(默认 alipay/wxpay 各 1w,stripe 不限)
- lib/order/limits.ts:getMethodDailyLimit + queryMethodLimits 共用工具,支持动态渠道兜底
- order/service.ts:createOrder 校验渠道限额,超限抛 METHOD_DAILY_LIMIT_EXCEEDED
- api/limits/route.ts:公开接口 GET /api/limits,返回各渠道今日用量/剩余/是否可用
- api/user/route.ts:config 响应中加入 methodLimits,前端一次请求即可获取限额状态
- PaymentForm.tsx:额度已满的渠道置灰 + 标注「今日额度已满」,无法选择
- pay/page.tsx:AppConfig 加 methodLimits,传给 PaymentForm,新增错误码映射
2026-03-01 21:53:09 +08:00
erio
0c2476f340
fix: 无 token 不显示余额;充值完成后立即预取最新余额
...
- UserInfo.balance 改为可选字段
- 无 token 时不设 balance,PaymentForm 不渲染余额行
- COMPLETED 触发时立即调 loadUserAndOrders 刷新余额
2.2s 结果页展示期间余额已在后台拉取,回表单时即刻呈现新值
2026-03-01 21:24:11 +08:00
erio
b4eebb0b1b
feat: 分页组件统一封装 + 移动端无限滚动
...
- 新增 PaginationBar 组件,支持 isDark / loading / 页码导航 / 每页大小切换
- 重写 pay/orders/page.tsx 使用 PaginationBar,summary 来自 API groupBy 全量统计
- admin/page.tsx 替换内联分页 UI 为 PaginationBar
- MobileOrderList 支持无限滚动:IntersectionObserver 哨兵 + hasMore/loadingMore props
- pay/page.tsx 新增 loadMoreOrders(append 模式),初始化/刷新时重置分页状态
2026-03-01 20:12:32 +08:00
erio
292c14b882
feat: 订单列表支持分页查询,分页大小可选 20/50/100
...
- /api/orders/my 新增 page/page_size 参数,返回分页信息和全局状态统计
- 用户订单页:分页控件(首/上/下/末页)+ 分页大小选择,摘要卡片改为全局统计
- 管理员订单页:分页大小选择器(20/50/100)+ 首尾页跳转按钮
2026-03-01 20:04:49 +08:00
erio
e4005da38e
fix: 支付网关失败时返回友好错误信息
...
捕获支付提供商配置缺失或调用失败,
包装成 PAYMENT_GATEWAY_ERROR 错误码并返回中文提示,
前端同步处理该错误码显示具体原因。
2026-03-01 19:56:41 +08:00
erio
4374ca9126
feat: 每日充值限额 + 单笔上限默认 1000 + 前端金额校验优化
...
- 新增 MAX_DAILY_RECHARGE_AMOUNT 环境变量(0=不限制),
创建订单时统计当日已付款总额,超限返回友好提示
- MAX_RECHARGE_AMOUNT 默认值从 10000 改为 1000
- PaymentForm 快速金额按钮过滤掉超过 maxAmount 的选项
- 金额超限时前端显示明确提示(单笔最低/最高 ¥xxx)
- 支付说明栏展示每日限额信息
2026-03-01 19:41:44 +08:00
erio
c41933db70
security: 隐私接口全面加固,统一 token 鉴权
...
- /api/orders/[id] 只返回 id/status/expiresAt,移除 user_name/pay_url 等隐私字段
- /api/orders/[id]/cancel 改为 token 鉴权,服务端验证用户身份后执行取消
- /api/orders (POST 响应) 过滤 userName/userBalance,不向客户端暴露
- /api/user 移除 username/email/balance,只返回 id/status 和 config
- /api/users/[id] 只返回 {id, exists},不暴露任何隐私信息
- pay/page.tsx 恢复从服务端动态获取 config,无 token 时只显示用户 ID
- pay/orders/page.tsx 无 token 时不查询隐私接口,统一按钮样式
- PaymentQRCode 新增 token prop,无 token 时隐藏取消按钮
- 创建订单失败改为中文错误提示
2026-03-01 19:25:14 +08:00
erio
d9ab65ecf2
feat: integrate Stripe payment with bugfixes and active timeout cancellation
...
- Add Stripe payment provider with Checkout Session flow
- Payment provider abstraction layer (EasyPay + Stripe unified interface)
- Stripe webhook with proper raw body handling and signature verification
- Frontend: Stripe button with URL validation, anti-duplicate click, noopener
- Active timeout cancellation: query platform before expiring, recover paid orders
- Singleton Stripe client, idempotency keys, Math.round for amounts
- Handle async_payment events, return null for unknown webhook events
- Set Checkout Session expires_at aligned with order timeout
- Add cancelPayment to provider interface (Stripe: sessions.expire, EasyPay: no-op)
- Enable stripe in frontend payment type list
2026-03-01 17:58:08 +08:00
erio
2f45044073
refactor: extract pay page components and migrate zpay → easypay
...
Components:
- Add PayPageLayout, OrderFilterBar, MobileOrderList, OrderTable, OrderSummaryCards
- Extract shared pay-utils (types, constants, helper functions)
- Simplify pay/page.tsx and orders/page.tsx
EasyPay migration:
- Remove src/lib/zpay/, api/zpay/notify, zpay test, zpay.md
- Simplify config.ts: single envSchema, no ZPAY_* fallback
- Rename DB field zpay_trade_no → payment_trade_no (migration added)
- Update OrderDetail label: ZPAY订单号 → 支付单号
- Update CLAUDE.md project structure
2026-03-01 15:55:43 +08:00
erio
d2e856b89c
fix: align pay page header layout to match orders page
2026-03-01 15:00:27 +08:00
erio
04abbf1dd1
fix: add refresh+orders to header, remove 订单中心 card
2026-03-01 14:53:00 +08:00
erio
8656f1ab8f
fix: move refresh+orders buttons into 订单中心 card, remove from header
2026-03-01 14:41:05 +08:00
erio
3052886ca1
fix: add refresh button next to 我的订单 in desktop header
2026-03-01 14:36:56 +08:00
erio
ceb09659f8
feat: add refresh button to orders panel and admin page
...
- Desktop orders card in pay/page.tsx: refresh button next to "订单中心"
- Admin orders page: refresh button next to the page title
2026-03-01 14:17:18 +08:00
erio
d5719bf213
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
2026-03-01 03:04:24 +08:00