diff --git a/alipay/ant.go b/alipay/ant.go index df72723d..b5ba621e 100644 --- a/alipay/ant.go +++ b/alipay/ant.go @@ -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) { @@ -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) +} diff --git a/alipay/data_api.go b/alipay/data_api.go index 69c5090f..9112b3b7 100644 --- a/alipay/data_api.go +++ b/alipay/data_api.go @@ -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) { diff --git a/alipay/face.go b/alipay/face.go new file mode 100644 index 00000000..850606fa --- /dev/null +++ b/alipay/face.go @@ -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) +} diff --git a/alipay/model.go b/alipay/model.go index 8016730a..62e212c9 100644 --- a/alipay/model.go +++ b/alipay/model.go @@ -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"` diff --git a/alipay/model_ant.go b/alipay/model_ant.go index a464ae37..dbecc857 100644 --- a/alipay/model_ant.go +++ b/alipay/model_ant.go @@ -35,6 +35,13 @@ type AntMerchantShopQueryRsp struct { Sign string `json:"sign"` } +type AntMerchantShopPageQueryRsp struct { + Response *AntMerchantShopPageQuery `json:"ant_merchant_expand_shop_page_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + type AntMerchantShopCloseRsp struct { Response *AntMerchantShopClose `json:"ant_merchant_expand_shop_close_response"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` @@ -49,6 +56,20 @@ type AntMerchantExpandIndirectImageUploadRsp struct { Sign string `json:"sign"` } +type AntMerchantExpandMccQueryRsp struct { + Response *AntMerchantExpandMccQuery `json:"ant_merchant_expand_mcc_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type AntMerchantExpandShopReceiptAccountSaveRsp struct { + Response *AntMerchantExpandShopReceiptAccountSave `json:"ant_merchant_expand_shop_receiptaccount_save_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + // =========================================================分割========================================================= type AntMerchantShopModify struct { @@ -142,3 +163,61 @@ type AntMerchantExpandIndirectImageUpload struct { ErrorResponse ImageId string `json:"image_id"` } + +type AntMerchantShopPageQuery struct { + ErrorResponse + ShopInfos []*AntShopInfo `json:"shop_infos"` + TotalPages int `json:"total_pages"` + AlipayPoiid string `json:"alipay_poiid"` +} + +type AntShopInfo struct { + ShopId string `json:"shop_id"` + BusinessAddress *BusinessAddress `json:"business_address"` + ShopCategory string `json:"shop_category"` + NewShopCategory string `json:"new_shop_category"` + StoreId string `json:"store_id"` + ShopType string `json:"shop_type"` + ShopName string `json:"shop_name"` + ContactPhone string `json:"contact_phone"` + ContactMobile string `json:"contact_mobile"` + BusinessTime []*BusinessTime `json:"business_time"` + ShopStatus string `json:"shop_status"` + ShopInfoStatus string `json:"shop_info_status"` +} + +type BusinessAddress struct { + CityCode string `json:"city_code"` + DistrictCode string `json:"district_code"` + Address string `json:"address"` + ProvinceCode string `json:"province_code"` + Poiid string `json:"poiid"` + Longitude string `json:"longitude"` + Latitude string `json:"latitude"` + Type string `json:"type"` +} + +type BusinessTime struct { + WeekDay int `json:"week_day"` + OpenTime string `json:"open_time"` + CloseTime string `json:"close_time"` +} + +type AntMerchantExpandMccQuery struct { + ErrorResponse + MccInfoList []*MccInfo `json:"mcc_info_list"` +} + +type MccInfo struct { + MccLevel1 string `json:"mcc_level_1"` + MccLevel1Name string `json:"mcc_level_1_name"` + MccLevel2 string `json:"mcc_level_2"` + MccLevel2Name string `json:"mcc_level_2_name"` + IsSpecial bool `json:"is_special"` + SpecialQualRequired bool `json:"special_qual_required"` + MccRequirements string `json:"mcc_requirements"` +} + +type AntMerchantExpandShopReceiptAccountSave struct { + ErrorResponse +} diff --git a/alipay/model_data.go b/alipay/model_data.go new file mode 100644 index 00000000..f4ffd620 --- /dev/null +++ b/alipay/model_data.go @@ -0,0 +1,91 @@ +package alipay + +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 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 DataBillEreceiptApplyRsp struct { + Response *DataBillEreceiptApply `json:"alipay_data_bill_ereceipt_apply_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type DataBillEreceiptQueryRsp struct { + Response *DataBillEreceiptQuery `json:"alipay_data_bill_ereceipt_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +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 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 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 DataBillDownloadUrlQuery struct { + ErrorResponse + BillDownloadUrl string `json:"bill_download_url,omitempty"` +} + +type DataBillEreceiptApply struct { + ErrorResponse + FileId string `json:"file_id"` +} + +type DataBillEreceiptQuery struct { + ErrorResponse + Status string `json:"status"` + DownloadUrl string `json:"download_url"` + ErrorMessage string `json:"error_message"` +} diff --git a/alipay/model_face.go b/alipay/model_face.go new file mode 100644 index 00000000..0ba479bc --- /dev/null +++ b/alipay/model_face.go @@ -0,0 +1,111 @@ +package alipay + +type FaceVerificationInitializeRsp struct { + Response *FaceVerificationInitialize `json:"datadigital_fincloud_generalsaas_face_verification_initialize_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceVerificationQueryRsp struct { + Response *FaceVerificationQuery `json:"datadigital_fincloud_generalsaas_face_verification_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceCertifyInitializeRsp struct { + Response *FaceCertifyInitialize `json:"datadigital_fincloud_generalsaas_face_certify_initialize_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceCertifyVerifyRsp struct { + Response *FaceCertifyVerify `json:"datadigital_fincloud_generalsaas_face_certify_verify_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceCertifyQueryRsp struct { + Response *FaceCertifyQuery `json:"datadigital_fincloud_generalsaas_face_certify_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceSourceCertifyRsp struct { + Response *FaceSourceCertify `json:"datadigital_fincloud_generalsaas_face_source_certify_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceCheckInitializeRsp struct { + Response *FaceCheckInitialize `json:"datadigital_fincloud_generalsaas_face_check_initialize_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type FaceCheckQueryRsp struct { + Response *FaceCheckQuery `json:"datadigital_fincloud_generalsaas_face_check_query_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +// =========================================================分割========================================================= + +type FaceVerificationInitialize struct { + ErrorResponse + CertifyId string `json:"certify_id"` + WebUrl string `json:"web_url"` +} + +type FaceVerificationQuery struct { + ErrorResponse + CertifyState string `json:"certify_state"` + Score string `json:"score"` + Quality string `json:"quality"` + AlivePhoto string `json:"alive_photo"` + AttackFlag string `json:"attack_flag"` +} + +type FaceCertifyInitialize struct { + ErrorResponse + CertifyId string `json:"certify_id"` +} + +type FaceCertifyVerify struct { + ErrorResponse + CertifyUrl string `json:"certify_url"` +} + +type FaceCertifyQuery struct { + ErrorResponse + Passed string `json:"passed"` +} + +type FaceSourceCertify struct { + ErrorResponse + CertifyNo string `json:"certify_no"` + Passed string `json:"passed"` + Score string `json:"score"` + Quality string `json:"quality"` + MismatchReason string `json:"mismatch_reason"` +} + +type FaceCheckInitialize struct { + ErrorResponse + CertifyId string `json:"certify_id"` + WebUrl string `json:"web_url"` +} + +type FaceCheckQuery struct { + ErrorResponse + CertifyState string `json:"certify_state"` + Quality string `json:"quality"` + AlivePhoto string `json:"alive_photo"` +} diff --git a/alipay/model_ocr.go b/alipay/model_ocr.go new file mode 100644 index 00000000..3d2c4943 --- /dev/null +++ b/alipay/model_ocr.go @@ -0,0 +1,41 @@ +package alipay + +type OcrServerDetectRsp struct { + Response *OcrServerDetect `json:"datadigital_fincloud_generalsaas_ocr_server_detect_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type OcrMobileInitializeRsp struct { + Response *OcrMobileInitialize `json:"datadigital_fincloud_generalsaas_ocr_mobile_initialize_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +type OcrCommonDetectRsp struct { + Response *OcrCommonDetect `json:"datadigital_fincloud_generalsaas_ocr_common_detect_response"` + AlipayCertSn string `json:"alipay_cert_sn,omitempty"` + SignData string `json:"-"` + Sign string `json:"sign"` +} + +// =========================================================分割========================================================= + +type OcrServerDetect struct { + ErrorResponse + OcrData string `json:"ocr_data"` + CertifyId string `json:"certify_id"` +} + +type OcrMobileInitialize struct { + ErrorResponse + CertifyId string `json:"certify_id"` +} + +type OcrCommonDetect struct { + ErrorResponse + CertifyId string `json:"certify_id"` + OcrData string `json:"ocr_data"` +} diff --git a/alipay/ocr.go b/alipay/ocr.go new file mode 100644 index 00000000..4d1de6d3 --- /dev/null +++ b/alipay/ocr.go @@ -0,0 +1,78 @@ +package alipay + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/go-pay/gopay" +) + +// datadigital.fincloud.generalsaas.ocr.server.detect(服务端OCR) +// 文档地址:https://opendocs.alipay.com/open/05ut8h +func (a *Client) OcrServerDetect(ctx context.Context, bm gopay.BodyMap) (aliRsp *OcrServerDetectRsp, err error) { + err = bm.CheckEmptyError("ocr_type", "outer_order_no") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.ocr.server.detect"); err != nil { + return nil, err + } + aliRsp = new(OcrServerDetectRsp) + 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.ocr.mobile.initialize(App端OCR初始化) +// 文档地址:https://opendocs.alipay.com/open/043ksf +func (a *Client) OcrMobileInitialize(ctx context.Context, bm gopay.BodyMap) (aliRsp *OcrMobileInitializeRsp, 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.ocr.mobile.initialize"); err != nil { + return nil, err + } + aliRsp = new(OcrMobileInitializeRsp) + 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.ocr.common.detect(文字识别OCR) +// 文档地址:https://opendocs.alipay.com/open/0776c2cb_datadigital.fincloud.generalsaas.ocr.common.detect +func (a *Client) OcrCommonDetect(ctx context.Context, bm gopay.BodyMap) (aliRsp *OcrCommonDetectRsp, err error) { + err = bm.CheckEmptyError("ocr_type", "outer_order_no", "file_content") + if err != nil { + return nil, err + } + var bs []byte + if bs, err = a.doAliPay(ctx, bm, "datadigital.fincloud.generalsaas.ocr.common.detect"); err != nil { + return nil, err + } + aliRsp = new(OcrCommonDetectRsp) + 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) +} diff --git a/doc/alipay.md b/doc/alipay.md index d0ebdba4..f2b5c6bb 100644 --- a/doc/alipay.md +++ b/doc/alipay.md @@ -1,5 +1,7 @@ ## 支付宝 +> #### [开发文档(V3版)](https://opendocs.alipay.com/open-v3) is coming soon... + > #### 因支付宝接口太多,如没实现的接口,还请开发者自行调用 `client.PostAliPayAPISelfV2()`方法实现!请参考 `client_test.go` 内的 `TestClient_PostAliPayAPISelfV2()` 方法 > #### 希望有时间的伙伴儿Fork完后,补充并提交Pull Request,一起完善支付宝各个类别下的接口到相应的go文件中 @@ -305,16 +307,14 @@ xlog.Infof("%+v", phone) * 订单优惠前置咨询接口:`client.MarketingCampaignOrderVoucherConsult()` * 蚂蚁门店管理 * 蚂蚁店铺创建接口: `client.AntMerchantShopCreate()` - * 店铺保存审核通过消息接口:TODO:https://opendocs.alipay.com/open/04fgwm - * 店铺保存拒绝消息:TODO:https://opendocs.alipay.com/open/04fgwn * 修改蚂蚁店铺接口: `client.AntMerchantShopModify()` * 商户申请单查询接口: `client.AntMerchantOrderQuery()` - * 店铺分页查询接口:TODO:https://opendocs.alipay.com/open/04fgwq + * 店铺分页查询接口:`client.AntMerchantShopPageQuery()` * 店铺查询接口:`client.AntMerchantShopQuery()` * 蚂蚁店铺关闭接口:`client.AntMerchantShopClose()` * 图片上传接口:`client.AntMerchantExpandIndirectImageUpload()` - * 商户mcc信息查询接口:TODO:https://opendocs.alipay.com/open/04fgwu - * 店铺增加收单账号接口:TODO:https://opendocs.alipay.com/open/54b69b89_ant.merchant.expand.shop.receiptaccount.save + * 商户mcc信息查询接口:`client.AntMerchantExpandMccQuery()` + * 店铺增加收单账号接口:`client.AntMerchantExpandShopReceiptAccountSave()` * 商家券 2.0 * 活动创建 * 创建商家券活动接口:TODO:https://opendocs.alipay.com/open/7ad3a7bf_alipay.marketing.activity.ordervoucher.create @@ -388,8 +388,8 @@ xlog.Infof("%+v", phone) * 资金产品 * 转账到支付宝账户 * 支付宝资金账户资产查询接口:`client.FundAccountQuery()` - * 申请电子回单(incubating)接口:TODO:https://opendocs.alipay.com/open/1aad1956_alipay.data.bill.ereceipt.apply - * 查询电子回单状态(incubating)接口:TODO:https://opendocs.alipay.com/open/30b94a2f_alipay.data.bill.ereceipt.query + * 申请电子回单(incubating)接口:`client.DataBillEreceiptApply()` + * 查询电子回单状态(incubating)接口:`client.DataBillEreceiptQuery()` * 查询转账订单接口: `client.FundTransOrderQuery()` * 批次下单接口: `client.FundBatchCreate()` * 批量转账关单接口: `client.FundBatchClose()` @@ -398,19 +398,19 @@ xlog.Infof("%+v", phone) * 会员产品 * 人脸验证 * 人脸核身 - * APP人脸核身初始化接口:TODO:https://opendocs.alipay.com/open/04jg6r - * APP人脸核身结果查询接口:TODO:https://opendocs.alipay.com/open/04jg6s - * H5人脸核身初始化接口:TODO:https://opendocs.alipay.com/open/02zloa - * H5人脸核身开始认证接口:TODO:https://opendocs.alipay.com/open/02zlob - * H5人脸核身查询记录接口:TODO:https://opendocs.alipay.com/open/02zloc - * 纯服务端人脸核身接口:TODO:https://opendocs.alipay.com/open/04pxq6 + * APP人脸核身初始化接口:`client.FaceVerificationInitialize()` + * APP人脸核身结果查询接口:`client.FaceVerificationQuery()` + * H5人脸核身初始化接口:`client.FaceCertifyInitialize()` + * H5人脸核身开始认证接口:`client.FaceCertifyVerify()` + * H5人脸核身查询记录接口:`client.FaceCertifyQuery()` + * 纯服务端人脸核身接口:`client.FaceSourceCertify()` * 活体检测 - * 人脸检测初始化接口:TODO:https://opendocs.alipay.com/open/03nisu - * 人脸检测结果数据查询接口:TODO:https://opendocs.alipay.com/open/03nisv + * 人脸检测初始化接口:`client.FaceCheckInitialize()` + * 人脸检测结果数据查询接口:`client.FaceCheckQuery()` * OCR文字识别 - * 服务端OCR接口:TODO:https://opendocs.alipay.com/open/05ut8h - * App端OCR初始化接口:TODO:https://opendocs.alipay.com/open/043ksf - * 文字识别OCR接口:TODO:https://opendocs.alipay.com/open/0776c2cb_datadigital.fincloud.generalsaas.ocr.common.detect + * 服务端OCR接口:`client.OcrServerDetect()` + * App端OCR初始化接口:`client.OcrMobileInitialize()` + * 文字识别OCR接口:`client.OcrCommonDetect()` * 获取会员信息 * 支付宝会员授权信息查询接口:`client.UserInfoShare()` * 换取授权访问令牌接口:`client.SystemOauthToken()`