feat: add online payment management and checkout
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
2026-10-15 09:26:40 +08:00
parent 5353a4a128
commit dc2efcde08
41 changed files with 4855 additions and 21 deletions

View File

@@ -11,15 +11,16 @@ import (
)
type Config struct {
HTTPAddr string
TrustedProxies []string
ReadHeaderTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
ShutdownTimeout time.Duration
SigningPrivateKeyPEM string
CredentialEncryptionKey []byte
HTTPAddr string
TrustedProxies []string
ReadHeaderTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
ShutdownTimeout time.Duration
SigningPrivateKeyPEM string
CredentialEncryptionKey []byte
PaymentConfigEncryptionKey []byte
}
func Load(getenv func(string) string) (Config, error) {
@@ -96,6 +97,16 @@ func Load(getenv func(string) string) (Config, error) {
}
c.CredentialEncryptionKey = data
}
if path := getenv("PAYMENT_CONFIG_ENCRYPTION_KEY_FILE"); path != "" {
if !filepath.IsAbs(path) {
return Config{}, fmt.Errorf("PAYMENT_CONFIG_ENCRYPTION_KEY_FILE must be absolute")
}
data, err := os.ReadFile(path)
if err != nil || len(data) != 32 {
return Config{}, fmt.Errorf("payment config encryption key must be exactly 32 raw bytes")
}
c.PaymentConfigEncryptionKey = data
}
if root := getenv("PACKAGE_STORAGE_ROOT"); root != "" {
if !filepath.IsAbs(root) {
return Config{}, fmt.Errorf("PACKAGE_STORAGE_ROOT must be absolute")