fix: 包年改为 Waffo 一次性商品并切 CNY
包年 SKU 换为 PROD_1BIezCi932IbgCzRIV8hcJ,checkout type 统一 onetime。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a47af22e91
commit
d4c5637168
4 files changed
+19
-22
No files matched your search
@@ -282,7 +282,7 @@ func ensureWaffoPaymentGateway(db *gorm.DB) error {
|
||||
Gateway: "waffo",
|
||||
Enabled: true,
|
||||
SandboxMode: true,
|
||||
Currency: "USD",
|
||||
Currency: "CNY",
|
||||
Priority: 0,
|
||||
}
|
||||
if err := db.Create(&gw).Error; err != nil {
|
||||
@@ -291,7 +291,7 @@ func ensureWaffoPaymentGateway(db *gorm.DB) error {
|
||||
} else {
|
||||
existing.Enabled = true
|
||||
existing.SandboxMode = true
|
||||
existing.Currency = "USD"
|
||||
existing.Currency = "CNY"
|
||||
existing.Priority = 0
|
||||
if err := db.Save(&existing).Error; err != nil {
|
||||
return err
|
||||
@@ -303,6 +303,6 @@ func ensureWaffoPaymentGateway(db *gorm.DB) error {
|
||||
Update("priority", 100).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
log.Println("[初始化] 支付网关已优先 Waffo(包年 subscription / 永久 onetime)")
|
||||
log.Println("[初始化] 支付网关已优先 Waffo(包年/永久均为 onetime)")
|
||||
return nil
|
||||
}
|
||||
@@ -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",
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user