refactor(payment): 支付插件 - 宿主仅通过 RPC 包加载并保护订单版本
This commit is contained in:
1 parent
d6bbdbe27b
commit
38e715ea3f
45 files changed
+1584
-203
No files matched your search
@@ -1,15 +1,14 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"infinite-canvas/backend/internal/payment"
|
||||
"infinite-canvas/backend/internal/protocol"
|
||||
)
|
||||
|
||||
const (
|
||||
PaymentPluginWeChatNative = payment.PluginWeChatNative
|
||||
PaymentPluginAlipayPage = payment.PluginAlipayPage
|
||||
PaymentProviderWeChat = payment.ProviderWeChatNative
|
||||
PaymentProviderAlipay = payment.ProviderAlipayPage
|
||||
PaymentPluginWeChatNative = "official-payment-wechat-native"
|
||||
PaymentPluginAlipayPage = "official-payment-alipay-page"
|
||||
PaymentProviderWeChat = "wechat-native"
|
||||
PaymentProviderAlipay = "alipay-page-pay"
|
||||
)
|
||||
|
||||
func bundledPaymentPluginManifests() []protocol.Manifest {
|
||||
@@ -53,11 +52,38 @@ func paymentPluginManifest(pluginID, providerID, name, vendor, description, runt
|
||||
Configuration: configuration,
|
||||
Contributes: protocol.ManifestContributions{PaymentProviders: []protocol.ManifestPaymentProvider{{
|
||||
ID: providerID, Label: name, Icon: icon, CheckoutMode: checkoutMode,
|
||||
IdentityFields: paymentIdentityFields(providerID),
|
||||
NotificationSuccess: paymentNotificationSuccess(providerID), NotificationFailure: paymentNotificationFailure(providerID),
|
||||
ExpiryPolicy: protocol.ManifestPaymentExpiryPolicy{DefaultMinutes: 30, MinMinutes: 5, MaxMinutes: 1440},
|
||||
}}},
|
||||
}
|
||||
}
|
||||
|
||||
func paymentIdentityFields(providerID string) []string {
|
||||
switch providerID {
|
||||
case PaymentProviderWeChat:
|
||||
return []string{"appId", "mchId"}
|
||||
case PaymentProviderAlipay:
|
||||
return []string{"appId", "sellerId"}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func paymentNotificationSuccess(providerID string) protocol.ManifestPaymentResponse {
|
||||
if providerID == PaymentProviderAlipay {
|
||||
return protocol.ManifestPaymentResponse{Status: 200, ContentType: "text/plain; charset=utf-8", Body: "success"}
|
||||
}
|
||||
return protocol.ManifestPaymentResponse{Status: 204}
|
||||
}
|
||||
|
||||
func paymentNotificationFailure(providerID string) protocol.ManifestPaymentResponse {
|
||||
if providerID == PaymentProviderAlipay {
|
||||
return protocol.ManifestPaymentResponse{Status: 400, ContentType: "text/plain; charset=utf-8", Body: "failure"}
|
||||
}
|
||||
return protocol.ManifestPaymentResponse{Status: 400}
|
||||
}
|
||||
|
||||
func wechatPaymentConfiguration() protocol.ManifestConfiguration {
|
||||
return protocol.ManifestConfiguration{Fields: []protocol.ManifestField{
|
||||
{Name: "publicBaseUrl", Type: "url", Label: "服务器公网地址", Required: true, Description: "用于生成微信支付回调地址,必须可被微信访问。"},
|
||||
|
||||
Reference in new issue
Block a user