fix: 测试包年商品改用 USD,避免 CNY 不被支持

Waffo 测试侧 Yearly Product 仅支持 USD;按 Product ID 自动选币种。
This commit is contained in:
Logan.Li committed 2026-08-13 00:13:07 +08:00
1 parent 2b44e8dcb3
commit 37d9e8ca56
3 files changed
+51 -23

No files matched your search

+17 -3
View File
@@ -456,22 +456,36 @@ func productIDForPlan(cfg WaffoConfig, planType string) string {
}
func currencyForPlan(cfg WaffoConfig, planType string) string {
// 已知商品 ID 优先(测试包年不支持 CNY) // Logan.Li
if pid := productIDForPlan(cfg, planType); pid != "" {
switch pid {
case "PROD_1BIezCi932IbgCzRIV8hcJ", // test yearly
"PROD_0pcnzzT4nalEkkcdyIUoD5", // test perpetual
"PROD_3BSJqDRkVBoYNgO78NsTAU": // live perpetual
return "USD"
case "PROD_5PqVJyEiCM4nDgVoA0RKjN": // live yearly
return "CNY"
}
}
switch strings.TrimSpace(strings.ToLower(planType)) {
case "yearly", "monthly":
if cfg.CurrencyYearly != "" {
return cfg.CurrencyYearly
}
return "CNY" // OpsXshell 包年默认人民币 // Logan.Li
if NormalizeWaffoEnvironment(cfg.Environment) == "live" {
return "CNY"
}
return "USD"
case "perpetual", "lifetime":
if cfg.CurrencyPerpetual != "" {
return cfg.CurrencyPerpetual
}
return "USD" // OpsXshell 永久默认美元 // Logan.Li
return "USD"
}
if cfg.Currency != "" {
return cfg.Currency
}
return "CNY"
return "USD"
}
func checkoutTypeForPlan(planType string) string {
@@ -6,13 +6,13 @@ import (
"testing"
)
func TestResolveBaseCheckoutURL_YearlyOnetimeCNY(t *testing.T) {
func TestResolveBaseCheckoutURL_YearlyOnetimeUSD(t *testing.T) {
cfg := WaffoConfig{
StoreSlug: "opsxshell-pwsi6m4n",
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
Currency: "CNY",
CurrencyYearly: "CNY",
CurrencyYearly: "CNY", // 即使配置写 CNY,已知测试商品仍强制 USD // Logan.Li
CurrencyPerpetual: "USD",
Environment: "test",
SuccessURL: "opsxshell://pro/activated",
@@ -28,12 +28,12 @@ func TestResolveBaseCheckoutURL_YearlyOnetimeCNY(t *testing.T) {
if q.Get("type") != "onetime" {
t.Fatalf("type=%s want onetime", q.Get("type"))
}
if q.Get("currency") != "CNY" {
t.Fatalf("currency=%s want CNY", q.Get("currency"))
if q.Get("currency") != "USD" {
t.Fatalf("currency=%s want USD", q.Get("currency"))
}
}
func TestResolveBaseCheckoutURL_PerpetualOnetimeCNY(t *testing.T) {
func TestResolveBaseCheckoutURL_PerpetualOnetimeUSD(t *testing.T) {
cfg := WaffoConfig{
StoreSlug: "opsxshell-pwsi6m4n",
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
@@ -55,8 +55,8 @@ func TestResolveBaseCheckoutURL_PerpetualOnetimeCNY(t *testing.T) {
if q.Get("type") != "onetime" {
t.Fatalf("type=%s want onetime", q.Get("type"))
}
if q.Get("currency") != "CNY" {
t.Fatalf("currency=%s want CNY", q.Get("currency"))
if q.Get("currency") != "USD" {
t.Fatalf("currency=%s want USD", q.Get("currency"))
}
}