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)