Skip to content

Commit

Permalink
add new alipay api
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed May 11, 2024
1 parent dcde665 commit 13a1eb5
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 12 deletions.
23 changes: 23 additions & 0 deletions alipay/merchant_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,26 @@ func (a *Client) TradeRoyaltyRateQuery(ctx context.Context, bm gopay.BodyMap) (a
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.security.risk.customerrisk.send(商户数据同步)
// 文档地址:https://opendocs.alipay.com/open/02qth4
func (a *Client) SecurityCustomerRiskSend(ctx context.Context, bm gopay.BodyMap) (aliRsp *SecurityCustomerRiskSendRsp, err error) {
err = bm.CheckEmptyError("process_code", "trade_no")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.security.risk.customerrisk.send"); err != nil {
return nil, err
}
aliRsp = new(SecurityCustomerRiskSendRsp)
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)
}
11 changes: 11 additions & 0 deletions alipay/model_merchant.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ type TradeRoyaltyRateQueryResponse struct {
Sign string `json:"sign"`
}

type SecurityCustomerRiskSendRsp struct {
Response *SecurityCustomerRiskSend `json:"alipay_security_risk_customerrisk_send_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

// =========================================================分割=========================================================

type TradeRelationBind struct {
Expand Down Expand Up @@ -120,3 +127,7 @@ type TradeRoyaltyRateQuery struct {
UserId string `json:"user_id,omitempty"`
MaxRatio string `json:"max_ratio,omitempty"`
}

type SecurityCustomerRiskSend struct {
ErrorResponse
}
93 changes: 93 additions & 0 deletions alipay/model_zhima.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,55 @@ type ZhimaCustomerJobworthSceneUseRsp struct {
Sign string `json:"sign"`
}

type ZhimaCustomerJobworthAuthQueryRsp struct {
Response *ZhimaCustomerJobworthAuthQuery `json:"zhima_customer_jobworth_authentication_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCustomerJobworthAuthPreConsultRsp struct {
Response *ZhimaCustomerJobworthAuthPreConsult `json:"zhima_customer_jobworth_authentication_preconsult_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCreditPeZmgoSettleApplyRsp struct {
Response *ZhimaCreditPeZmgoSettleApply `json:"zhima_credit_pe_zmgo_settle_apply_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCreditPayAfterUseAgreementQueryRsp struct {
Response *ZhimaCreditPayAfterUseAgreementQuery `json:"zhima_credit_payafteruse_creditagreement_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCreditPayAfterUseCreditBizOrderRsp struct {
Response *ZhimaCreditPayAfterUseCreditBizOrder `json:"zhima_credit_payafteruse_creditbizorder_order_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCreditPayAfterUseCreditBizOrderQueryRsp struct {
Response *ZhimaCreditPayAfterUseCreditBizOrderQuery `json:"zhima_credit_payafteruse_creditbizorder_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCreditPayAfterUseCreditBizOrderFinishRsp struct {
Response *ZhimaCreditPayAfterUseCreditBizOrderFinish `json:"zhima_credit_payafteruse_creditbizorder_finish_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

// =========================================================分割=========================================================

type ScoreGet struct {
Expand Down Expand Up @@ -401,6 +443,21 @@ type ZhimaCustomerJobworthSceneUse struct {
ErrorResponse
}

type ZhimaCustomerJobworthAuthQuery struct {
ErrorResponse
IdentityResult string `json:"identity_result"`
IdentityResultSkipUrl string `json:"identity_result_skip_url"`
TokenStatus string `json:"token_status"`
UserId string `json:"user_id"`
OpenId string `json:"open_id"`
}

type ZhimaCustomerJobworthAuthPreConsult struct {
ErrorResponse
PreCheckSuccess bool `json:"pre_check_success"`
Reason string `json:"reason"`
}

type ZhimaCreditPeZmgoSettleApply struct {
ErrorResponse
OutRequestNo string `json:"out_request_no"`
Expand All @@ -409,3 +466,39 @@ type ZhimaCreditPeZmgoSettleApply struct {
SettleStatus string `json:"settle_status"`
FailReason string `json:"fail_reason"`
}

type ZhimaCreditPayAfterUseAgreementQuery struct {
ErrorResponse
OutAgreementNo string `json:"out_agreement_no"`
AgreementStatus string `json:"agreement_status"`
CreditAgreementId string `json:"credit_agreement_id"`
BizTime string `json:"biz_time"`
ExtInfo string `json:"ext_info"`
AlipayUserId string `json:"alipay_user_id"`
OpenId string `json:"open_id"`
}

type ZhimaCreditPayAfterUseCreditBizOrder struct {
ErrorResponse
OutOrderNo string `json:"out_order_no"`
CreditBizOrderId string `json:"credit_biz_order_id"`
}

type ZhimaCreditPayAfterUseCreditBizOrderQuery struct {
ErrorResponse
CreditBizOrderId string `json:"credit_biz_order_id"`
CreditAgreementId string `json:"credit_agreement_id"`
TotalAmount string `json:"total_amount"`
CreateTime string `json:"create_time"`
ZmServiceId string `json:"zm_service_id"`
ProductCode string `json:"product_code"`
OrderStatus string `json:"order_status"`
TradeNo string `json:"trade_no"`
}

type ZhimaCreditPayAfterUseCreditBizOrderFinish struct {
ErrorResponse
OutRequestNo string `json:"out_request_no"`
CreditBizOrderId string `json:"credit_biz_order_id"`
OrderStatus string `json:"order_status"`
}
2 changes: 1 addition & 1 deletion alipay/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (a *Client) doAliPay(ctx context.Context, bm gopay.BodyMap, method string,
return nil, err
}
switch method {
case "alipay.trade.app.pay", "alipay.fund.auth.order.app.freeze":
case "alipay.trade.app.pay", "alipay.fund.auth.order.app.freeze", "zhima.credit.pe.zmgo.sign.apply", "zhima.credit.payafteruse.creditagreement.sign":
return []byte(param), nil
case "alipay.trade.wap.pay", "alipay.trade.page.pay", "alipay.user.certify.open.certify":
if !a.IsProd {
Expand Down
145 changes: 145 additions & 0 deletions alipay/zhima_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,105 @@ func (a *Client) ZhimaCreditPeZmgoPaysignConfirm(ctx context.Context, bm gopay.B
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// zhima.credit.payafteruse.creditagreement.sign(信用服务开通/授权)
// 文档地址:https://opendocs.alipay.com/open/03uloz
func (a *Client) ZhimaCreditPayAfterUseAgreementSign(ctx context.Context, bm gopay.BodyMap) (orderStr string, err error) {
err = bm.CheckEmptyError("out_agreement_no", "zm_service_id")
if err != nil {
return gopay.NULL, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditagreement.sign"); err != nil {
return gopay.NULL, err
}
orderStr = string(bs)
return orderStr, nil
}

// zhima.credit.payafteruse.creditagreement.query(查询服务开通/授权信息)
// 文档地址:https://opendocs.alipay.com/open/03ulp0
func (a *Client) ZhimaCreditPayAfterUseAgreementQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseAgreementQueryRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditagreement.query"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCreditPayAfterUseAgreementQueryRsp)
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)
}

// zhima.credit.payafteruse.creditbizorder.order(芝麻信用服务下单(免用户确认场景))
// 文档地址:https://opendocs.alipay.com/open/03ulpo
func (a *Client) ZhimaCreditPayAfterUseCreditBizOrder(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseCreditBizOrderRsp, err error) {
err = bm.CheckEmptyError("out_order_no", "credit_agreement_id", "subject")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditbizorder.order"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCreditPayAfterUseCreditBizOrderRsp)
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)
}

// zhima.credit.payafteruse.creditbizorder.query(信用服务订单查询)
// 文档地址:https://opendocs.alipay.com/open/03vtet
func (a *Client) ZhimaCreditPayAfterUseCreditBizOrderQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseCreditBizOrderQueryRsp, err error) {
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditbizorder.query"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCreditPayAfterUseCreditBizOrderQueryRsp)
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)
}

// zhima.credit.payafteruse.creditbizorder.finish(结束信用服务订单)
// 文档地址:https://opendocs.alipay.com/open/03vteu
func (a *Client) ZhimaCreditPayAfterUseCreditBizOrderFinish(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPayAfterUseCreditBizOrderFinishRsp, err error) {
err = bm.CheckEmptyError("out_request_no", "credit_biz_order_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.payafteruse.creditbizorder.finish"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCreditPayAfterUseCreditBizOrderFinishRsp)
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)
}

// zhima.customer.jobworth.adapter.query(职得工作证信息匹配度查询)
// 文档地址:https://opendocs.alipay.com/apis/022mvz
func (a *Client) ZhimaCustomerJobworthAdapterQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthAdapterQueryRsp, err error) {
Expand Down Expand Up @@ -527,3 +626,49 @@ func (a *Client) ZhimaCustomerJobworthSceneUse(ctx context.Context, bm gopay.Bod
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// zhima.customer.jobworth.authentication.query(职得身份认证查询接口)
// 文档地址:https://opendocs.alipay.com/open/351177b5_zhima.customer.jobworth.authentication.query
func (a *Client) ZhimaCustomerJobworthAuthQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthAuthQueryRsp, err error) {
err = bm.CheckEmptyError("conn_key", "once_token", "query_type", "identity_type", "service_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.customer.jobworth.authentication.query"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCustomerJobworthAuthQueryRsp)
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)
}

// zhima.customer.jobworth.authentication.preconsult(身份验真预咨询服务)
// 文档地址:https://opendocs.alipay.com/open/16f72e43_zhima.customer.jobworth.authentication.preconsult
func (a *Client) ZhimaCustomerJobworthAuthPreConsult(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCustomerJobworthAuthPreConsultRsp, err error) {
err = bm.CheckEmptyError("out_agreement_no", "once_token", "identity_type", "query_type", "zm_service_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.customer.jobworth.authentication.preconsult"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCustomerJobworthAuthPreConsultRsp)
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)
}
22 changes: 11 additions & 11 deletions doc/alipay.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,29 +441,29 @@ xlog.Infof("%+v", phone)
* 芝麻GO支付下单链路签约确认: `client.ZhimaCreditPeZmgoPaysignConfirm()`
* 芝麻先享
* 服务开通
* 信用服务开通/授权接口:TODO:https://opendocs.alipay.com/open/03uloz
* 查询服务开通/授权信息接口:TODO:https://opendocs.alipay.com/open/03ulp0
* 信用服务开通/授权接口:`client.ZhimaCreditPayAfterUseAgreementSign()`
* 查询服务开通/授权信息接口:`client.ZhimaCreditPayAfterUseAgreementQuery()`
* 信用下单
* 芝麻先享信用服务下单(免用户确认场景)接口:TODO:https://opendocs.alipay.com/open/03ulpo
* 芝麻先享信用服务下单(用户确认场景)接口:TODO:https://opendocs.alipay.com/open/03ulpp
* 信用服务订单查询接口:TODO:https://opendocs.alipay.com/open/03vtet
* 结束信用服务订单接口:TODO:https://opendocs.alipay.com/open/03vteu
* 芝麻先享信用服务下单(免用户确认场景)接口:`client.ZhimaCreditPayAfterUseCreditBizOrder()`
* 芝麻先享信用服务下单(用户确认场景)接口:支付宝 SDK 实现
* 信用服务订单查询接口:`client.ZhimaCreditPayAfterUseCreditBizOrderQuery()`
* 结束信用服务订单接口:`client.ZhimaCreditPayAfterUseCreditBizOrderFinish()`
* 扣款
* 统一收单交易订单支付接口:TODO:https://opendocs.alipay.com/open/2e81a85f_alipay.trade.order.pay
* 统一收单交易订单支付接口:`client.TradeOrderPay()`
* 芝麻免押
* 创建免押订单接口:`client:FundAuthOrderAppFreeze()`
* 完结免押订单接口:`client.FundAuthOrderUnfreeze()`
* 查询免押订单接口:`client.FundAuthOperationDetailQuery()`
* 取消免押订单接口:`client.FundAuthOperationCancel()`
* 芝麻身份信息验证
* 信用服务开通/授权接口:TODO:https://opendocs.alipay.com/open/63612668_zhima.credit.payafteruse.creditagreement.sign
* 职得身份认证查询接口:TODO:https://opendocs.alipay.com/open/351177b5_zhima.customer.jobworth.authentication.query
* 信用服务开通/授权接口:`client.ZhimaCreditPayAfterUseAgreementSign()`
* 职得身份认证查询接口:`client.ZhimaCustomerJobworthAuthQuery()`
* 职得工作证信息匹配度查询: `client.ZhimaCustomerJobworthAdapterQuery()`
* 职得工作证外部渠道应用数据回流: `client.ZhimaCustomerJobworthSceneUse()`
* 身份验真预咨询服务接口:TODO:https://opendocs.alipay.com/open/16f72e43_zhima.customer.jobworth.authentication.preconsult
* 身份验真预咨询服务接口:`client.ZhimaCustomerJobworthAuthPreConsult()`
* <font color='#027AFF' size='4'>安全产品</font>
* 交易安全防护
* 商户数据同步:TODO:https://opendocs.alipay.com/open/02qth4
* 商户数据同步:`client.SecurityCustomerRiskSend()`
* <font color='#027AFF' size='4'>其他产品</font>
* 花芝轻会员结算申请: `client.PcreditHuabeiAuthSettleApply()`
* NFC用户卡信息同步: `client.CommerceTransportNfccardSend()`
Expand Down

0 comments on commit 13a1eb5

Please sign in to comment.