Documentation ¶
Index ¶
- type AuthType
- type AuthenticationEntity
- type AuthenticationScene
- type AuthenticationState
- type AuthenticationType
- type AuthenticationsApiService
- func (a *AuthenticationsApiService) GetAuthentication(ctx context.Context, req GetAuthenticationRequest) (resp *AuthenticationEntity, result *core.APIResult, err error)
- func (a *AuthenticationsApiService) ListAuthentications(ctx context.Context, req ListAuthenticationsRequest) (resp *ListAuthenticationsResponse, result *core.APIResult, err error)
- func (a *AuthenticationsApiService) PreOrderAuthentication(ctx context.Context, req PreOrderAuthenticationRequest) (resp *PreOrderAuthenticationResponse, result *core.APIResult, err error)
- func (a *AuthenticationsApiService) PreOrderAuthenticationWithAuth(ctx context.Context, req PreOrderAuthenticationWithAuthRequest) (resp *PreOrderAuthenticationWithAuthResponse, result *core.APIResult, ...)
- type BusinessType
- type CreateTokenRequest
- type CreateTransferBatchRequest
- type EmploymentScene
- type EmploymentType
- type GetAuthenticationRequest
- type GetRelationRequest
- type ListAuthenticationsRequest
- type ListAuthenticationsResponse
- type PayrollCardRegisterState
- type PreOrderAuthenticationRequest
- type PreOrderAuthenticationResponse
- type PreOrderAuthenticationWithAuthRequest
- type PreOrderAuthenticationWithAuthResponse
- type RelationEntity
- type RelationsApiService
- type TokenEntity
- type TokensApiService
- type TransferBatchApiService
- type TransferBatchEntity
- type TransferDetailInput
Examples ¶
- AuthenticationsApiService.GetAuthentication
- AuthenticationsApiService.ListAuthentications
- AuthenticationsApiService.PreOrderAuthentication
- AuthenticationsApiService.PreOrderAuthenticationWithAuth
- RelationsApiService.GetRelation
- TokensApiService.CreateToken
- TransferBatchApiService.CreateTransferBatch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthType ¶
type AuthType string
AuthType
type AuthenticationEntity ¶
type AuthenticationEntity struct { // 服务商商户号 Mchid *string `json:"mchid"` // 特约商户商户号 SubMchid *string `json:"sub_mchid"` // 用户OpenID Openid *string `json:"openid"` // 核身渠道,发起核身时的来源渠道,如通过小程序,硬件设备等 AuthenticateScene *AuthenticationScene `json:"authenticate_scene"` // 核身渠道标识,用于定位渠道具体来源,如果是扫码打卡渠道标识就是具体的小程序AppID,若是硬件设备,则是设备的序列号等 AuthenticateSource *string `json:"authenticate_source"` // 项目名称 ProjectName *string `json:"project_name"` // 该工人所属的用工企业,由商户核身下单时传入 EmployerName *string `json:"employer_name"` // 核身状态 AuthenticateState *AuthenticationState `json:"authenticate_state"` // 核身时间,遵循RFC3339标准格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。 AuthenticateTime *string `json:"authenticate_time,omitempty"` // 商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一 AuthenticateNumber *string `json:"authenticate_number"` // 结果为核身失败时的原因描述,仅在失败记录返回 AuthenticateFailedReason *string `json:"authenticate_failed_reason,omitempty"` // 核身类型 AuthenticateType *AuthenticationType `json:"authenticate_type,omitempty"` }
AuthenticationEntity
func (AuthenticationEntity) Clone ¶
func (o AuthenticationEntity) Clone() *AuthenticationEntity
func (AuthenticationEntity) MarshalJSON ¶
func (o AuthenticationEntity) MarshalJSON() ([]byte, error)
func (AuthenticationEntity) String ¶
func (o AuthenticationEntity) String() string
type AuthenticationScene ¶
type AuthenticationScene string
AuthenticationScene
const ( AUTHENTICATIONSCENE_MINI_APP AuthenticationScene = "FROM_MINI_APP" AUTHENTICATIONSCENE_HARDWARE AuthenticationScene = "FROM_HARDWARE" )
Enums of AuthenticationScene
func (AuthenticationScene) Ptr ¶
func (e AuthenticationScene) Ptr() *AuthenticationScene
type AuthenticationState ¶
type AuthenticationState string
AuthenticationState
const ( AUTHENTICATIONSTATE_PROCESSING AuthenticationState = "AUTHENTICATE_PROCESSING" AUTHENTICATIONSTATE_SUCCESS AuthenticationState = "AUTHENTICATE_SUCCESS" AUTHENTICATIONSTATE_FAILED AuthenticationState = "AUTHENTICATE_FAILED" )
Enums of AuthenticationState
func (AuthenticationState) Ptr ¶
func (e AuthenticationState) Ptr() *AuthenticationState
type AuthenticationType ¶
type AuthenticationType string
AuthenticationType
const ( AUTHENTICATIONTYPE_NORMAL AuthenticationType = "NORMAL" AUTHENTICATIONTYPE_SIGN_IN AuthenticationType = "SIGN_IN" AUTHENTICATIONTYPE_INSURANCE AuthenticationType = "INSURANCE" AUTHENTICATIONTYPE_CONTRACT AuthenticationType = "CONTRACT" )
Enums of AuthenticationType
func (AuthenticationType) Ptr ¶
func (e AuthenticationType) Ptr() *AuthenticationType
type AuthenticationsApiService ¶
func (*AuthenticationsApiService) GetAuthentication ¶
func (a *AuthenticationsApiService) GetAuthentication(ctx context.Context, req GetAuthenticationRequest) (resp *AuthenticationEntity, result *core.APIResult, err error)
GetAuthentication 获取核身结果
按商户拉起核身时预下单的单号获取该次微工卡核身的结果
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.AuthenticationsApiService{Client: client} resp, result, err := svc.GetAuthentication(ctx, payrollcard.GetAuthenticationRequest{ SubMchid: core.String("1111111"), AuthenticateNumber: core.String("mcdhehfgisdhfjghed39384564i83"), }, ) if err != nil { // 处理错误 log.Printf("call GetAuthentication err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*AuthenticationsApiService) ListAuthentications ¶
func (a *AuthenticationsApiService) ListAuthentications(ctx context.Context, req ListAuthenticationsRequest) (resp *ListAuthenticationsResponse, result *core.APIResult, err error)
ListAuthentications 查询核身记录
查询指定用户指定日期微工卡核身记录,查询结果仅展示核身成功的记录
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.AuthenticationsApiService{Client: client} resp, result, err := svc.ListAuthentications(ctx, payrollcard.ListAuthenticationsRequest{ Openid: core.String("onqOjjmo8wmTOOtSKwXtGjg9Gb58"), Appid: core.String("wxa1111111"), SubAppid: core.String("wxa1111111"), SubMchid: core.String("1111111"), AuthenticateDate: core.String("2020-12-25"), AuthenticateState: core.String("AUTHENTICATE_SUCCESS"), Offset: core.Int64(0), Limit: core.Int64(10), }, ) if err != nil { // 处理错误 log.Printf("call ListAuthentications err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*AuthenticationsApiService) PreOrderAuthentication ¶
func (a *AuthenticationsApiService) PreOrderAuthentication(ctx context.Context, req PreOrderAuthenticationRequest) (resp *PreOrderAuthenticationResponse, result *core.APIResult, err error)
PreOrderAuthentication 微工卡核身预下单
服务商在拉起微工卡前端服务给用户做微工卡核身前,需要先调用本接口预下单,下单成功后才能进行核身
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.AuthenticationsApiService{Client: client} resp, result, err := svc.PreOrderAuthentication(ctx, payrollcard.PreOrderAuthenticationRequest{ Openid: core.String("onqOjjmo8wmTOOtSKwXtGjg9Gb58"), Appid: core.String("wxa1111111"), SubMchid: core.String("1111111"), SubAppid: core.String("wxa1111111"), AuthenticateNumber: core.String("mcdhehfgisdhfjghed39384564i83"), ProjectName: core.String("某项目"), EmployerName: core.String("某用工企业"), AuthenticateType: payrollcard.AUTHENTICATIONTYPE_NORMAL.Ptr(), }, ) if err != nil { // 处理错误 log.Printf("call PreOrderAuthentication err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*AuthenticationsApiService) PreOrderAuthenticationWithAuth ¶
func (a *AuthenticationsApiService) PreOrderAuthenticationWithAuth(ctx context.Context, req PreOrderAuthenticationWithAuthRequest) (resp *PreOrderAuthenticationWithAuthResponse, result *core.APIResult, err error)
PreOrderAuthenticationWithAuth 微工卡核身预下单(流程中完成授权)
本接口适用于用户需同步完成服务开通、授权及身份核验的场景。在拉起微工卡前端服务为用户核身前,需调用本接口预下单,下单成功后才能进行核身。如此时用户未开通微工卡服务或未完成对商户的授权,则先完成开通、授权,同步完成身份核验,并提供可信的核验结果。
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.AuthenticationsApiService{Client: client} resp, result, err := svc.PreOrderAuthenticationWithAuth(ctx, payrollcard.PreOrderAuthenticationWithAuthRequest{ Openid: core.String("onqOjjmo8wmTOOtSKwXtGjg9Gb58"), Appid: core.String("wxa1111111"), SubMchid: core.String("1111111"), SubAppid: core.String("wxa1111111"), AuthenticateNumber: core.String("mcdhehfgisdhfjghed39384564i83"), ProjectName: core.String("某项目"), EmployerName: core.String("某用工企业"), UserName: core.String("LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg"), IdCardNumber: core.String("7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5"), EmploymentType: payrollcard.EMPLOYMENTTYPE_LONG_TERM_EMPLOYMENT.Ptr(), AuthenticateType: payrollcard.AUTHENTICATIONTYPE_NORMAL.Ptr(), }, ) if err != nil { // 处理错误 log.Printf("call PreOrderAuthenticationWithAuth err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type BusinessType ¶
type BusinessType string
BusinessType
const ( BUSINESSTYPE_UNDEFINE BusinessType = "UNDEFINE" BUSINESSTYPE_PROMOTION BusinessType = "PROMOTION" )
Enums of BusinessType
func (BusinessType) Ptr ¶
func (e BusinessType) Ptr() *BusinessType
type CreateTokenRequest ¶
type CreateTokenRequest struct { // 用户OpenID Openid *string `json:"openid"` // 当输入服务商AppID时,会校验其与服务商商户号的绑定关系。 服务商AppID和与特约商户AppID至少输入一个,且必须要有拉起微工卡小程序时使用的AppID。 Appid *string `json:"appid,omitempty"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // 当输入特约商户AppID时,会校验其与特约商户号的绑定关系。 服务商AppID和与特约商户AppID至少输入一个,且必须要有拉起微工卡小程序时使用的AppID。 SubAppid *string `json:"sub_appid,omitempty"` // 用户实名信息,按照APIV3标准加密该字段 UserName *string `json:"user_name" encryption:"EM_APIV3"` // 用户证件号,按照APIV3标准加密该字段 IdCardNumber *string `json:"id_card_number" encryption:"EM_APIV3"` // 微工卡服务仅支持用于与商户有用工关系的用户,需明确用工类型;参考值:长期用工:LONG_TERM_EMPLOYMENT,短期用工:SHORT_TERM_EMPLOYMENT,合作关系:COOPERATION_EMPLOYMENT EmploymentType *EmploymentType `json:"employment_type,omitempty"` }
CreateTokenRequest
func (CreateTokenRequest) Clone ¶
func (o CreateTokenRequest) Clone() *CreateTokenRequest
func (CreateTokenRequest) MarshalJSON ¶
func (o CreateTokenRequest) MarshalJSON() ([]byte, error)
func (CreateTokenRequest) String ¶
func (o CreateTokenRequest) String() string
type CreateTransferBatchRequest ¶
type CreateTransferBatchRequest struct { // 特约商户号 SubMchid *string `json:"sub_mchid"` // 微信分配的特约商户公众账号ID,特约商户授权类型为INFORMATION_AUTHORIZATION_TYPE和INFORMATION_AND_FUND_AUTHORIZATION_TYPE时 需要填写 SubAppid *string `json:"sub_appid,omitempty"` // 特约商户授权类型 AuthorizationType *AuthType `json:"authorization_type"` // 商户系统内部的商家批次单号,在商户系统内部唯一 OutBatchNo *string `json:"out_batch_no"` // 该笔批量转账的名称 BatchName *string `json:"batch_name"` // 转账说明,UTF8编码,最多允许32个字符 BatchRemark *string `json:"batch_remark"` // 转账金额单位为“分”。转账总金额必须与批次内所有明细转账金额之和保持一致,否则无法发起转账操作 TotalAmount *int64 `json:"total_amount"` // 一个转账批次单最多发起三千笔转账。转账总笔数必须与批次内所有明细之和保持一致,否则无法发起转账操作 TotalNum *int64 `json:"total_num"` // 发起批量转账的明细列表,最多三千笔 TransferDetailList []TransferDetailInput `json:"transfer_detail_list"` // 微信分配的服务商商户公众账号ID,特约商户授权类型为FUND_AUTHORIZATION_TYPE时 需要填写 SpAppid *string `json:"sp_appid,omitempty"` // 微工卡服务仅支持用于与商户有用工关系的用户,需明确用工类型;参考值:长期用工:LONG_TERM_EMPLOYMENT,短期用工:SHORT_TERM_EMPLOYMENT,合作关系:COOPERATION_EMPLOYMENT EmploymentType *EmploymentType `json:"employment_type,omitempty"` // 用工场景;参考值:LOGISTICS:物流;MANUFACTURING:制造业;HOTEL:酒店;CATERING:餐饮业;EVENT:活动促销;RETAIL:零售;OTHERS:其他 EmploymentScene *EmploymentScene `json:"employment_scene,omitempty"` // 传入业务ID后必填,区分不同任务来源于哪个业务系统 BusinessType *BusinessType `json:"business_type,omitempty"` }
CreateTransferBatchRequest
func (CreateTransferBatchRequest) Clone ¶
func (o CreateTransferBatchRequest) Clone() *CreateTransferBatchRequest
func (CreateTransferBatchRequest) MarshalJSON ¶
func (o CreateTransferBatchRequest) MarshalJSON() ([]byte, error)
func (CreateTransferBatchRequest) String ¶
func (o CreateTransferBatchRequest) String() string
type EmploymentScene ¶
type EmploymentScene string
EmploymentScene
const ( EMPLOYMENTSCENE_LOGISTICS EmploymentScene = "LOGISTICS" EMPLOYMENTSCENE_MANUFACTURING EmploymentScene = "MANUFACTURING" EMPLOYMENTSCENE_HOTEL EmploymentScene = "HOTEL" EMPLOYMENTSCENE_CATERING EmploymentScene = "CATERING" EMPLOYMENTSCENE_EVENT EmploymentScene = "EVENT" EMPLOYMENTSCENE_RETAIL EmploymentScene = "RETAIL" EMPLOYMENTSCENE_OTHERS EmploymentScene = "OTHERS" )
Enums of EmploymentScene
func (EmploymentScene) Ptr ¶
func (e EmploymentScene) Ptr() *EmploymentScene
type EmploymentType ¶
type EmploymentType string
EmploymentType
const ( EMPLOYMENTTYPE_LONG_TERM_EMPLOYMENT EmploymentType = "LONG_TERM_EMPLOYMENT" EMPLOYMENTTYPE_SHORT_TERM_EMPLOYMENT EmploymentType = "SHORT_TERM_EMPLOYMENT" EMPLOYMENTTYPE_COOPERATION_EMPLOYMENT EmploymentType = "COOPERATION_EMPLOYMENT" )
Enums of EmploymentType
func (EmploymentType) Ptr ¶
func (e EmploymentType) Ptr() *EmploymentType
type GetAuthenticationRequest ¶
type GetAuthenticationRequest struct { // 特约商户号 SubMchid *string `json:"sub_mchid"` // 商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一 AuthenticateNumber *string `json:"authenticate_number"` }
GetAuthenticationRequest
func (GetAuthenticationRequest) Clone ¶
func (o GetAuthenticationRequest) Clone() *GetAuthenticationRequest
func (GetAuthenticationRequest) MarshalJSON ¶
func (o GetAuthenticationRequest) MarshalJSON() ([]byte, error)
func (GetAuthenticationRequest) String ¶
func (o GetAuthenticationRequest) String() string
type GetRelationRequest ¶
type GetRelationRequest struct { // 微信用户OpenID Openid *string `json:"openid"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // 当输入服务商AppID时会校验其与服务商商户号绑定关系。 服务商AppID和特约商户AppID至少输入一个。 Appid *string `json:"appid,omitempty"` // 当输入特约商户AppID时会校验其与特约商户号关系。 特约商户AppID和服务商AppID至少输入一个。 SubAppid *string `json:"sub_appid,omitempty"` }
GetRelationRequest
func (GetRelationRequest) Clone ¶
func (o GetRelationRequest) Clone() *GetRelationRequest
func (GetRelationRequest) MarshalJSON ¶
func (o GetRelationRequest) MarshalJSON() ([]byte, error)
func (GetRelationRequest) String ¶
func (o GetRelationRequest) String() string
type ListAuthenticationsRequest ¶
type ListAuthenticationsRequest struct { // 微信用户OpenID Openid *string `json:"openid"` // 当输入服务商AppID时会校验其与服务商商户号绑定关系。 服务商AppID和特约商户AppID至少输入一个。 Appid *string `json:"appid,omitempty"` // 当输入特约商户AppID时会校验其与特约商户号关系。 特约商户AppID和服务商AppID至少输入一个。 SubAppid *string `json:"sub_appid,omitempty"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // 核身日期,一次只能查询一天,最久可查询90天内的记录,格式为“yyyy-MM-DD” AuthenticateDate *string `json:"authenticate_date"` // 核身状态,列表查询仅提供成功状态的核身记录查询,故此字段固定默认值即可 AuthenticateState *string `json:"authenticate_state,omitempty"` // 非负整数,表示该次请求资源的起始位置,从0开始计数。调用方选填,默认为0。offset为10,limit为10时,查询第10-19条数据 Offset *int64 `json:"offset,omitempty"` // 非0非负的整数,该次请求可返回的最大资源条数,默认值为10,最大支持10条。 Limit *int64 `json:"limit,omitempty"` }
ListAuthenticationsRequest
func (ListAuthenticationsRequest) Clone ¶
func (o ListAuthenticationsRequest) Clone() *ListAuthenticationsRequest
func (ListAuthenticationsRequest) MarshalJSON ¶
func (o ListAuthenticationsRequest) MarshalJSON() ([]byte, error)
func (ListAuthenticationsRequest) String ¶
func (o ListAuthenticationsRequest) String() string
type ListAuthenticationsResponse ¶
type ListAuthenticationsResponse struct { // 查询结果记录列表 Data []AuthenticationEntity `json:"data,omitempty"` // 经过条件筛选,查询到的记录总数 TotalCount *int64 `json:"total_count"` // 该次请求资源的起始位置,请求中包含偏移量时应答消息返回相同偏移量,否则返回默认值0 Offset *int64 `json:"offset"` // 经过条件筛选,本次查询到的记录条数 Limit *int64 `json:"limit"` }
ListAuthenticationsResponse
func (ListAuthenticationsResponse) Clone ¶
func (o ListAuthenticationsResponse) Clone() *ListAuthenticationsResponse
func (ListAuthenticationsResponse) MarshalJSON ¶
func (o ListAuthenticationsResponse) MarshalJSON() ([]byte, error)
func (ListAuthenticationsResponse) String ¶
func (o ListAuthenticationsResponse) String() string
type PayrollCardRegisterState ¶
type PayrollCardRegisterState string
PayrollCardRegisterState
const ( PAYROLLCARDREGISTERSTATE_UNDEFINED PayrollCardRegisterState = "UNDEFINED" PAYROLLCARDREGISTERSTATE_UNREGISTERED PayrollCardRegisterState = "UNREGISTERED" PAYROLLCARDREGISTERSTATE_REGISTERED PayrollCardRegisterState = "REGISTERED" PAYROLLCARDREGISTERSTATE_CLOSED PayrollCardRegisterState = "CLOSED" )
Enums of PayrollCardRegisterState
func (PayrollCardRegisterState) Ptr ¶
func (e PayrollCardRegisterState) Ptr() *PayrollCardRegisterState
type PreOrderAuthenticationRequest ¶
type PreOrderAuthenticationRequest struct { // 用户OpenID Openid *string `json:"openid"` // 当输入服务商AppID时,会校验其与服务商商户号的绑定关系。服务商AppID和与特约商户AppID至少输入一个,且必须要有拉起微工卡小程序时使用的AppID。 Appid *string `json:"appid,omitempty"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // 当输入特约商户AppID时,会校验其与特约商户号的绑定关系。服务商AppID和与特约商户AppID至少输入一个,且必须要有拉起微工卡小程序时使用的AppID。 SubAppid *string `json:"sub_appid,omitempty"` // 商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一 AuthenticateNumber *string `json:"authenticate_number"` // 该劳务活动的项目名称 ProjectName *string `json:"project_name"` // 该工人所属的用工企业 EmployerName *string `json:"employer_name"` // 核身类型 AuthenticateType *AuthenticationType `json:"authenticate_type,omitempty"` }
PreOrderAuthenticationRequest
func (PreOrderAuthenticationRequest) Clone ¶
func (o PreOrderAuthenticationRequest) Clone() *PreOrderAuthenticationRequest
func (PreOrderAuthenticationRequest) MarshalJSON ¶
func (o PreOrderAuthenticationRequest) MarshalJSON() ([]byte, error)
func (PreOrderAuthenticationRequest) String ¶
func (o PreOrderAuthenticationRequest) String() string
type PreOrderAuthenticationResponse ¶
type PreOrderAuthenticationResponse struct { // 商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一 AuthenticateNumber *string `json:"authenticate_number"` // 微信用户OpenID Openid *string `json:"openid"` // 商户号 Mchid *string `json:"mchid"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // token值 Token *string `json:"token"` // token有效时间,单位秒 ExpiresIn *int64 `json:"expires_in"` }
PreOrderAuthenticationResponse
func (PreOrderAuthenticationResponse) Clone ¶
func (o PreOrderAuthenticationResponse) Clone() *PreOrderAuthenticationResponse
func (PreOrderAuthenticationResponse) MarshalJSON ¶
func (o PreOrderAuthenticationResponse) MarshalJSON() ([]byte, error)
func (PreOrderAuthenticationResponse) String ¶
func (o PreOrderAuthenticationResponse) String() string
type PreOrderAuthenticationWithAuthRequest ¶
type PreOrderAuthenticationWithAuthRequest struct { // 用户OpenID Openid *string `json:"openid"` // 当输入服务商AppID时,会校验其与服务商商户号的绑定关系。服务商AppID和与特约商户AppID至少输入一个,且必须要有拉起微工卡小程序时使用的AppID。 Appid *string `json:"appid,omitempty"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // 当输入特约商户AppID时,会校验其与特约商户号的绑定关系。服务商AppID和与特约商户AppID至少输入一个,且必须要有拉起微工卡小程序时使用的AppID。 SubAppid *string `json:"sub_appid,omitempty"` // 商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一 AuthenticateNumber *string `json:"authenticate_number"` // 该劳务活动的项目名称 ProjectName *string `json:"project_name"` // 该工人所属的用工企业 EmployerName *string `json:"employer_name"` // 用户实名信息,按照APIV3标准加密该字段 UserName *string `json:"user_name" encryption:"EM_APIV3"` // 用户证件号,按照APIV3标准加密该字段 IdCardNumber *string `json:"id_card_number" encryption:"EM_APIV3"` // 微工卡服务仅支持用于与商户有用工关系的用户,需明确用工类型;非必填;未授权必填,授权过,非必填,如填写,需要校验和初次填写的一致性;参考值:长期用工:LONG_TERM_EMPLOYMENT,短期用工:SHORT_TERM_EMPLOYMENT,合作关系:COOPERATION_EMPLOYMENT EmploymentType *EmploymentType `json:"employment_type"` // 核身类型 AuthenticateType *AuthenticationType `json:"authenticate_type,omitempty"` }
PreOrderAuthenticationWithAuthRequest
func (PreOrderAuthenticationWithAuthRequest) Clone ¶
func (o PreOrderAuthenticationWithAuthRequest) Clone() *PreOrderAuthenticationWithAuthRequest
func (PreOrderAuthenticationWithAuthRequest) MarshalJSON ¶
func (o PreOrderAuthenticationWithAuthRequest) MarshalJSON() ([]byte, error)
func (PreOrderAuthenticationWithAuthRequest) String ¶
func (o PreOrderAuthenticationWithAuthRequest) String() string
type PreOrderAuthenticationWithAuthResponse ¶
type PreOrderAuthenticationWithAuthResponse struct { // 商户系统内部的商家核身单号,要求此参数只能由数字、大小写字母组成,在服务商内部唯一 AuthenticateNumber *string `json:"authenticate_number"` // 微信用户OpenID Openid *string `json:"openid"` // 商户号 Mchid *string `json:"mchid"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // token值 Token *string `json:"token"` // token有效时间,单位秒 ExpiresIn *int64 `json:"expires_in"` }
PreOrderAuthenticationWithAuthResponse
func (PreOrderAuthenticationWithAuthResponse) Clone ¶
func (o PreOrderAuthenticationWithAuthResponse) Clone() *PreOrderAuthenticationWithAuthResponse
func (PreOrderAuthenticationWithAuthResponse) MarshalJSON ¶
func (o PreOrderAuthenticationWithAuthResponse) MarshalJSON() ([]byte, error)
func (PreOrderAuthenticationWithAuthResponse) String ¶
func (o PreOrderAuthenticationWithAuthResponse) String() string
type RelationEntity ¶
type RelationEntity struct { // 用户OpenID Openid *string `json:"openid"` // 商户号 Mchid *string `json:"mchid"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // 授权状态:UNAUTHORIZED:未授权 AUTHORIZED:已授权 DEAUTHORIZED:已取消授权 AuthorizeState *string `json:"authorize_state"` // 授权时间 AuthorizeTime *string `json:"authorize_time,omitempty"` DeauthorizeTime *string `json:"deauthorize_time,omitempty"` // 微工卡的开通状态:UNREGISTERED:未开通;REGISTERED:已开通;CLOSED:已关闭 RegisterState *PayrollCardRegisterState `json:"register_state"` // 开通时间,未开通时不返回。遵循RFC3339标准格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。 RegisterTime *string `json:"register_time,omitempty"` // 关闭时间,仅当开通状态是已关闭时返回。遵循RFC3339标准格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。 CloseTime *string `json:"close_time,omitempty"` }
RelationEntity
func (RelationEntity) Clone ¶
func (o RelationEntity) Clone() *RelationEntity
func (RelationEntity) MarshalJSON ¶
func (o RelationEntity) MarshalJSON() ([]byte, error)
func (RelationEntity) String ¶
func (o RelationEntity) String() string
type RelationsApiService ¶
func (*RelationsApiService) GetRelation ¶
func (a *RelationsApiService) GetRelation(ctx context.Context, req GetRelationRequest) (resp *RelationEntity, result *core.APIResult, err error)
GetRelation 查询微工卡授权关系
查询商户和微信支付用户的微工卡授权关系
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.RelationsApiService{Client: client} resp, result, err := svc.GetRelation(ctx, payrollcard.GetRelationRequest{ Openid: core.String("onqOjjmo8wmTOOtSKwXtGjg9Gb58"), SubMchid: core.String("1111111"), Appid: core.String("wxa1111111"), SubAppid: core.String("wxa1111111"), }, ) if err != nil { // 处理错误 log.Printf("call GetRelation err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type TokenEntity ¶
type TokenEntity struct { // 微信用户OpenID Openid *string `json:"openid"` // 商户号 Mchid *string `json:"mchid"` // 特约商户号 SubMchid *string `json:"sub_mchid"` // token值 Token *string `json:"token"` // token有效时间,单位秒 ExpiresIn *int64 `json:"expires_in"` }
TokenEntity
func (TokenEntity) Clone ¶
func (o TokenEntity) Clone() *TokenEntity
func (TokenEntity) MarshalJSON ¶
func (o TokenEntity) MarshalJSON() ([]byte, error)
func (TokenEntity) String ¶
func (o TokenEntity) String() string
type TokensApiService ¶
func (*TokensApiService) CreateToken ¶
func (a *TokensApiService) CreateToken(ctx context.Context, req CreateTokenRequest) (resp *TokenEntity, result *core.APIResult, err error)
CreateToken 生成授权token
生成授权token信息
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.TokensApiService{Client: client} resp, result, err := svc.CreateToken(ctx, payrollcard.CreateTokenRequest{ Openid: core.String("onqOjjmo8wmTOOtSKwXtGjg9Gb58"), Appid: core.String("wxa1111111"), SubMchid: core.String("1111111"), SubAppid: core.String("wxa1111111"), UserName: core.String("LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg"), IdCardNumber: core.String("7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5"), EmploymentType: payrollcard.EMPLOYMENTTYPE_LONG_TERM_EMPLOYMENT.Ptr(), }, ) if err != nil { // 处理错误 log.Printf("call CreateToken err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type TransferBatchApiService ¶
func (*TransferBatchApiService) CreateTransferBatch ¶
func (a *TransferBatchApiService) CreateTransferBatch(ctx context.Context, req CreateTransferBatchRequest) (resp *TransferBatchEntity, result *core.APIResult, err error)
CreateTransferBatch 发起批量转账
## 发起批量转账
服务商可以通过该接口,批量向用户零钱进行转账操作。请求消息中应包含特约商户号、特约商户授权的AppID、授权类型、商家批次单号、转账名称、转账总金额、转账总笔数、转账OpenID、收款用户姓名、服务商AppID、转账用途等信息 1、当特约商户授权类型为INFORMATION\_AUTHORIZATION\_TYPE(特约商户信息授权),需要填特约商户的公众号AppID,特约商户公众号AppID的用户的OpenID 2、当特约商户授权类型为FUND\_AUTHORIZATION\_TYPE(特约商户资金授权),需要填服务商的公众号AppID,服务商公众号AppID的用户的OpenID
接口限频: 单个服务商(发起批量转账接口)50QPS,如果超过频率限制,会报错FREQUENCY\_LIMITED,请降低频率请求。
注意事项:
* 因服务商自身系统设置存在问题导致的资金损失,由服务商自行承担。 * 批量转账一旦发起后,不允许撤销。 * 转账批次单和明细单中涉及金额的字段单位为“分”。 * 微信支付视任何不同“发起的服务商商户号+商家批次单号(out\_batch\_no)”的请求为一个全新的批次。在未查询到明确的转账批次单处理结果之前,请勿修改商家批次单号重新提交!如有发生,服务商应当自行承担因此产生的所有损失和责任。 * 当返回错误时,请不要更换商家批次单号,一定要使用原商家批次单号重试,否则可能造成重复转账等资金风险。 * 如果遇到回包返回新的错误码,请务必不要换单重试,请联系客服确认转账情况。如果有新的错误码,会更新到此API文档中。 * 错误码描述字段message只供人工定位问题时做参考,系统实现时请不要依赖这个字段来做自动化处理。 * 请服务商在自身的系统中合理设置转账频次并做好并发控制,防范错付风险。
Example ¶
package main import ( "context" "log" "github.com/Marek-maxs/wechatpay-go/core" "github.com/Marek-maxs/wechatpay-go/core/option" "github.com/Marek-maxs/wechatpay-go/services/payrollcard" "github.com/Marek-maxs/wechatpay-go/utils" ) func main() { var ( mchID string = "190000****" // 商户号 mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号 mchAPIv3Key string = "2ab9****************************" // 商户APIv3密钥 ) // 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名 mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem") if err != nil { log.Printf("load merchant private key error:%s", err) return } ctx := context.Background() // 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力 opts := []core.ClientOption{ option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key), } client, err := core.NewClient(ctx, opts...) if err != nil { log.Printf("new wechat pay client err:%s", err) return } svc := payrollcard.TransferBatchApiService{Client: client} resp, result, err := svc.CreateTransferBatch(ctx, payrollcard.CreateTransferBatchRequest{ SubMchid: core.String("1900000109"), SubAppid: core.String("wxf636efh567hg4356"), AuthorizationType: payrollcard.AUTHTYPE_INFORMATION_AUTHORIZATION_TYPE.Ptr(), OutBatchNo: core.String("plfk2020042013"), BatchName: core.String("2019年1月深圳分部报销单"), BatchRemark: core.String("2019年1月深圳分部报销单"), TotalAmount: core.Int64(4000000), TotalNum: core.Int64(200), TransferDetailList: []payrollcard.TransferDetailInput{payrollcard.TransferDetailInput{ OutDetailNo: core.String("x23zy545Bd5436"), TransferAmount: core.Int64(200000), TransferRemark: core.String("2020年4月报销"), Openid: core.String("o-MYE42l80oelYMDE34nYD456Xoy"), UserName: core.String("757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45"), }}, SpAppid: core.String("wxf636efh567hg4388"), EmploymentType: payrollcard.EMPLOYMENTTYPE_LONG_TERM_EMPLOYMENT.Ptr(), EmploymentScene: payrollcard.EMPLOYMENTSCENE_LOGISTICS.Ptr(), BusinessType: payrollcard.BUSINESSTYPE_UNDEFINE.Ptr(), }, ) if err != nil { // 处理错误 log.Printf("call CreateTransferBatch err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type TransferBatchEntity ¶
type TransferBatchEntity struct { // 商户系统内部的商家批次单号,在商户系统内部唯一 OutBatchNo *string `json:"out_batch_no"` // 微信支付批次单号,微信商家转账系统返回的唯一标识 BatchId *string `json:"batch_id"` // 批次受理成功时返回,按照使用rfc3339所定义的格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE CreateTime *time.Time `json:"create_time"` }
TransferBatchEntity
func (TransferBatchEntity) Clone ¶
func (o TransferBatchEntity) Clone() *TransferBatchEntity
func (TransferBatchEntity) MarshalJSON ¶
func (o TransferBatchEntity) MarshalJSON() ([]byte, error)
func (TransferBatchEntity) String ¶
func (o TransferBatchEntity) String() string
type TransferDetailInput ¶
type TransferDetailInput struct { // 商户系统内部区分转账批次单下不同转账明细单的唯一标识 OutDetailNo *string `json:"out_detail_no"` // 转账金额单位为“分” TransferAmount *int64 `json:"transfer_amount"` // 单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符 TransferRemark *string `json:"transfer_remark"` // 收款用户OpenID。如果转账特约商户授权类型是INFORMATION_AUTHORIZATION_TYPE,对应的是特约商户公众号下的OpenID。 Openid *string `json:"openid"` // 收款用户姓名。采用标准RSA算法,公钥由微信侧提供 明细转账金额 >= 2,000时,该笔明细必须填写收款用户姓名 同一批次转账明细中的姓名字段传入规则需保持一致,也即全部填写、或全部不填写 若商户传入收款用户姓名,微信支付会校验用户OpenID与姓名是否一致,并提供电子回单 UserName *string `json:"user_name" encryption:"EM_APIV3"` }
TransferDetailInput
func (TransferDetailInput) Clone ¶
func (o TransferDetailInput) Clone() *TransferDetailInput
func (TransferDetailInput) MarshalJSON ¶
func (o TransferDetailInput) MarshalJSON() ([]byte, error)
func (TransferDetailInput) String ¶
func (o TransferDetailInput) String() string