This commit is contained in:
eric
2026-04-01 02:23:17 -05:00
parent 056dadc817
commit de86a65293
8 changed files with 202 additions and 52 deletions

View File

@@ -1,57 +1,46 @@
# NomadVIP | 异度星球
VIP 会员解锁页,集成 PocketBase 支付校验、XorPay/ZPAY 支付
NomadVIP 前端Next.js App Router负责会员购买、支付跳转、支付状态轮询以及与 `payjsapi` / PocketBase 联动完成 VIP 开通
## 服务配置(参考 desktop digital
## 核心流程
ZPAY、PocketBase、MinIO 配置与 `C:\project\digital` 保持一致,复制 `.env.example``.env.local` 后按需修改:
1. 前端调用 `app/api/pay` 发起支付。
2. `app/api/pay` 按设备分流:
- 微信内:`xorpay`
- PC / 手机浏览器:`zpay`
3. 支付成功后通过 `payjsapi` 异步通知写入 PocketBase。
4. 若通知延迟,前端会调用 `app/api/pay/confirm` 兜底写入 `payments` + `site_vip`
## 关键配置
复制 `.env.example``.env.local`,按需修改:
| 变量 | 说明 | 默认值 |
|------|------|--------|
| `NEXT_SERVER_ACTIONS_ENCRYPTION_KEY` | Server Actions 加密密钥(可选,未设时自动从 `config/server-actions.key` 加载) | `config/server-actions.key` |
| `NEXT_PUBLIC_POCKETBASE_URL` | PocketBase 地址 | `https://pocketbase.hackrobot.cn` |
| `NEXT_PUBLIC_API_URL` / `PAYMENT_API_URL` | payjsapi 地址 | `https://api.hackrobot.cn` |
| `PAYMENT_PROVIDER` | 支付提供商payjsapi 环境变量) | `xorpay` / `zpay` |
| `NEXT_PUBLIC_POCKETBASE_URL` | PocketBase 地址(浏览器侧) | `https://pocketbase.hackrobot.cn` |
| `POCKETBASE_URL` | PocketBase 地址(服务端) | `http://127.0.0.1:8090` |
| `PAYMENT_API_URL` / `NEXT_PUBLIC_API_URL` | payjsapi 公网地址 | `https://api.hackrobot.cn` |
| `PAYMENT_API_INTERNAL_URL` | 同机部署时 payjsapi 内网地址 | `http://127.0.0.1:8007` |
| `PAYMENT_DEFAULT_AMOUNT` | 默认支付金额(分) | `18800` |
| `ZPAY_SUBMIT_URL` | ZPAY 收银台地址 | `https://zpayz.cn/submit.php` |
| `POCKETBASE_EMAIL` / `POCKETBASE_PASSWORD` | confirm 兜底写库所需管理员账号 | - |
**XorPay**:直接调用 payh5无 redirect 中转,表单提交至 xorpay 收银台。payjsapi 需设置 `PAYMENT_PROVIDER=xorpay`。切换渠道仅需前端改参数,后端 payjsapi 标准化接口。
**设备逻辑**PC 显示二维码 + 支付状态轮询;手机/微信无中转页,直接跳转收银台。默认价格 8.8 元880 分)。
| `MINIO_ENDPOINT` | MinIO 端点 | `minioweb.hackrobot.cn` |
| `MINIO_BUCKET` | 存储桶 | `hackrobot` |
详见 `config/services.config.ts`
## Getting Started
First, run the development server:
## 本地开发
```bash
npm install
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
访问 `http://localhost:3000`
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
## 自检与已修复问题2026-04-01
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
- 已修复:`app/api/pay/confirm` 在兜底写 `payments` 时使用默认金额,可能导致测试价/临时调价场景记账错误。
- 修复后:优先使用支付网关返回的 `pay_price`(元)换算为分;只有拿不到实际金额时才回退默认金额。
## Learn More
## 常见排查
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
- 支付发起失败:优先检查 `PAYMENT_API_INTERNAL_URL` / `PAYMENT_API_URL` 是否可达。
- 已支付但未开通:检查 `payjsapi``/nomadvip/order_status` 与异步通知日志。
- 账号已支付但 VIP 未识别:检查 `vip_email_link` 关联是否建立。