Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信刷掌返回参数解析处理 #440

Merged
merged 4 commits into from
Dec 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading