feat(payment): 新增微信支付宝积分充值与对账
This commit is contained in:
1 parent
52158da7c2
commit
669b83b2f8
41 files changed
+6401
-136
No files matched your search
@@ -258,7 +258,7 @@ func ValidateManifest(manifest Manifest) error {
|
||||
return fmt.Errorf("plugin must declare at least one contribution")
|
||||
}
|
||||
if len(manifest.Contributes.Providers) == 0 {
|
||||
return nil
|
||||
return validatePaymentProviderContributions(manifest)
|
||||
}
|
||||
providerIDs := make(map[string]struct{}, len(manifest.Contributes.Providers))
|
||||
for index, provider := range manifest.Contributes.Providers {
|
||||
@@ -316,6 +316,33 @@ func ValidateManifest(manifest Manifest) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
return validatePaymentProviderContributions(manifest)
|
||||
}
|
||||
|
||||
func validatePaymentProviderContributions(manifest Manifest) error {
|
||||
seen := make(map[string]struct{}, len(manifest.Contributes.PaymentProviders))
|
||||
for index, provider := range manifest.Contributes.PaymentProviders {
|
||||
provider.ID = strings.TrimSpace(provider.ID)
|
||||
if provider.ID == "" || strings.TrimSpace(provider.Label) == "" || !validManifestIdentifier(provider.ID) {
|
||||
return fmt.Errorf("payment provider contribution %d requires a valid id and label", index)
|
||||
}
|
||||
if _, exists := seen[provider.ID]; exists {
|
||||
return fmt.Errorf("duplicate payment provider contribution %q", provider.ID)
|
||||
}
|
||||
seen[provider.ID] = struct{}{}
|
||||
if strings.TrimSpace(provider.Icon) == "" {
|
||||
return fmt.Errorf("payment provider contribution %q requires an icon", provider.ID)
|
||||
}
|
||||
switch provider.CheckoutMode {
|
||||
case "qr_code", "redirect":
|
||||
default:
|
||||
return fmt.Errorf("payment provider contribution %q has unsupported checkout mode %q", provider.ID, provider.CheckoutMode)
|
||||
}
|
||||
policy := provider.ExpiryPolicy
|
||||
if policy.MinMinutes <= 0 || policy.DefaultMinutes < policy.MinMinutes || policy.MaxMinutes < policy.DefaultMinutes {
|
||||
return fmt.Errorf("payment provider contribution %q has invalid expiry policy", provider.ID)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -358,7 +385,7 @@ func normalizeManifestForProvider(manifest *Manifest, index int) error {
|
||||
}
|
||||
|
||||
func hasNonProviderContribution(contributes ManifestContributions) bool {
|
||||
return len(contributes.Workflows) > 0 || len(contributes.CanvasNodes) > 0 || len(contributes.Transforms) > 0 || len(contributes.Commands) > 0 || len(contributes.AssetSources) > 0 || len(contributes.UsageObservers) > 0 || len(contributes.AICapabilities) > 0 || len(contributes.Agents) > 0 || len(contributes.ImportExport) > 0
|
||||
return len(contributes.PaymentProviders) > 0 || len(contributes.Workflows) > 0 || len(contributes.CanvasNodes) > 0 || len(contributes.Transforms) > 0 || len(contributes.Commands) > 0 || len(contributes.AssetSources) > 0 || len(contributes.UsageObservers) > 0 || len(contributes.AICapabilities) > 0 || len(contributes.Agents) > 0 || len(contributes.ImportExport) > 0
|
||||
}
|
||||
|
||||
func operationSummary(operation ManifestOperation) string {
|
||||
|
||||
@@ -279,22 +279,38 @@ type ManifestField struct {
|
||||
Type string `json:"type"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
Secret bool `json:"secret,omitempty"`
|
||||
Default any `json:"default,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Values []string `json:"values,omitempty"`
|
||||
}
|
||||
|
||||
type ManifestContributions struct {
|
||||
Providers []ManifestProvider `json:"providers,omitempty"`
|
||||
Workflows []ManifestWorkflow `json:"workflows,omitempty"`
|
||||
CanvasNodes []ManifestCanvasNode `json:"canvasNodes,omitempty"`
|
||||
Transforms []ManifestTransform `json:"transforms,omitempty"`
|
||||
Commands []ManifestCommand `json:"commands,omitempty"`
|
||||
AssetSources []string `json:"assetSources,omitempty"`
|
||||
UsageObservers []string `json:"usageObservers,omitempty"`
|
||||
AICapabilities []string `json:"aiCapabilities,omitempty"`
|
||||
Agents []string `json:"agents,omitempty"`
|
||||
ImportExport []string `json:"importExport,omitempty"`
|
||||
Providers []ManifestProvider `json:"providers,omitempty"`
|
||||
PaymentProviders []ManifestPaymentProvider `json:"paymentProviders,omitempty"`
|
||||
Workflows []ManifestWorkflow `json:"workflows,omitempty"`
|
||||
CanvasNodes []ManifestCanvasNode `json:"canvasNodes,omitempty"`
|
||||
Transforms []ManifestTransform `json:"transforms,omitempty"`
|
||||
Commands []ManifestCommand `json:"commands,omitempty"`
|
||||
AssetSources []string `json:"assetSources,omitempty"`
|
||||
UsageObservers []string `json:"usageObservers,omitempty"`
|
||||
AICapabilities []string `json:"aiCapabilities,omitempty"`
|
||||
Agents []string `json:"agents,omitempty"`
|
||||
ImportExport []string `json:"importExport,omitempty"`
|
||||
}
|
||||
|
||||
type ManifestPaymentProvider struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Icon string `json:"icon"`
|
||||
CheckoutMode string `json:"checkoutMode"`
|
||||
ExpiryPolicy ManifestPaymentExpiryPolicy `json:"expiryPolicy"`
|
||||
}
|
||||
|
||||
type ManifestPaymentExpiryPolicy struct {
|
||||
DefaultMinutes int `json:"defaultMinutes"`
|
||||
MinMinutes int `json:"minMinutes"`
|
||||
MaxMinutes int `json:"maxMinutes"`
|
||||
}
|
||||
|
||||
type ManifestProvider struct {
|
||||
|
||||
Reference in new issue
Block a user