Skip to content

Commit

Permalink
微信刷掌返回参数解析处理 (#440)
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
laogeng660 authored Dec 24, 2024
1 parent 386e590 commit b42e015
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions wechat/v3/palm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package wechat

import (
"context"
"encoding/json"
"fmt"
"net/http"

"github.com/go-pay/gopay"
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b42e015

Please sign in to comment.