-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
323 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ const ( | |
OK = "OK" | ||
DebugOff = 0 | ||
DebugOn = 1 | ||
Version = "1.5.70" | ||
Version = "1.5.71" | ||
) | ||
|
||
type DebugSwitch int8 |
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,175 @@ | ||
package wechat | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/go-pay/gopay/pkg/util" | ||
) | ||
|
||
// 获取对私银行卡号开户银行 | ||
// 注意:accountNo 需此方法加密:client.V3EncryptText() | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_1.shtml | ||
func (c *ClientV3) V3BankSearchBank(ctx context.Context, accountNo string) (wxRsp *BankSearchBankRsp, err error) { | ||
uri := v3BankSearchBank + "?account_number=" + accountNo | ||
authorization, err := c.authorization(MethodGet, uri, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdGet(ctx, uri, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &BankSearchBankRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(BankSearchBank) | ||
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) | ||
} | ||
|
||
// 查询支持个人业务的银行列表 | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_2.shtml | ||
func (c *ClientV3) V3BankSearchPersonalList(ctx context.Context, limit, offset int) (wxRsp *BankSearchPersonalListRsp, err error) { | ||
if limit == 0 { | ||
limit = 20 | ||
} | ||
uri := v3BankSearchPersonalList + "&limit=" + util.Int2String(limit) + "&offset=" + util.Int2String(offset) | ||
authorization, err := c.authorization(MethodGet, uri, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdGet(ctx, uri, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &BankSearchPersonalListRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(BankSearchList) | ||
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) | ||
} | ||
|
||
// 查询支持对公业务的银行列表 | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_3.shtml | ||
func (c *ClientV3) V3BankSearchCorporateList(ctx context.Context, limit, offset int) (wxRsp *BankSearchCorporateListRsp, err error) { | ||
if limit == 0 { | ||
limit = 20 | ||
} | ||
uri := v3BankSearchCorporateList + "&limit=" + util.Int2String(limit) + "&offset=" + util.Int2String(offset) | ||
authorization, err := c.authorization(MethodGet, uri, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdGet(ctx, uri, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &BankSearchCorporateListRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(BankSearchList) | ||
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) | ||
} | ||
|
||
// 查询省份列表 | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_4.shtml | ||
func (c *ClientV3) V3BankSearchProvinceList(ctx context.Context) (wxRsp *BankSearchProvinceListRsp, err error) { | ||
authorization, err := c.authorization(MethodGet, v3BankSearchProvinceList, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdGet(ctx, v3BankSearchProvinceList, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &BankSearchProvinceListRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(BankSearchProvince) | ||
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) | ||
} | ||
|
||
// 查询城市列表 | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_5.shtml | ||
func (c *ClientV3) V3BankSearchCityList(ctx context.Context, provinceCode int) (wxRsp *BankSearchCityListRsp, err error) { | ||
url := fmt.Sprintf(v3BankSearchCityList, provinceCode) | ||
authorization, err := c.authorization(MethodGet, url, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdGet(ctx, url, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &BankSearchCityListRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(BankSearchCity) | ||
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) | ||
} | ||
|
||
// 查询支行列表 | ||
// Code = 0 is success | ||
// 服务商文档:https://pay.weixin.qq.com/wiki/doc/apiv3_partner/Offline/apis/chapter11_2_6.shtml | ||
func (c *ClientV3) V3BankSearchBranchList(ctx context.Context, bankAliasCode string, cityCode, limit, offset int) (wxRsp *BankSearchBranchListRsp, err error) { | ||
if limit == 0 { | ||
limit = 20 | ||
} | ||
uri := fmt.Sprintf(v3BankSearchBranchList, bankAliasCode) + "?city_code=" + util.Int2String(cityCode) + "&limit=" + util.Int2String(limit) + "&offset=" + util.Int2String(offset) | ||
authorization, err := c.authorization(MethodGet, uri, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
res, si, bs, err := c.doProdGet(ctx, uri, authorization) | ||
if err != nil { | ||
return nil, err | ||
} | ||
wxRsp = &BankSearchBranchListRsp{Code: Success, SignInfo: si} | ||
wxRsp.Response = new(BankSearchBranch) | ||
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) | ||
} |
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
Oops, something went wrong.