Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	release_note.txt
  • Loading branch information
iGoogle-ink committed Jun 27, 2024
2 parents 979e7e7 + 17ae5dd commit 8755898
Show file tree
Hide file tree
Showing 20 changed files with 780 additions and 103 deletions.
Binary file modified .github/wx_gopay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ QQ群:
<img width="280" height="280" src=".github/qq_gopay.png"/>
微信群:
<img width="280" height="280" src=".github/wx_gopay.png"/>
<br>微信群二维码过期可加微信拉群:
<img width="280" height="280" src=".github/wechat_jerry.png"/>

---

Expand Down
65 changes: 65 additions & 0 deletions alipay/ant.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,29 @@ func (a *Client) AntMerchantShopQuery(ctx context.Context, bm gopay.BodyMap) (al
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// ant.merchant.expand.shop.page.query(店铺分页查询接口)
// 文档地址:https://opendocs.alipay.com/open/04fgwq
func (a *Client) AntMerchantShopPageQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopPageQueryRsp, err error) {
err = bm.CheckEmptyError("ip_role_id", "page_num", "page_size")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.page.query"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantShopPageQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// ant.merchant.expand.shop.close(蚂蚁店铺关闭)
// 文档地址:https://opendocs.alipay.com/apis/api_1/ant.merchant.expand.shop.close
func (a *Client) AntMerchantShopClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantShopCloseRsp, err error) {
Expand Down Expand Up @@ -158,3 +181,45 @@ func (a *Client) AntMerchantExpandIndirectImageUpload(ctx context.Context, bm go
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// ant.merchant.expand.mcc.query(商户mcc信息查询)
// 文档地址:https://opendocs.alipay.com/open/04fgwu
func (a *Client) AntMerchantExpandMccQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantExpandMccQueryRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.mcc.query"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantExpandMccQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// ant.merchant.expand.shop.receiptaccount.save(店铺增加收单账号)
// 文档地址:https://opendocs.alipay.com/open/54b69b89_ant.merchant.expand.shop.receiptaccount.save
func (a *Client) AntMerchantExpandShopReceiptAccountSave(ctx context.Context, bm gopay.BodyMap) (aliRsp *AntMerchantExpandShopReceiptAccountSaveRsp, err error) {
err = bm.CheckEmptyError("shop_id", "receipt_account_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "ant.merchant.expand.shop.receiptaccount.save"); err != nil {
return nil, err
}
aliRsp = new(AntMerchantExpandShopReceiptAccountSaveRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
5 changes: 5 additions & 0 deletions alipay/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,8 @@ func (a *Client) encryptBizContent(originData string) (string, error) {
}
return base64.StdEncoding.EncodeToString(encryptData), nil
}

// SetHttpClient 设置自定义的xhttp.Client
func (a *Client) SetHttpClient(client *xhttp.Client) {
a.hc = client
}
46 changes: 46 additions & 0 deletions alipay/data_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,52 @@ func (a *Client) DataBillAccountLogQuery(ctx context.Context, bm gopay.BodyMap)
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.data.bill.ereceipt.apply(申请电子回单(incubating))
// 文档地址:https://opendocs.alipay.com/open/1aad1956_alipay.data.bill.ereceipt.apply
func (a *Client) DataBillEreceiptApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillEreceiptApplyRsp, err error) {
err = bm.CheckEmptyError("type", "key")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.ereceipt.apply"); err != nil {
return nil, err
}
aliRsp = new(DataBillEreceiptApplyRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.data.bill.ereceipt.query(查询电子回单状态(incubating))
// 文档地址:https://opendocs.alipay.com/open/30b94a2f_alipay.data.bill.ereceipt.query
func (a *Client) DataBillEreceiptQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillEreceiptQueryRsp, err error) {
err = bm.CheckEmptyError("file_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.ereceipt.query"); err != nil {
return nil, err
}
aliRsp = new(DataBillEreceiptQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.data.dataservice.bill.downloadurl.query(查询对账单下载地址)
// 文档地址:https://opendocs.alipay.com/open/02e7gr
func (a *Client) DataBillDownloadUrlQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillDownloadUrlQueryResponse, err error) {
Expand Down
193 changes: 193 additions & 0 deletions alipay/face.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
package alipay

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

"github.com/go-pay/gopay"
)

// datadigital.fincloud.generalsaas.face.verification.initialize(人脸核身初始化)
// 文档地址:https://opendocs.alipay.com/open/04jg6r
func (a *Client) FaceVerificationInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceVerificationInitializeRsp, err error) {
err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_type", "cert_type", "cert_name", "cert_no")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.verification.initialize"); err != nil {
return nil, err
}
aliRsp = new(FaceVerificationInitializeRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.verification.query(人脸核身结果查询)
// 文档地址:https://opendocs.alipay.com/open/04jg6s
func (a *Client) FaceVerificationQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceVerificationQueryRsp, err error) {
err = bm.CheckEmptyError("certify_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.verification.query"); err != nil {
return nil, err
}
aliRsp = new(FaceVerificationQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.certify.initialize(H5人脸核身初始化)
// 文档地址:https://opendocs.alipay.com/open/02zloa
func (a *Client) FaceCertifyInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyInitializeRsp, err error) {
err = bm.CheckEmptyError("outer_order_no", "biz_code", "identity_param", "merchant_config")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.initialize"); err != nil {
return nil, err
}
aliRsp = new(FaceCertifyInitializeRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.certify.verify(H5人脸核身开始认证)
// 文档地址:https://opendocs.alipay.com/open/02zlob
func (a *Client) FaceCertifyVerify(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyVerifyRsp, err error) {
err = bm.CheckEmptyError("certify_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.verify"); err != nil {
return nil, err
}
aliRsp = new(FaceCertifyVerifyRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.certify.query(H5人脸核身查询记录)
// 文档地址:https://opendocs.alipay.com/open/02zloc
func (a *Client) FaceCertifyQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCertifyQueryRsp, err error) {
err = bm.CheckEmptyError("certify_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.certify.query"); err != nil {
return nil, err
}
aliRsp = new(FaceCertifyQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.source.certify(纯服务端人脸核身)
// 文档地址:https://opendocs.alipay.com/open/04pxq6
func (a *Client) FaceSourceCertify(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceSourceCertifyRsp, err error) {
err = bm.CheckEmptyError("outer_biz_no", "cert_type", "cert_no", "cert_name")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.source.certify"); err != nil {
return nil, err
}
aliRsp = new(FaceSourceCertifyRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.check.initialize(活体检测初始化)
// 文档地址:https://opendocs.alipay.com/open/03nisu
func (a *Client) FaceCheckInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCheckInitializeRsp, err error) {
err = bm.CheckEmptyError("outer_order_no", "biz_code")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.check.initialize"); err != nil {
return nil, err
}
aliRsp = new(FaceCheckInitializeRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// datadigital.fincloud.generalsaas.face.check.query(活体检测结果查询)
// 文档地址:https://opendocs.alipay.com/open/03nisv
func (a *Client) FaceCheckQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *FaceCheckQueryRsp, err error) {
err = bm.CheckEmptyError("certify_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.face.check.query"); err != nil {
return nil, err
}
aliRsp = new(FaceCheckQueryRsp)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}
Loading

0 comments on commit 8755898

Please sign in to comment.