添加微信支付支持,重构资源创建逻辑,更新支付宝相关配置,移除账单状态字段
This commit is contained in:
@@ -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
47
web/globals/wechat.go
Normal 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},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user