包年 SKU 换为 PROD_1BIezCi932IbgCzRIV8hcJ,checkout type 统一 onetime。 Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package payment
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestBuildCheckoutURL_YearlyOnetime(t *testing.T) {
|
|
cfg := WaffoConfig{
|
|
StoreSlug: "opsxshell-pwsi6m4n",
|
|
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
|
|
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
|
|
Currency: "CNY",
|
|
Environment: "test",
|
|
SuccessURL: "opsxshell://pro/activated",
|
|
}
|
|
raw, err := BuildCheckoutURL(cfg, "ORD1", "dev-1", "a@b.c", "", "yearly")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
u, err := url.Parse(raw)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(u.Path, "PROD_1BIezCi932IbgCzRIV8hcJ") {
|
|
t.Fatalf("yearly product missing: %s", raw)
|
|
}
|
|
q := u.Query()
|
|
if q.Get("type") != "onetime" {
|
|
t.Fatalf("type=%s want onetime", q.Get("type"))
|
|
}
|
|
if q.Get("currency") != "CNY" {
|
|
t.Fatalf("currency=%s", q.Get("currency"))
|
|
}
|
|
if q.Get("test") != "true" {
|
|
t.Fatalf("test=%s", q.Get("test"))
|
|
}
|
|
}
|
|
|
|
func TestBuildCheckoutURL_PerpetualOnetime(t *testing.T) {
|
|
cfg := WaffoConfig{
|
|
StoreSlug: "opsxshell-pwsi6m4n",
|
|
ProductIDYearly: "PROD_1BIezCi932IbgCzRIV8hcJ",
|
|
ProductIDPerpetual: "PROD_0pcnzzT4nalEkkcdyIUoD5",
|
|
Currency: "CNY",
|
|
Environment: "test",
|
|
SuccessURL: "opsxshell://pro/activated",
|
|
}
|
|
raw, err := BuildCheckoutURL(cfg, "ORD2", "dev-1", "a@b.c", "", "perpetual")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
u, err := url.Parse(raw)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(u.Path, "PROD_0pcnzzT4nalEkkcdyIUoD5") {
|
|
t.Fatalf("perpetual product missing: %s", raw)
|
|
}
|
|
if u.Query().Get("type") != "onetime" {
|
|
t.Fatalf("type=%s want onetime", u.Query().Get("type"))
|
|
}
|
|
}
|