Skip to content

Commit

Permalink
add new api
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed Jun 20, 2024
1 parent c513033 commit 0fb8a12
Show file tree
Hide file tree
Showing 10 changed files with 722 additions and 83 deletions.
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)
}
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)
}
65 changes: 0 additions & 65 deletions alipay/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,71 +206,6 @@ type MonitorHeartbeatSynRes struct {
Pid string `json:"pid"`
}

// ===================================================
type DataBillBalanceQueryResponse struct {
Response *DataBillBalanceQuery `json:"alipay_data_bill_balance_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type DataBillBalanceQuery struct {
ErrorResponse
TotalAmount string `json:"total_amount,omitempty"`
AvailableAmount string `json:"available_amount,omitempty"`
FreezeAmount string `json:"freeze_amount,omitempty"`
SettleAmount string `json:"settle_amount,omitempty"`
}

// ===================================================
type DataBillAccountLogQueryResponse struct {
Response *DataBillAccountLogQuery `json:"alipay_data_bill_accountlog_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type DataBillAccountLogQuery struct {
ErrorResponse
PageNo string `json:"page_no,omitempty"`
PageSize string `json:"page_size,omitempty"`
TotalSize string `json:"total_size,omitempty"`
DetailList []AccountLogItemResult `json:"detail_list,omitempty"`
}

type AccountLogItemResult struct {
TransDt string `json:"trans_dt,omitempty"`
AccountLogId string `json:"account_log_id,omitempty"`
AlipayOrderNo string `json:"alipay_order_no,omitempty"`
MerchantOrderNo string `json:"merchant_order_no,omitempty"`
TransAmount string `json:"trans_amount,omitempty"`
Balance string `json:"balance,omitempty"`
Type string `json:"type,omitempty"`
OtherAccount string `json:"other_account,omitempty"`
TransMemo string `json:"trans_memo,omitempty"`
Direction string `json:"direction,omitempty"`
BillSource string `json:"bill_source,omitempty"`
BizNos string `json:"biz_nos,omitempty"`
BizOrigNo string `json:"biz_orig_no,omitempty"`
BizDesc string `json:"biz_desc,omitempty"`
MerchantOutRefundNo string `json:"merchant_out_refund_no,omitempty"`
ComplementInfo string `json:"complement_info,omitempty"`
StoreName string `json:"store_name,omitempty"`
}

// ===================================================
type DataBillDownloadUrlQueryResponse struct {
Response *DataBillDownloadUrlQuery `json:"alipay_data_dataservice_bill_downloadurl_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type DataBillDownloadUrlQuery struct {
ErrorResponse
BillDownloadUrl string `json:"bill_download_url,omitempty"`
}

// ===================================================
type PublicCertDownloadRsp struct {
Response *PublicCertDownload `json:"alipay_open_app_alipaycert_download_response"`
Expand Down
Loading

0 comments on commit 0fb8a12

Please sign in to comment.