From 1a7b93ed2f61aaea01f075a63510b4ebd4ecb8fe Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Sat, 11 Jul 2026 14:52:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(server):=20/buy=20=E8=87=AA=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E8=B4=AD=E4=B9=B0=E9=A1=B5(=E5=90=8C=E6=BA=90,USDT+?= =?UTF-8?q?=E5=93=AA=E5=90=92,=E7=99=BB=E5=BD=95=E2=86=92=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E2=86=92=E8=BD=AE=E8=AF=A2=E5=BC=80=E9=80=9A)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 单文件 HTML(内联 CSS+JS,go:embed)挂在公开 GET /buy,与 /v1/pay 同源免 CORS: 登录 -> 拉取套餐 -> 选 USDT/哪吒下单 -> 按 render_type(crypto_address/redirect/qr) 展示付款信息 -> 轮询订单直到 activated,页面隐藏/关闭时停止轮询。 Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u --- server/cmd/server/buy.html | 410 ++++++++++++++++++++++++++++++++++ server/cmd/server/buy_page.go | 22 ++ server/cmd/server/main.go | 4 + 3 files changed, 436 insertions(+) create mode 100644 server/cmd/server/buy.html create mode 100644 server/cmd/server/buy_page.go diff --git a/server/cmd/server/buy.html b/server/cmd/server/buy.html new file mode 100644 index 0000000..21a8e46 --- /dev/null +++ b/server/cmd/server/buy.html @@ -0,0 +1,410 @@ + + + + + +购买 Pangolin + + + +
+
+ +

购买 Pangolin

+
+ + +
+

登录账号

+
+
+ + + + + +
+
+ + + + + + +
+ + + + diff --git a/server/cmd/server/buy_page.go b/server/cmd/server/buy_page.go new file mode 100644 index 0000000..41819ff --- /dev/null +++ b/server/cmd/server/buy_page.go @@ -0,0 +1,22 @@ +package main + +import ( + _ "embed" + "net/http" +) + +// buyPageHTML is the self-contained, same-origin "/buy" purchase page: login +// -> pick a plan + payment method (USDT/nezha) -> create order -> poll until +// activated. It talks to /v1/auth/login, /v1/pay/catalog, /v1/pay/orders and +// /v1/pay/orders/{orderNo} via relative fetch() calls, so it's always same +// origin as the API (no CORS needed) as long as it's served from this binary. +// +//go:embed buy.html +var buyPageHTML []byte + +// serveBuyPage handles GET /buy. Public (no JWT) — the page itself drives the +// login flow client-side. +func serveBuyPage(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "text/html; charset=utf-8") + _, _ = w.Write(buyPageHTML) +} diff --git a/server/cmd/server/main.go b/server/cmd/server/main.go index c1bfdd4..9b683d0 100644 --- a/server/cmd/server/main.go +++ b/server/cmd/server/main.go @@ -131,6 +131,10 @@ func main() { _ = json.NewEncoder(w).Encode(map[string]string{"status": "ok"}) }) + // Public (no JWT): self-contained purchase page, same-origin as /v1/pay/* + // so it can call the API with plain relative fetch()s (no CORS). + r.Get("/buy", serveBuyPage) + // Optional probe ingest route. sharedProbeStore is reused by the scheduler // (below) when both are enabled, so they share one Redis-backed store. var sharedProbeStore *probe.Store