微信红包 todo 插件加载证书
This commit is contained in:
parent
740d48d4fe
commit
673859b923
|
@ -2,6 +2,6 @@ package main
|
||||||
|
|
||||||
// main 这只是一个演示
|
// main 这只是一个演示
|
||||||
func main() {
|
func main() {
|
||||||
wechatCpn()
|
//wechatCpn()
|
||||||
//wechatRedPack()
|
wechatRedPack()
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ func wechatRedPack() {
|
||||||
Config: getWechatRedPackConf(),
|
Config: getWechatRedPackConf(),
|
||||||
Order: &proto.QueryRequest_Order{
|
Order: &proto.QueryRequest_Order{
|
||||||
OrderNo: "",
|
OrderNo: "",
|
||||||
TradeNo: "69445765514",
|
TradeNo: "202408211517304392270563",
|
||||||
Account: "oO3vO5AxRWgTjmMD38FTvnB5Rq6o",
|
Account: "",
|
||||||
Extra: []byte(`{"app_id":"wx9ed74283ad25bca1"}`),
|
Extra: []byte(`{"out_detail_no":"20240821151730439227056399842027"}`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
resQuery, err := instance.Query(context.Background(), wechatRedPackConf.Tag, queryRequest)
|
resQuery, err := instance.Query(context.Background(), wechatRedPackConf.Tag, queryRequest)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package wechat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||||
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
||||||
|
@ -34,12 +35,11 @@ func newClient(ctx context.Context, c *Server) (*core.Client, error) {
|
||||||
option.WithWechatPayAutoAuthCipher(c.MchID, c.MchCertificateSerialNumber, mchPrivateKey, c.MchAPIv3Key),
|
option.WithWechatPayAutoAuthCipher(c.MchID, c.MchCertificateSerialNumber, mchPrivateKey, c.MchAPIv3Key),
|
||||||
}
|
}
|
||||||
// 微信支付平台配置
|
// 微信支付平台配置
|
||||||
////payCert, err := utils.LoadCertificateWithPath(fmt.Sprintf("%s/%s", filePath, "wechat_cert.pem"))
|
payCert, err := utils.LoadCertificateWithPath(fmt.Sprintf("%s/%s", filePath, "wechat_cert.pem"))
|
||||||
//payCert, err := utils.LoadCertificateWithPath(fmt.Sprintf("%s/%s", filePath, "wechatpay_2C10BB073B55C2191DF46CE443DA8B9064AB7F60.pem"))
|
if err != nil {
|
||||||
//if err != nil {
|
return nil, fmt.Errorf("MchID[%s] load pay certificate error:%v", c.MchID, err)
|
||||||
// return nil, fmt.Errorf("MchID[%s] load pay certificate error:%v", c.MchID, err)
|
}
|
||||||
//}
|
opts = append(opts, option.WithWechatPayCertificate([]*x509.Certificate{payCert}))
|
||||||
//opts = append(opts, option.WithWechatPayCertificate([]*x509.Certificate{payCert}))
|
|
||||||
client, err := core.NewClient(ctx, opts...)
|
client, err := core.NewClient(ctx, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("MchID[%s] %v", c.MchID, err)
|
return nil, fmt.Errorf("MchID[%s] %v", c.MchID, err)
|
||||||
|
|
Loading…
Reference in New Issue