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 c7b4c8c commit dcde665
Show file tree
Hide file tree
Showing 5 changed files with 296 additions and 15 deletions.
46 changes: 46 additions & 0 deletions alipay/member_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,52 @@ func (a *Client) SystemOauthToken(ctx context.Context, bm gopay.BodyMap) (aliRsp
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.open.auth.userauth.relationship.query(用户授权关系查询)
// 文档地址:https://opendocs.alipay.com/open/6b97edd1_alipay.open.auth.userauth.relationship.query
func (a *Client) UserAuthRelationshipQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserAuthRelationshipQueryRsp, err error) {
err = bm.CheckEmptyError("scopes")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.open.auth.userauth.relationship.query"); err != nil {
return nil, err
}
aliRsp = new(UserAuthRelationshipQueryRsp)
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.user.deloauth.detail.query(查询解除授权明细)
// 文档地址:https://opendocs.alipay.com/open/77e7fec5_alipay.user.deloauth.detail.query
func (a *Client) UserDelOAuthDetailQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *UserDelOAuthDetailQueryRsp, err error) {
err = bm.CheckEmptyError("date", "limit", "offset")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.user.deloauth.detail.query"); err != nil {
return nil, err
}
aliRsp = new(UserDelOAuthDetailQueryRsp)
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.user.info.share(支付宝会员授权信息查询接口)
// body:此接口无需body参数
// 文档地址:https://opendocs.alipay.com/open/02aild
Expand Down
38 changes: 34 additions & 4 deletions alipay/model_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ type UserAlipaypointBudgetlibQueryRsp struct {
Sign string `json:"sign"`
}

type UserAuthRelationshipQueryRsp struct {
Response *UserAuthRelationshipQuery `json:"alipay_open_auth_userauth_relationship_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type UserDelOAuthDetailQueryRsp struct {
Response *UserDelOAuthDetailQuery `json:"alipay_user_deloauth_detail_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

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

type OauthTokenInfo struct {
Expand Down Expand Up @@ -169,10 +183,10 @@ type UserInfoShare struct {
UserStatus string `json:"user_status,omitempty"`
IsCertified string `json:"is_certified,omitempty"`
Gender string `json:"gender,omitempty"`
Cert_type string `json:"cert_type,omitempty"`
Cert_no string `json:"cert_no,omitempty"`
Mobile string `json:"mobile,omitempty"`
User_name string `json:"user_name,omitempty"`
Cert_type string `json:"cert_type,omitempty"`
Cert_no string `json:"cert_no,omitempty"`
Mobile string `json:"mobile,omitempty"`
User_name string `json:"user_name,omitempty"`
}

type UserCertifyOpenInit struct {
Expand Down Expand Up @@ -336,3 +350,19 @@ type UserAlipaypointBudgetlibQuery struct {
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}

type UserAuthRelationshipQuery struct {
ErrorResponse
QueryDetail string `json:"query_detail"`
}

type UserDelOAuthDetailQuery struct {
ErrorResponse
Details []*DelOAuthDetail `json:"details"`
}

type DelOAuthDetail struct {
DelAuthTime string `json:"del_auth_time"`
UserId string `json:"user_id"`
OpenId string `json:"open_id"`
}
130 changes: 126 additions & 4 deletions alipay/model_zhima.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ type ZhimaMerchantZmgoCumulateQueryRsp struct {
Sign string `json:"sign"`
}

type ZhimaMerchantZmgoTemplateCreateRsp struct {
Response *ZhimaMerchantZmgoTemplateCreate `json:"zhima_merchant_zmgo_template_create_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaMerchantZmgoTemplateQueryRsp struct {
Response *ZhimaMerchantZmgoTemplateQuery `json:"zhima_merchant_zmgo_template_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type ZhimaCreditPeZmgoBizoptCloseRsp struct {
Response *ZhimaCreditPeZmgoBizoptClose `json:"zhima_credit_pe_zmgo_bizopt_close_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
Expand Down Expand Up @@ -133,6 +147,13 @@ type ZhimaCustomerJobworthSceneUseRsp struct {
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 ScoreGet struct {
Expand Down Expand Up @@ -213,6 +234,102 @@ type CumulateDataDetail struct {
DiscountAmount string `json:"discount_amount,omitempty"`
}

type ZhimaMerchantZmgoTemplateCreate struct {
ErrorResponse
TemplateNo string `json:"template_no"`
}

type ZhimaMerchantZmgoTemplateQuery struct {
ErrorResponse
BasicConfig *BasicConfig `json:"basic_config"`
ObligationConfig *ObligationConfig `json:"obligation_config"`
RightConfig *RightConfig `json:"right_config"`
OpenConfig *OpenConfig `json:"open_config"`
SettlementConfig *SettlementConfig `json:"settlement_config"`
QuitConfig *QuitConfig `json:"quit_config"`
ExtConfig *ExtConfig `json:"ext_config"`
}

type BasicConfig struct {
TemplateName string `json:"template_name"`
PartnerId string `json:"partner_id"`
IsvPid string `json:"isv_pid"`
BizType string `json:"biz_type"`
OutBizNo string `json:"out_biz_no"`
MerchantCustomLogo string `json:"merchant_custom_logo"`
Contact string `json:"contact"`
TemplateNo string `json:"template_no"`
}

type ObligationConfig struct {
ObligationTemplate string `json:"obligation_template"`
ObligationTimes string `json:"obligation_times"`
ObligationAmount int `json:"obligation_amount"`
PromiseTypeDesc string `json:"promise_type_desc"`
BenefitUrl string `json:"benefit_url"`
TaskProgressRedirectSchema string `json:"task_progress_redirect_schema"`
}

type RightConfig struct {
CustomBenefitDesc string `json:"custom_benefit_desc"`
CustomSubBenefitDesc string `json:"custom_sub_benefit_desc"`
CumulativePreferentialRedirectSchema string `json:"cumulative_preferential_redirect_schema"`
}

type OpenConfig struct {
FreezeAmount string `json:"freeze_amount"`
PeriodMode string `json:"period_mode"`
PeriodTime string `json:"period_time"`
AppointDate string `json:"appoint_date"`
MinSignInterval string `json:"min_sign_interval"`
SupportExpireDeferral bool `json:"support_expire_deferral"`
CustomOpenTipList string `json:"custom_open_tip_list"`
CardColorScheme string `json:"card_color_scheme"`
CustomOpenTips string `json:"custom_open_tips"`
ShowSignSuccessPage bool `json:"show_sign_success_page"`
SignSuccessTaskButtonDesc string `json:"sign_success_task_button_desc"`
SignAgainSchema string `json:"sign_again_schema"`
ApplyButtonDesc string `json:"apply_button_desc"`
}

type SettlementConfig struct {
SettlementType string `json:"settlement_type"`
CustomFeeName string `json:"custom_fee_name"`
CycleFlexWithholdConfig *CycleFlexWithholdConfig `json:"cycle_flex_withhold_config"`
FulfilltimesCustomSettlementPlan string `json:"fulfilltimes_custom_settlement_plan"`
ExpStopTimeMode string `json:"exp_stop_time_mode"`
ExpStopTime string `json:"exp_stop_time"`
ExpStopDelayDays int `json:"exp_stop_delay_days"`
CycleWithholdConfig *CycleWithholdConfig `json:"cycle_withhold_config"`
}

type CycleFlexWithholdConfig struct {
CycleFlexWithholdTotalPeriodCount int `json:"cycle_flex_withhold_total_period_count"`
CycleFlexWithholdMaxPrice int `json:"cycle_flex_withhold_max_price"`
CycleFlexWithholdFeeName string `json:"cycle_flex_withhold_fee_name"`
}

type CycleWithholdConfig struct {
WithholdMode string `json:"withhold_mode"`
PeriodType string `json:"period_type"`
Period string `json:"period"`
SupportCycleWithholdHighMode bool `json:"support_cycle_withhold_high_mode"`
DeductPlan []string `json:"deduct_plan"`
SupportExemptionPeriod bool `json:"support_exemption_period"`
ExemptionPeriod string `json:"exemption_period"`
}

type QuitConfig struct {
QuitType string `json:"quit_type"`
QuitJumpUrl string `json:"quit_jump_url"`
QuitDesc string `json:"quit_desc"`
}

type ExtConfig struct {
TextContentFillRuleId string `json:"text_content_fill_rule_id"`
TextContentFillVariable string `json:"text_content_fill_variable"`
}

type ZhimaCreditPeZmgoBizoptClose struct {
ErrorResponse
UserId string `json:"user_id"`
Expand Down Expand Up @@ -277,13 +394,18 @@ type ZhimaCreditPeZmgoPaysignConfirm struct {
type ZhimaCustomerJobworthAdapterQuery struct {
ErrorResponse
AdapterScore string `json:"adapter_score,omitempty"`
SubCode string `json:"sub_code,omitempty"`
SubMsg string `json:"sub_msg,omitempty"`
Url string `json:"url,omitempty"`
}

type ZhimaCustomerJobworthSceneUse struct {
ErrorResponse
SubCode string `json:"sub_code"`
SubMsg string `json:"sub_msg"`
}

type ZhimaCreditPeZmgoSettleApply struct {
ErrorResponse
OutRequestNo string `json:"out_request_no"`
AgreementId string `json:"agreement_id"`
WithholdPlanNo string `json:"withhold_plan_no"`
SettleStatus string `json:"settle_status"`
FailReason string `json:"fail_reason"`
}
84 changes: 84 additions & 0 deletions alipay/zhima_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,75 @@ func (a *Client) ZhimaMerchantZmgoCumulateQuery(ctx context.Context, bm gopay.Bo
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// zhima.merchant.zmgo.template.create(商户创建芝麻GO模板接口)
// 文档地址:https://opendocs.alipay.com/open/03uq08
func (a *Client) ZhimaMerchantZmgoTemplateCreate(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaMerchantZmgoTemplateCreateRsp, err error) {
err = bm.CheckEmptyError("basic_config", "right_config", "open_config", "settlement_config")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.merchant.zmgo.template.create"); err != nil {
return nil, err
}
aliRsp = new(ZhimaMerchantZmgoTemplateCreateRsp)
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.merchant.zmgo.template.query(芝麻GO模板查询)
// 文档地址:https://opendocs.alipay.com/open/04m8ci
func (a *Client) ZhimaMerchantZmgoTemplateQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaMerchantZmgoTemplateQueryRsp, err error) {
err = bm.CheckEmptyError("template_no", "partner_id")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.merchant.zmgo.template.query"); err != nil {
return nil, err
}
aliRsp = new(ZhimaMerchantZmgoTemplateQueryRsp)
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.pe.zmgo.settle.apply(芝麻GO结算申请)
// 文档地址:https://opendocs.alipay.com/open/03usxk
func (a *Client) ZhimaCreditPeZmgoSettleApply(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoSettleApplyRsp, err error) {
err = bm.CheckEmptyError("agreement_id", "partner_id", "out_request_no", "withhold_plan_no", "pay_amount")
if err != nil {
return nil, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.settle.apply"); err != nil {
return nil, err
}
aliRsp = new(ZhimaCreditPeZmgoSettleApplyRsp)
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.pe.zmgo.bizopt.close(芝麻GO签约关单)
// 文档地址:https://opendocs.alipay.com/apis/01qii3
func (a *Client) ZhimaCreditPeZmgoBizoptClose(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoBizoptCloseRsp, err error) {
Expand Down Expand Up @@ -291,6 +360,21 @@ func (a *Client) ZhimaCreditPeZmgoPreorderCreate(ctx context.Context, bm gopay.B
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// zhima.credit.pe.zmgo.sign.apply(芝麻GO页面签约接口)
// 文档地址:https://opendocs.alipay.com/open/03u934
func (a *Client) ZhimaCreditPeZmgoSignApply(ctx context.Context, bm gopay.BodyMap) (orderStr string, err error) {
err = bm.CheckEmptyError("partner_id", "template_id", "out_request_no")
if err != nil {
return gopay.NULL, err
}
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "zhima.credit.pe.zmgo.sign.apply"); err != nil {
return gopay.NULL, err
}
orderStr = string(bs)
return orderStr, nil
}

// zhima.credit.pe.zmgo.agreement.unsign(芝麻GO协议解约)
// 文档地址:https://opendocs.alipay.com/open/03ub1g
func (a *Client) ZhimaCreditPeZmgoAgreementUnsign(ctx context.Context, bm gopay.BodyMap) (aliRsp *ZhimaCreditPeZmgoAgreementUnsignRsp, err error) {
Expand Down
13 changes: 6 additions & 7 deletions doc/alipay.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,8 @@ xlog.Infof("%+v", phone)
* 获取会员信息
* 支付宝会员授权信息查询接口:`client.UserInfoShare()`
* 换取授权访问令牌接口:`client.SystemOauthToken()`
* 用户授权取消消息接口:TODO:https://opendocs.alipay.com/open/b4f0d4cf_alipay.open.auth.userauth.cancelled
* 用户授权关系查询接口:TODO:https://opendocs.alipay.com/open/6b97edd1_alipay.open.auth.userauth.relationship.query
* 查询解除授权明细接口:TODO:https://opendocs.alipay.com/open/77e7fec5_alipay.user.deloauth.detail.query
* 用户授权关系查询接口:`client.UserAuthRelationshipQuery()`
* 查询解除授权明细接口:`client.UserDelOAuthDetailQuery()`
* 支付宝身份验证
* 身份认证记录查询: `client.UserCertifyOpenQuery()`
* 身份认证初始化服务接口: `client.UserCertifyOpenInit()`
Expand All @@ -426,15 +425,15 @@ xlog.Infof("%+v", phone)
* <font color='#027AFF' size='4'>信用产品</font>
* 芝麻GO
* 芝麻GO签约预创单接口:`client.ZhimaCreditPeZmgoPreorderCreate()`
* 芝麻GO页面签约接口:TODO:https://opendocs.alipay.com/open/03u934
* 芝麻GO页面签约接口:`client.ZhimaCreditPeZmgoSignApply()`
* 商家芝麻GO累计数据回传接口:`client.ZhimaMerchantZmgoCumulateSync()`
* 商家芝麻GO累计数据查询接口:`client.ZhimaMerchantZmgoCumulateQuery()`
* 芝麻GO结算申请接口:TODO:https://opendocs.alipay.com/open/03usxk
* 芝麻GO结算申请接口:`client.ZhimaCreditPeZmgoSettleApply()`
* 芝麻GO结算退款接口:`client.ZhimaCreditPeZmgoSettleRefund()`
* 芝麻Go协议查询接口:`client.ZhimaCreditPeZmgoAgreementQuery()`
* 芝麻GO协议解约接口:`client.ZhimaCreditPeZmgoAgreementUnsign()`
* 商户创建芝麻GO模板接口:TODO:https://opendocs.alipay.com/open/03uq08
* 芝麻GO模板查询接口:TODO:https://opendocs.alipay.com/open/04m8ci
* 商户创建芝麻GO模板接口:`client.ZhimaMerchantZmgoTemplateCreate()`
* 芝麻GO模板查询接口:`client.ZhimaMerchantZmgoTemplateQuery()`
* 芝麻GO用户数据回传: `client.ZhimaCreditPeZmgoCumulationSync()`
* 芝麻GO签约关单: `client.ZhimaCreditPeZmgoBizoptClose()`
* 芝麻GO解冻接口: `client.ZhimaCreditPeZmgoSettleUnfreeze()`
Expand Down

0 comments on commit dcde665

Please sign in to comment.