From b42e01509adf23ae52fd8670592b4d0939918b44 Mon Sep 17 00:00:00 2001 From: laogeng660 <140534298+laogeng660@users.noreply.github.com> Date: Tue, 24 Dec 2024 14:34:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=88=B7=E6=8E=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90=E5=A4=84=E7=90=86?= =?UTF-8?q?=20(#440)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix --- wechat/v3/palm.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wechat/v3/palm.go b/wechat/v3/palm.go index b32f0805..091a5123 100644 --- a/wechat/v3/palm.go +++ b/wechat/v3/palm.go @@ -2,6 +2,8 @@ package wechat import ( "context" + "encoding/json" + "fmt" "net/http" "github.com/go-pay/gopay" @@ -19,6 +21,10 @@ func (c *ClientV3) V3PalmServicePreAuthorize(ctx context.Context, bm gopay.BodyM return nil, err } wxRsp = &PalmServicePreAuthorizeRsp{Code: Success, SignInfo: si} + wxRsp.Response = new(PalmServicePreAuthorize) + if err = json.Unmarshal(bs, wxRsp.Response); err != nil { + return nil, fmt.Errorf("[%w]: %v, bytes: %s", gopay.UnmarshalErr, err, string(bs)) + } if res.StatusCode != http.StatusOK { wxRsp.Code = res.StatusCode wxRsp.Error = string(bs) @@ -29,8 +35,8 @@ func (c *ClientV3) V3PalmServicePreAuthorize(ctx context.Context, bm gopay.BodyM // 预授权状态查询 // Code = 0 is success -func (c *ClientV3) V3PalmServiceOpenidQuery(ctx context.Context, bm gopay.BodyMap) (wxRsp *PalmServiceOpenidQueryRsp, err error) { - uri := v3PalmServiceOpenidQuery + "?" + bm.EncodeURLParams() +func (c *ClientV3) V3PalmServiceOpenidQuery(ctx context.Context, openid, organizationId string) (wxRsp *PalmServiceOpenidQueryRsp, err error) { + uri := fmt.Sprintf(v3PalmServiceOpenidQuery, openid) + "?organization_id=" + organizationId authorization, err := c.authorization(MethodGet, uri, nil) if err != nil { return nil, err @@ -40,6 +46,10 @@ func (c *ClientV3) V3PalmServiceOpenidQuery(ctx context.Context, bm gopay.BodyMa return nil, err } wxRsp = &PalmServiceOpenidQueryRsp{Code: Success, SignInfo: si} + wxRsp.Response = new(PalmServiceOpenidQuery) + if err = json.Unmarshal(bs, wxRsp.Response); err != nil { + return nil, fmt.Errorf("[%w]: %v, bytes: %s", gopay.UnmarshalErr, err, string(bs)) + } if res.StatusCode != http.StatusOK { wxRsp.Code = res.StatusCode wxRsp.Error = string(bs)