Files
pangolin/server/cmd/server/buy_page.go
T
wangjia 1a7b93ed2f feat(server): /buy 自包含购买页(同源,USDT+哪吒,登录→下单→轮询开通)
单文件 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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
2026-07-11 14:52:21 +08:00

23 lines
744 B
Go

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)
}