微信支付密钥使用 base64 字符串替换文件配置
This commit is contained in:
@@ -2,6 +2,7 @@ package globals
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"platform/pkg/env"
|
||||
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
@@ -21,13 +22,24 @@ type WechatPayClient struct {
|
||||
|
||||
func InitWechatPay() {
|
||||
|
||||
// 加载 rsa 密钥文件
|
||||
appPrivateKey, err := utils.LoadPrivateKeyWithPath(env.WechatPayMchPrivateKeyPath)
|
||||
// 加载商户私钥
|
||||
private, err := base64.StdEncoding.DecodeString(env.WechatPayMchPrivateKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
wechatPublicKey, err := utils.LoadPublicKeyWithPath(env.WechatPayPublicKeyPath)
|
||||
appPrivateKey, err := utils.LoadPrivateKey(string(private))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 加载微信支付公钥
|
||||
public, err := base64.StdEncoding.DecodeString(env.WechatPayPublicKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
wechatPublicKey, err := utils.LoadPublicKey(string(public))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
Reference in New Issue
Block a user