feat(payment): 虎皮椒聚合支付 - 官方插件与跨平台可执行文件

新增 xunhupay 官方包,支付 RPC 与宿主只保留订单和验签边界;官方支付包同时带上各系统 provider,避免把 Linux ELF 当成本机入口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ddCat
2026-09-17 23:32:11 +08:00
parent e5a5f0ccc8
commit a23df0cb32
63 changed files with 2070 additions and 128 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"sort"
@@ -91,6 +92,15 @@ type pluginRegistryRecord struct {
}
func newPluginRuntime(dataDir string) (*pluginRuntime, error) {
dataDir = strings.TrimSpace(dataDir)
if dataDir == "" {
return nil, errors.New("plugin data directory is empty")
}
var err error
dataDir, err = filepath.Abs(dataDir)
if err != nil {
return nil, fmt.Errorf("plugin data directory is invalid: %w", err)
}
if err := os.MkdirAll(dataDir, 0o755); err != nil {
return nil, fmt.Errorf("create plugin registry directory: %w", err)
}
@@ -519,8 +529,24 @@ func paymentRuntimeReady(root, digest, backendEntry string) bool {
if err != nil || strings.TrimSpace(string(ready)) != digest {
return false
}
entry, err := os.Stat(filepath.Join(root, filepath.FromSlash(backendEntry)))
return err == nil && !entry.IsDir()
return protocol.HasAnyPaymentRPCBackend(backendEntry, paymentRuntimeBackendFiles(root))
}
func paymentRuntimeBackendFiles(root string) map[string][]byte {
files := map[string][]byte{}
backendRoot := filepath.Join(root, "backend")
_ = filepath.WalkDir(backendRoot, func(path string, entry fs.DirEntry, err error) error {
if err != nil || entry.IsDir() {
return err
}
rel, relErr := filepath.Rel(root, path)
if relErr != nil {
return nil
}
files[filepath.ToSlash(rel)] = []byte{1}
return nil
})
return files
}
func (c *pluginRuntime) list() []PluginView {