's'
This commit is contained in:
@@ -12,7 +12,9 @@ ZPAY、PocketBase、MinIO 配置与 `C:\project\digital` 保持一致,复制 `
|
|||||||
| `NEXT_PUBLIC_API_URL` / `PAYMENT_API_URL` | payjsapi 地址 | `https://api.hackrobot.cn` |
|
| `NEXT_PUBLIC_API_URL` / `PAYMENT_API_URL` | payjsapi 地址 | `https://api.hackrobot.cn` |
|
||||||
| `PAYMENT_PROVIDER` | 支付提供商(payjsapi 环境变量) | `xorpay` / `zpay` |
|
| `PAYMENT_PROVIDER` | 支付提供商(payjsapi 环境变量) | `xorpay` / `zpay` |
|
||||||
|
|
||||||
**XorPay**:直接调用 payh5,无 redirect 中转,表单提交至 xorpay 收银台。payjsapi 需设置 `PAYMENT_PROVIDER=xorpay`。
|
**XorPay**:直接调用 payh5,无 redirect 中转,表单提交至 xorpay 收银台。payjsapi 需设置 `PAYMENT_PROVIDER=xorpay`。切换渠道仅需前端改参数,后端 payjsapi 标准化接口。
|
||||||
|
|
||||||
|
**设备逻辑**:PC 显示二维码 + 支付状态轮询;手机/微信无中转页,直接跳转收银台。默认价格 8.8 元(880 分)。
|
||||||
| `MINIO_ENDPOINT` | MinIO 端点 | `minioweb.hackrobot.cn` |
|
| `MINIO_ENDPOINT` | MinIO 端点 | `minioweb.hackrobot.cn` |
|
||||||
| `MINIO_BUCKET` | 存储桶 | `hackrobot` |
|
| `MINIO_BUCKET` | 存储桶 | `hackrobot` |
|
||||||
|
|
||||||
|
|||||||
@@ -37,25 +37,10 @@ function buildPayHtml(
|
|||||||
.map(([k, v]) => `<input type="hidden" name="${escapeAttr(k)}" value="${escapeAttr(v)}" />`)
|
.map(([k, v]) => `<input type="hidden" name="${escapeAttr(k)}" value="${escapeAttr(v)}" />`)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
const direct = options?.directToCashier;
|
const direct = options?.directToCashier;
|
||||||
// 微信内:显示加载提示,避免 visibility:hidden 导致部分 WebView 表单提交异常
|
// 手机/微信:无中转页,直接提交表单跳转收银台
|
||||||
return direct
|
return direct
|
||||||
? `<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>支付</title><style>body{font-family:system-ui;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;background:#f0f4f8;}p{color:#64748b;}</style></head><body><p>正在跳转至微信支付...</p><form id="f" action="${escapeAttr(payUrl)}" method="POST" enctype="application/x-www-form-urlencoded">${inputs}</form><script>document.getElementById("f").submit()</script></body></html>`
|
? `<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>支付</title><style>body{margin:0;overflow:hidden}</style></head><body><form id="f" action="${escapeAttr(payUrl)}" method="POST" enctype="application/x-www-form-urlencoded">${inputs}</form><script>document.getElementById("f").submit()</script></body></html>`
|
||||||
: `<!DOCTYPE html>
|
: `<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>支付</title><style>body{margin:0;overflow:hidden}</style></head><body><form id="zpayForm" action="${escapeAttr(payUrl)}" method="POST" enctype="application/x-www-form-urlencoded">${inputs}</form><script>document.getElementById("zpayForm").submit();</script></body></html>`;
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
||||||
<title>跳转支付...</title>
|
|
||||||
<style>body{font-family:system-ui;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;background:#f0f4f8;}p{color:#64748b;}</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>正在跳转到支付页面...</p>
|
|
||||||
<form id="zpayForm" action="${escapeAttr(payUrl)}" method="POST" enctype="application/x-www-form-urlencoded">
|
|
||||||
${inputs}
|
|
||||||
</form>
|
|
||||||
<script>document.getElementById("zpayForm").submit();</script>
|
|
||||||
</body>
|
|
||||||
</html>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPayOrderCookie(res: NextResponse, orderId: string) {
|
function setPayOrderCookie(res: NextResponse, orderId: string) {
|
||||||
@@ -127,7 +112,7 @@ export async function POST(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const return_url = String(body?.return_url || "").trim();
|
const return_url = String(body?.return_url || "").trim();
|
||||||
const total_fee = Number(body?.total_fee) || 8800;
|
const total_fee = Number(body?.total_fee) || payConfig.defaultAmount || 880;
|
||||||
const type = String(body?.type || "vip");
|
const type = String(body?.type || "vip");
|
||||||
const channel = String(body?.channel || "wxpay");
|
const channel = String(body?.channel || "wxpay");
|
||||||
const device = String(body?.device || "pc");
|
const device = String(body?.device || "pc");
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import PocketBase from "pocketbase";
|
|||||||
import { indexMd } from "./index-content";
|
import { indexMd } from "./index-content";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
import { getPayEnv, getDeviceFromEnv } from "@/app/lib/payEnv";
|
import { getPayEnv, getDeviceFromEnv } from "@/app/lib/payEnv";
|
||||||
|
import { getPaymentConfig } from "@/config/services.config";
|
||||||
|
import { getPaymentConfig } from "@/config/services.config";
|
||||||
import { usePayStatusPoll } from "@/app/lib/usePayStatusPoll";
|
import { usePayStatusPoll } from "@/app/lib/usePayStatusPoll";
|
||||||
|
|
||||||
const PB_URL =
|
const PB_URL =
|
||||||
@@ -160,10 +162,11 @@ export default function Home() {
|
|||||||
const returnUrl = `${window.location.origin}/paid`;
|
const returnUrl = `${window.location.origin}/paid`;
|
||||||
const env = getPayEnv();
|
const env = getPayEnv();
|
||||||
const device = getDeviceFromEnv(env);
|
const device = getDeviceFromEnv(env);
|
||||||
|
const totalFee = getPaymentConfig().defaultAmount ?? 880;
|
||||||
redirectToPay({
|
redirectToPay({
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
return_url: returnUrl,
|
return_url: returnUrl,
|
||||||
total_fee: 8800,
|
total_fee: totalFee,
|
||||||
type: "vip",
|
type: "vip",
|
||||||
channel: "wxpay",
|
channel: "wxpay",
|
||||||
device,
|
device,
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ export interface PaymentConfig {
|
|||||||
apiUrl: string;
|
apiUrl: string;
|
||||||
provider: "zpay" | "xorpay";
|
provider: "zpay" | "xorpay";
|
||||||
zpaySubmitUrl: string;
|
zpaySubmitUrl: string;
|
||||||
/** nomadvip 专用接口路径(固定 ZPAY,不影响 digital/cnomadcna) */
|
/** 默认金额(分),8.8 元 = 880 */
|
||||||
|
defaultAmount?: number;
|
||||||
|
/** nomadvip 专用接口路径 */
|
||||||
nomadvipPayPath: string;
|
nomadvipPayPath: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ export function getPaymentConfig(): PaymentConfig {
|
|||||||
provider: (process.env.PAYMENT_PROVIDER as "zpay" | "xorpay") || "zpay",
|
provider: (process.env.PAYMENT_PROVIDER as "zpay" | "xorpay") || "zpay",
|
||||||
zpaySubmitUrl:
|
zpaySubmitUrl:
|
||||||
process.env.ZPAY_SUBMIT_URL || "https://zpayz.cn/submit.php",
|
process.env.ZPAY_SUBMIT_URL || "https://zpayz.cn/submit.php",
|
||||||
|
defaultAmount: 880,
|
||||||
nomadvipPayPath: "/nomadvip/payh5",
|
nomadvipPayPath: "/nomadvip/payh5",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user