-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42e2b0e
commit 3f25b44
Showing
13 changed files
with
224 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package wechat | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/go-pay/gopay" | ||
) | ||
|
||
// 点金计划管理API | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_5_1.shtml | ||
func (c *ClientV3) V3GoldPlanManage(ctx context.Context, bm gopay.BodyMap) (wxRsp *GoldPlanManageRsp, err error) { | ||
authorization, err := c.authorization(MethodPost, v3GoldPlanManage, bm) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdPost(ctx, bm, v3GoldPlanManage, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &GoldPlanManageRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(GoldPlanManage) | ||
if err = json.Unmarshal(bs, wxRsp.Response); err != nil { | ||
return nil, fmt.Errorf("json.Unmarshal(%s):%w", string(bs), err) | ||
} | ||
if res.StatusCode != http.StatusOK { | ||
wxRsp.Code = res.StatusCode | ||
wxRsp.Error = string(bs) | ||
return wxRsp, nil | ||
} | ||
return wxRsp, c.verifySyncSign(si) | ||
} | ||
|
||
// 商家小票管理API | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_5_2.shtml | ||
func (c *ClientV3) V3GoldPlanBillManage(ctx context.Context, bm gopay.BodyMap) (wxRsp *GoldPlanManageRsp, err error) { | ||
authorization, err := c.authorization(MethodPost, v3GoldPlanBillManage, bm) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdPost(ctx, bm, v3GoldPlanBillManage, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &GoldPlanManageRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(GoldPlanManage) | ||
if err = json.Unmarshal(bs, wxRsp.Response); err != nil { | ||
return nil, fmt.Errorf("json.Unmarshal(%s):%w", string(bs), err) | ||
} | ||
if res.StatusCode != http.StatusOK { | ||
wxRsp.Code = res.StatusCode | ||
wxRsp.Error = string(bs) | ||
return wxRsp, nil | ||
} | ||
return wxRsp, c.verifySyncSign(si) | ||
} | ||
|
||
// 同业过滤标签管理API | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_5_3.shtml | ||
func (c *ClientV3) V3GoldPlanFilterManage(ctx context.Context, bm gopay.BodyMap) (wxRsp *EmptyRsp, err error) { | ||
authorization, err := c.authorization(MethodPost, v3GoldPlanFilterManage, bm) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdPost(ctx, bm, v3GoldPlanFilterManage, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &EmptyRsp{Code: Success, SignInfo: si} | ||
if res.StatusCode != http.StatusNoContent { | ||
wxRsp.Code = res.StatusCode | ||
wxRsp.Error = string(bs) | ||
return wxRsp, nil | ||
} | ||
return wxRsp, c.verifySyncSign(si) | ||
} | ||
|
||
// 开通广告展示API | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_5_4.shtml | ||
func (c *ClientV3) V3GoldPlanOpenAdShow(ctx context.Context, bm gopay.BodyMap) (wxRsp *EmptyRsp, err error) { | ||
authorization, err := c.authorization(MethodPATCH, v3GoldPlanOpenAdShow, bm) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdPatch(ctx, bm, v3GoldPlanOpenAdShow, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &EmptyRsp{Code: Success, SignInfo: si} | ||
if res.StatusCode != http.StatusNoContent { | ||
wxRsp.Code = res.StatusCode | ||
wxRsp.Error = string(bs) | ||
return wxRsp, nil | ||
} | ||
return wxRsp, c.verifySyncSign(si) | ||
} | ||
|
||
// 关闭广告展示API | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_5_5.shtml | ||
func (c *ClientV3) V3GoldPlanCloseAdShow(ctx context.Context, bm gopay.BodyMap) (wxRsp *EmptyRsp, err error) { | ||
authorization, err := c.authorization(MethodPATCH, v3GoldPlanCloseAdShow, bm) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdPost(ctx, bm, v3GoldPlanCloseAdShow, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &EmptyRsp{Code: Success, SignInfo: si} | ||
if res.StatusCode != http.StatusNoContent { | ||
wxRsp.Code = res.StatusCode | ||
wxRsp.Error = string(bs) | ||
return wxRsp, nil | ||
} | ||
return wxRsp, c.verifySyncSign(si) | ||
} |
Oops, something went wrong.