From 673859b9230c4252dc428d6da51778568d38e946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Mon, 2 Sep 2024 11:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=BA=A2=E5=8C=85=20todo=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=8A=A0=E8=BD=BD=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main.go | 4 ++-- cmd/wechat_redpack.go | 6 +++--- utils/wechat/client.go | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 3cc0781..66a41f1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -2,6 +2,6 @@ package main // main 这只是一个演示 func main() { - wechatCpn() - //wechatRedPack() + //wechatCpn() + wechatRedPack() } diff --git a/cmd/wechat_redpack.go b/cmd/wechat_redpack.go index ed52f65..a6134fe 100644 --- a/cmd/wechat_redpack.go +++ b/cmd/wechat_redpack.go @@ -37,9 +37,9 @@ func wechatRedPack() { Config: getWechatRedPackConf(), Order: &proto.QueryRequest_Order{ OrderNo: "", - TradeNo: "69445765514", - Account: "oO3vO5AxRWgTjmMD38FTvnB5Rq6o", - Extra: []byte(`{"app_id":"wx9ed74283ad25bca1"}`), + TradeNo: "202408211517304392270563", + Account: "", + Extra: []byte(`{"out_detail_no":"20240821151730439227056399842027"}`), }, } resQuery, err := instance.Query(context.Background(), wechatRedPackConf.Tag, queryRequest) diff --git a/utils/wechat/client.go b/utils/wechat/client.go index 5924801..4415dfd 100644 --- a/utils/wechat/client.go +++ b/utils/wechat/client.go @@ -2,6 +2,7 @@ package wechat import ( "context" + "crypto/x509" "fmt" "github.com/wechatpay-apiv3/wechatpay-go/core" "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), } // 微信支付平台配置 - ////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 { - // return nil, fmt.Errorf("MchID[%s] load pay certificate error:%v", c.MchID, err) - //} - //opts = append(opts, option.WithWechatPayCertificate([]*x509.Certificate{payCert})) + payCert, err := utils.LoadCertificateWithPath(fmt.Sprintf("%s/%s", filePath, "wechat_cert.pem")) + if err != nil { + return nil, fmt.Errorf("MchID[%s] load pay certificate error:%v", c.MchID, err) + } + opts = append(opts, option.WithWechatPayCertificate([]*x509.Certificate{payCert})) client, err := core.NewClient(ctx, opts...) if err != nil { return nil, fmt.Errorf("MchID[%s] %v", c.MchID, err)