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
+18
-21
No files matched your search
+3
-3
@@ -42,14 +42,14 @@ DB_NAME=db.sqlite3
|
|||||||
# Waffo 支付(OpsXShell 收银台 · pancake.waffo.ai)
|
# Waffo 支付(OpsXShell 收银台 · pancake.waffo.ai)
|
||||||
# ============================================
|
# ============================================
|
||||||
# 店铺: https://pancake.waffo.ai/store/opsxshell-pwsi6m4n
|
# 店铺: https://pancake.waffo.ai/store/opsxshell-pwsi6m4n
|
||||||
# 包年订阅: PROD_2WmkUVoYWt0NN8OVEyC6n3 (type=subscription)
|
# 包年一次性: PROD_1BIezCi932IbgCzRIV8hcJ (type=onetime)
|
||||||
# 永久买断: PROD_0pcnzzT4nalEkkcdyIUoD5 (type=onetime)
|
# 永久买断: PROD_0pcnzzT4nalEkkcdyIUoD5 (type=onetime)
|
||||||
# 勿设置单一 WAFFO_CHECKOUT_URL,否则无法按档位分流商品
|
# 勿设置单一 WAFFO_CHECKOUT_URL,否则无法按档位分流商品
|
||||||
WAFFO_STORE_SLUG=opsxshell-pwsi6m4n
|
WAFFO_STORE_SLUG=opsxshell-pwsi6m4n
|
||||||
WAFFO_PRODUCT_ID=PROD_0pcnzzT4nalEkkcdyIUoD5
|
WAFFO_PRODUCT_ID=PROD_0pcnzzT4nalEkkcdyIUoD5
|
||||||
WAFFO_PRODUCT_ID_YEARLY=PROD_2WmkUVoYWt0NN8OVEyC6n3
|
WAFFO_PRODUCT_ID_YEARLY=PROD_1BIezCi932IbgCzRIV8hcJ
|
||||||
WAFFO_PRODUCT_ID_PERPETUAL=PROD_0pcnzzT4nalEkkcdyIUoD5
|
WAFFO_PRODUCT_ID_PERPETUAL=PROD_0pcnzzT4nalEkkcdyIUoD5
|
||||||
WAFFO_CURRENCY=USD
|
WAFFO_CURRENCY=CNY
|
||||||
# test | live(test 时自动附加 test=true)
|
# test | live(test 时自动附加 test=true)
|
||||||
WAFFO_ENVIRONMENT=test
|
WAFFO_ENVIRONMENT=test
|
||||||
# 支付成功回跳(桌面端 deep link;CreateOrder/Checkout 的 return_url 可覆盖)
|
# 支付成功回跳(桌面端 deep link;CreateOrder/Checkout 的 return_url 可覆盖)
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ func ensureWaffoPaymentGateway(db *gorm.DB) error {
|
|||||||
Gateway: "waffo",
|
Gateway: "waffo",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
SandboxMode: true,
|
SandboxMode: true,
|
||||||
Currency: "USD",
|
Currency: "CNY",
|
||||||
Priority: 0,
|
Priority: 0,
|
||||||
}
|
}
|
||||||
if err := db.Create(&gw).Error; err != nil {
|
if err := db.Create(&gw).Error; err != nil {
|
||||||
@@ -291,7 +291,7 @@ func ensureWaffoPaymentGateway(db *gorm.DB) error {
|
|||||||
} else {
|
} else {
|
||||||
existing.Enabled = true
|
existing.Enabled = true
|
||||||
existing.SandboxMode = true
|
existing.SandboxMode = true
|
||||||
existing.Currency = "USD"
|
existing.Currency = "CNY"
|
||||||
existing.Priority = 0
|
existing.Priority = 0
|
||||||
if err := db.Save(&existing).Error; err != nil {
|
if err := db.Save(&existing).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -303,6 +303,6 @@ func ensureWaffoPaymentGateway(db *gorm.DB) error {
|
|||||||
Update("priority", 100).Error; err != nil {
|
Update("priority", 100).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Println("[初始化] 支付网关已优先 Waffo(包年 subscription / 永久 onetime)")
|
log.Println("[初始化] 支付网关已优先 Waffo(包年/永久均为 onetime)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ func LoadWaffoConfig() WaffoConfig {
|
|||||||
}
|
}
|
||||||
currency := strings.TrimSpace(os.Getenv("WAFFO_CURRENCY"))
|
currency := strings.TrimSpace(os.Getenv("WAFFO_CURRENCY"))
|
||||||
if currency == "" {
|
if currency == "" {
|
||||||
currency = "USD"
|
currency = "CNY"
|
||||||
}
|
}
|
||||||
defaultProduct := strings.TrimSpace(os.Getenv("WAFFO_PRODUCT_ID"))
|
defaultProduct := strings.TrimSpace(os.Getenv("WAFFO_PRODUCT_ID"))
|
||||||
yearly := strings.TrimSpace(os.Getenv("WAFFO_PRODUCT_ID_YEARLY"))
|
yearly := strings.TrimSpace(os.Getenv("WAFFO_PRODUCT_ID_YEARLY"))
|
||||||
@@ -104,13 +104,10 @@ func productIDForPlan(cfg WaffoConfig, planType string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkoutTypeForPlan(planType string) string {
|
func checkoutTypeForPlan(planType string) string {
|
||||||
switch strings.TrimSpace(planType) {
|
// OpsXShell 包年 / 永久均为 Waffo onetime 商品(包年不再走 subscription)。 // Logan.Li
|
||||||
case "yearly", "monthly":
|
_ = planType
|
||||||
return "subscription"
|
|
||||||
default:
|
|
||||||
return "onetime"
|
return "onetime"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func resolveBaseCheckoutURL(cfg WaffoConfig, planType string) (*url.URL, error) {
|
func resolveBaseCheckoutURL(cfg WaffoConfig, planType string) (*url.URL, error) {
|
||||||
// Single WAFFO_CHECKOUT_URL only as absolute fallback when no store/products configured.
|
// Single WAFFO_CHECKOUT_URL only as absolute fallback when no store/products configured.
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuildCheckoutURL_YearlySubscription(t *testing.T) {
|
func TestBuildCheckoutURL_YearlyOnetime(t *testing.T) {
|
||||||
cfg := WaffoConfig{
|
cfg := WaffoConfig{
|
||||||
StoreSlug: "opsxshell-pwsi6m4n",
|
StoreSlug: "opsxshell-pwsi6m4n",
|
||||||
ProductIDYearly: "PROD_2WmkUVoYWt0NN8OVEyC6n3",
|
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
|
||||||
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
|
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
|
||||||
Currency: "USD",
|
Currency: "CNY",
|
||||||
Environment: "test",
|
Environment: "test",
|
||||||
SuccessURL: "opsxshell://pro/activated",
|
SuccessURL: "opsxshell://pro/activated",
|
||||||
}
|
}
|
||||||
@@ -23,14 +23,14 @@ func TestBuildCheckoutURL_YearlySubscription(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(u.Path, "PROD_2WmkUVoYWt0NN8OVEyC6n3") {
|
if !strings.Contains(u.Path, "PROD_1BIezCi932IbgCzRIV8hcJ") {
|
||||||
t.Fatalf("yearly product missing: %s", raw)
|
t.Fatalf("yearly product missing: %s", raw)
|
||||||
}
|
}
|
||||||
q := u.Query()
|
q := u.Query()
|
||||||
if q.Get("type") != "subscription" {
|
if q.Get("type") != "onetime" {
|
||||||
t.Fatalf("type=%s want subscription", q.Get("type"))
|
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"))
|
t.Fatalf("currency=%s", q.Get("currency"))
|
||||||
}
|
}
|
||||||
if q.Get("test") != "true" {
|
if q.Get("test") != "true" {
|
||||||
@@ -41,9 +41,9 @@ func TestBuildCheckoutURL_YearlySubscription(t *testing.T) {
|
|||||||
func TestBuildCheckoutURL_PerpetualOnetime(t *testing.T) {
|
func TestBuildCheckoutURL_PerpetualOnetime(t *testing.T) {
|
||||||
cfg := WaffoConfig{
|
cfg := WaffoConfig{
|
||||||
StoreSlug: "opsxshell-pwsi6m4n",
|
StoreSlug: "opsxshell-pwsi6m4n",
|
||||||
ProductIDYearly: "PROD_2WmkUVoYWt0NN8OVEyC6n3",
|
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
|
||||||
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
|
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
|
||||||
Currency: "USD",
|
Currency: "CNY",
|
||||||
Environment: "test",
|
Environment: "test",
|
||||||
SuccessURL: "opsxshell://pro/activated",
|
SuccessURL: "opsxshell://pro/activated",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user