fix: 修复支付页测试/生产 Product 映射串用与无法保存

切换环境时先暂存再切换;后端 Profile 不再串用另一侧商品;支持一键填充 OpsXshell 与跨环境复制,调试使用当前页映射。
This commit is contained in:
Logan.Li committed 2026-08-12 23:35:27 +08:00
1 parent 9b79eabd34
commit 7c146cb639
5 files changed
+317 -71

No files matched your search

@@ -37,6 +37,7 @@ type WaffoProductMapping struct {
PlanKey string `json:"plan_key"`
Label string `json:"label,omitempty"`
ProductID string `json:"product_id"`
Currency string `json:"currency,omitempty"`
}
// WaffoPublicMeta 存入 payment_gateway_configs.public_key 的 JSON(无私钥) // Logan.Li
@@ -416,6 +417,11 @@ func ResolveProductID(cfg WaffoConfig, planType string) string {
return productIDForPlan(cfg, planType)
}
// ResolveCurrency 按 plan_type 解析结算货币 // Logan.Li
func ResolveCurrency(cfg WaffoConfig, planType string) string {
return currencyForPlan(cfg, planType)
}
func productIDForPlan(cfg WaffoConfig, planType string) string {
plan := strings.TrimSpace(strings.ToLower(planType))
if plan == "" {
@@ -86,7 +86,11 @@ func CreateCheckoutSession(cfg WaffoConfig, req CreateSessionRequest) (*CreateSe
if env == "" {
env = strings.TrimSpace(cfg.Environment)
}
if env == "" {
// Waffo Store Slug 鉴权要求 X-Environment 为 test|prod(不是 live) // Logan.Li
switch strings.ToLower(env) {
case "live", "prod", "production":
env = "prod"
default:
env = "test"
}
httpReq.Header.Set("X-Store-Slug", slug)