添加微信支付支持,重构资源创建逻辑,更新支付宝相关配置,移除账单状态字段

This commit is contained in:
2025-04-17 18:29:44 +08:00
parent 2146887f95
commit f6a97545c5
20 changed files with 607 additions and 495 deletions

View File

@@ -23,7 +23,7 @@ func InitAlipay() {
panic("加载支付宝公钥失败: " + err.Error())
}
err = client.SetEncryptKey(env.AlipayEncryptKey)
err = client.SetEncryptKey(env.AlipayApiCert)
if err != nil {
panic("设置支付宝加密密钥失败: " + err.Error())
}

47
web/globals/wechat.go Normal file
View File

@@ -0,0 +1,47 @@
package globals
import (
"context"
"platform/pkg/env"
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/native"
"github.com/wechatpay-apiv3/wechatpay-go/utils"
)
var WechatPay *WechatPayClient
type WechatPayClient struct {
Native *native.NativeApiService
}
func InitWechatPay() {
appPrivateKey, err := utils.LoadPrivateKey(env.WechatPayMchPrivateKeyPath)
if err != nil {
panic(err)
}
wechatPublicKey, err := utils.LoadPublicKey(env.WechatPayPublicKeyPath)
if err != nil {
panic(err)
}
client, err := core.NewClient(context.Background(),
option.WithWechatPayPublicKeyAuthCipher(
env.WechatPayMchId,
env.WechatPayMchPrivateKeySerial,
appPrivateKey,
env.WechatPayPublicKeyId,
wechatPublicKey,
),
)
if err != nil {
panic(err)
}
WechatPay = &WechatPayClient{
Native: &native.NativeApiService{Client: client},
}
}