fix: 包年改为 Waffo 一次性商品并切 CNY

包年 SKU 换为 PROD_1BIezCi932IbgCzRIV8hcJ,checkout type 统一 onetime。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Logan.LiandCursor committed 2026-08-12 16:04:36 +08:00
1 parent a47af22e91
commit d4c5637168
4 files changed
+19 -22

No files matched your search

+4 -7
View File
@@ -31,7 +31,7 @@ func LoadWaffoConfig() WaffoConfig {
}
currency := strings.TrimSpace(os.Getenv("WAFFO_CURRENCY"))
if currency == "" {
currency = "USD"
currency = "CNY"
}
defaultProduct := strings.TrimSpace(os.Getenv("WAFFO_PRODUCT_ID"))
yearly := strings.TrimSpace(os.Getenv("WAFFO_PRODUCT_ID_YEARLY"))
@@ -104,12 +104,9 @@ func productIDForPlan(cfg WaffoConfig, planType string) string {
}
func checkoutTypeForPlan(planType string) string {
switch strings.TrimSpace(planType) {
case "yearly", "monthly":
return "subscription"
default:
return "onetime"
}
// OpsXShell 包年 / 永久均为 Waffo onetime 商品(包年不再走 subscription)。 // Logan.Li
_ = planType
return "onetime"
}
func resolveBaseCheckoutURL(cfg WaffoConfig, planType string) (*url.URL, error) {
@@ -6,12 +6,12 @@ import (
"testing"
)
func TestBuildCheckoutURL_YearlySubscription(t *testing.T) {
func TestBuildCheckoutURL_YearlyOnetime(t *testing.T) {
cfg := WaffoConfig{
StoreSlug: "opsxshell-pwsi6m4n",
ProductIDYearly: "PROD_2WmkUVoYWt0NN8OVEyC6n3",
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
Currency: "USD",
Currency: "CNY",
Environment: "test",
SuccessURL: "opsxshell://pro/activated",
}
@@ -23,14 +23,14 @@ func TestBuildCheckoutURL_YearlySubscription(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if !strings.Contains(u.Path, "PROD_2WmkUVoYWt0NN8OVEyC6n3") {
if !strings.Contains(u.Path, "PROD_1BIezCi932IbgCzRIV8hcJ") {
t.Fatalf("yearly product missing: %s", raw)
}
q := u.Query()
if q.Get("type") != "subscription" {
t.Fatalf("type=%s want subscription", q.Get("type"))
if q.Get("type") != "onetime" {
t.Fatalf("type=%s want onetime", q.Get("type"))
}
if q.Get("currency") != "USD" {
if q.Get("currency") != "CNY" {
t.Fatalf("currency=%s", q.Get("currency"))
}
if q.Get("test") != "true" {
@@ -41,9 +41,9 @@ func TestBuildCheckoutURL_YearlySubscription(t *testing.T) {
func TestBuildCheckoutURL_PerpetualOnetime(t *testing.T) {
cfg := WaffoConfig{
StoreSlug: "opsxshell-pwsi6m4n",
ProductIDYearly: "PROD_2WmkUVoYWt0NN8OVEyC6n3",
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
Currency: "USD",
Currency: "CNY",
Environment: "test",
SuccessURL: "opsxshell://pro/activated",
}