Documentation
¶
Index ¶
- Constants
- func Applyment(cli *Client, params *ApplymentReq) (applymentId int64, err error)
- func CombineTransaction(v3 *Client, order CombinePayOrder) (result map[string]string, err error)
- func ModifySettlement(cli *Client, params *ModifySettlementReq) (flag bool, err error)
- func Transaction(v3 *Client, order PayOrder) (result map[string]string, err error)
- type AdditionInfo
- type AppInfo
- type ApplymentQueryReply
- type ApplymentReply
- type ApplymentReq
- type BizStoreInfo
- type BusinessLicenseInfo
- type CertResponse
- type CertificateInfo
- type Client
- func (cli *Client) DecryptData(encryptData EncryptData) (data []byte, err error)
- func (cli *Client) DoGet(url string, needVerify ...bool) (resp []byte, err error)
- func (cli *Client) DoPost(url, body string, needVerify ...bool) (resp []byte, httpCode int, err error)
- func (cli *Client) GetPayResult(body []byte) (resp PayResp, result PayResult, err error)
- func (cli *Client) GetWechatCertificate() (err error)
- func (cli *Client) ImageUpload(content []byte, filename string) (mediaId string, err error)
- func (cli *Client) SecretFieldEncrypt(plaintext []byte) (ciphertext string, err error)
- func (cli *Client) Sign(method, url, body, nonce string) (sign string, err error)
- func (cli *Client) SignStr(str string) (sign string, err error)
- func (cli *Client) Verify(resp *http.Response, body []byte) bool
- type CombinePayOrder
- type CombinePayResult
- type CombineSubOrder
- type EncryptData
- type GoodsDetail
- type GoodsInfo
- type IdCardInfo
- type IdDocInfo
- type MiniProgramInfo
- type ModifySettlementReq
- type MpInfo
- type OrganizationInfo
- type PayDetail
- type PayOrder
- type PayResp
- type PayResult
- type PromotionDetail
- type QuerySettlementReply
- type SceneInfo
- type SettleInfo
- type StoreInfo
- type Time
- type UboInfo
- type WebInfo
- type WeworkInfo
Constants ¶
View Source
const ( GATEWAY = "https://api.mch.weixin.qq.com" UserAgent = "User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0" )
View Source
const ( PayTypeAPP = "app" PayTypeJSAPI = "jsapi" PayTypeNative = "native" PayTypeH5 = "h5" )
View Source
const DEBUG bool = true
View Source
const Fmt = time.RFC3339
Variables ¶
This section is empty.
Functions ¶
func Applyment ¶
func Applyment(cli *Client, params *ApplymentReq) (applymentId int64, err error)
提交申请单API doc: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_1.shtml
func CombineTransaction ¶
func CombineTransaction(v3 *Client, order CombinePayOrder) (result map[string]string, err error)
func ModifySettlement ¶
func ModifySettlement(cli *Client, params *ModifySettlementReq) (flag bool, err error)
修改结算帐号API doc: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_3.shtml
Types ¶
type AdditionInfo ¶
type AdditionInfo struct { LegalPersonCommitment string `json:"legal_person_commitment,omitempty"` // 法人开户承诺函 LegalPersonVideo string `json:"legal_person_video,omitempty"` // 法人开户意愿视频 BusinessAdditionPics string `json:"business_addition_pics,omitempty"` // 补充材料 BusinessAdditionMsg string `json:"business_addition_msg,omitempty"` // 补充说明 }
type ApplymentQueryReply ¶
type ApplymentQueryReply struct { BusinessCode string `json:"business_code"` // 业务申请编号 ApplymentId int64 `json:"applyment_id"` // 微信支付申请单号 SubMchid string `json:"sub_mchid"` // 特约商户号 SignUrl string `json:"sign_url"` // 超级管理员签约链接 ApplymentState string `json:"applyment_state"` // 申请单状态 ApplymentStateMsg string `json:"applyment_state_msg"` // 申请状态描述 AuditDetail struct { Field string `json:"field"` // 字段名 FieldName string `json:"field_name"` // 字段名称 RejectReason string `json:"reject_reason"` // 驳回原因 } `json:"audit_detail"` // 驳回原因详情 }
func QueryApplymentState ¶
func QueryApplymentState(cli *Client, applymentId int64) (state *ApplymentQueryReply, err error)
查询申请单状态API doc: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_2.shtml
func QueryApplymentStateByCode ¶
func QueryApplymentStateByCode(cli *Client, bussinessCode string) (state *ApplymentQueryReply, err error)
通过业务申请编号查询申请状态
type ApplymentReply ¶
type ApplymentReply struct {
ApplymentId int64 `json:"applyment_id"`
}
type ApplymentReq ¶
type ApplymentReq struct { BusinessCode string `json:"business_code"` // 业务申请编号 ContactInfo struct { ContactName string `json:"contact_name"` // 超级管理员姓名 ContactIdNumber string `json:"contact_id_number,omitempty"` // 超级管理员身份证件号码 Openid string `json:"openid,omitempty"` // 超级管理员微信openid MobilePhone string `json:"mobile_phone"` // 联系手机 ContactEmail string `json:"contact_email,omitempty"` // 邮箱 } `json:"contact_info"` // 超管 SubjectInfo struct { SubjectType string `json:"subject_type"` // 主体类型 BusinessLicenseInfo *BusinessLicenseInfo `json:"business_license_info,omitempty"` // 营业执照 CertificateInfo *CertificateInfo `json:"certificate_info,omitempty"` // 登记证书 OrganizationInfo *OrganizationInfo `json:"organization_info,omitempty"` // 组织机构代码证 CertificateLetterCopy string `json:"certificate_letter_copy,omitempty"` // 单位证明函照片 IdentityInfo struct { IdDocType string `json:"id_doc_type"` // 证件类型 IdCardInfo *IdCardInfo `json:"id_card_info,omitempty"` // 身份证信息 IdDocInfo *IdDocInfo `json:"id_doc_info,omitempty"` // 其他类型证件信息 Owner bool `json:"owner"` // 经营者/法人是否为受益人 } `json:"identity_info"` // 经营者/法人身份证件 UboInfo *UboInfo `json:"ubo_info,omitempty"` // 最终受益人信息 } `json:"subject_info"` // 主体资料 BusinessInfo struct { MerchantShortname string `json:"merchant_shortname"` // 商户简称 ServicePhone string `json:"service_phone"` // 客服电话 SalesInfo struct { SalesScenesType string `json:"sales_scenes_type"` // 经营场景类型 BizStoreInfo *BizStoreInfo `json:"biz_store_info,omitempty"` // 线下门店场景 MpInfo *MpInfo `json:"mp_info,omitempty"` // 公众号场景 MiniProgramInfo *MiniProgramInfo `json:"mini_program_info,omitempty"` // 小程序场景 AppInfo *AppInfo `json:"app_info,omitempty"` // APP场景 WebInfo *WebInfo `json:"web_info,omitempty"` // 互联网网站场景 WeworkInfo *WeworkInfo `json:"wework_info,omitempty"` // 企业微信场景 } `json:"sales_info"` // 经营场景 } `json:"business_info"` // 经营资料 SettlementInfo struct { SettlementId string `json:"settlement_id"` // 入驻结算规则ID QualificationType string `json:"qualification_type"` // 所属行业 Qualifications string `json:"qualifications,omitempty"` // 特殊资质图片 ActivitiesId string `json:"activities_id,omitempty"` // 优惠费率活动ID ActivitiesRate string `json:"activities_rate,omitempty"` // 优惠费率活动值 ActivitiesAdditions string `json:"activities_additions,omitempty"` // 优惠费率活动补充材料 } `json:"settlement_info"` // 结算规则 BankAccountInfo struct { BankAccountType string `json:"bank_account_type"` // 账户类型 AccountName string `json:"account_name"` // 开户名称 AccountBank string `json:"account_bank"` // 开户银行 BankAddressCode string `json:"bank_address_code"` // 开户银行省市编码 BankBranchId string `json:"bank_branch_id,omitempty"` // 开户银行联行号 BankName string `json:"bank_name,omitempty"` // 开户银行全称(含支行) AccountNumber string `json:"account_number"` // 银行账号 } `json:"bank_account_info"` // 结算银行账户 AdditionInfo *AdditionInfo `json:"addition_info,omitempty"` // 补充材料 }
type BizStoreInfo ¶
type BizStoreInfo struct { BizStoreName string `json:"biz_store_name"` // 门店名称 BizAddressCode string `json:"biz_address_code"` // 门店省市编码 BizStoreAddress string `json:"biz_store_address"` // 门店地址 StoreEntrancePic string `json:"store_entrance_pic"` // 门店门头照片 IndoorPic string `json:"indoor_pic"` // 店内环境照片 BizSubAppid string `json:"biz_sub_appid"` // 线下场所对应的商家APPID }
type BusinessLicenseInfo ¶
type CertResponse ¶
type CertResponse struct { Data []struct { SerialNo string `json:"serial_no"` // 证书序列号 EffectiveTime string `json:"effective_time"` // 生效时间 ExpireTime string `json:"expire_time"` // 过期时间 EncryptCertificate EncryptData `json:"encrypt_certificate"` // 证书内容 } `json:"data"` }
type CertificateInfo ¶
type CertificateInfo struct { CertCopy string `json:"cert_copy"` // 登记证书照片 CertType string `json:"cert_type"` // 登记证书类型 CertNumber string `json:"cert_number"` // 证书号 MerchantName string `json:"merchant_name"` // 商户名称 CompanyAddress string `json:"company_address"` // 注册地址 LegalPerson string `json:"legal_person"` // 法定代表人 PeriodBegin string `json:"period_begin"` // 有效期限开始日期 PeriodEnd string `json:"period_end"` // 有效期限结束日期 }
type Client ¶
type Client struct { GateWay string // 网关 Isv bool // 是否是服务商client MerchantId string // 商户id SerialNumber string // 商户序列号 AppSecret string // 商户密钥 微信支付在回调通知和平台证书下载接口中,对关键信息进行了AES-256-GCM加密 PrivateKey *rsa.PrivateKey // 商户API私钥 WechatCertificate *x509.Certificate // 平台证书 WechatSerialNumber string // 微信平台序列号 // contains filtered or unexported fields }
var Cli *Client // 默认客户端
func NewClient ¶
func NewClient(isv bool, merchantId, serialNumber, appSecret, keyFile string) (cli *Client, err error)
实例化一个客户端
func (*Client) DecryptData ¶ added in v1.2.0
func (cli *Client) DecryptData(encryptData EncryptData) (data []byte, err error)
func (*Client) DoPost ¶
func (cli *Client) DoPost(url, body string, needVerify ...bool) (resp []byte, httpCode int, err error)
POST一个API
func (*Client) GetPayResult ¶ added in v1.2.0
func (*Client) GetWechatCertificate ¶
获取微信支付平台证书 平台证书会周期性更换。建议商户定时通过API下载新的证书 可以弄个Cronjob线程周期执行这个方法
func (*Client) ImageUpload ¶
图片上传 https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/chapter3_1.shtml
func (*Client) SecretFieldEncrypt ¶
敏感信息加密 https://wechatpay-api.gitbook.io/wechatpay-api-v3/qian-ming-zhi-nan-1/min-gan-xin-xi-jia-mi
type CombinePayOrder ¶
type CombinePayOrder struct { Type string `json:"-"` AppID string `json:"combine_appid,omitempty"` // 服务商appid MchID string `json:"combine_mchid,omitempty"` // 服务商mchid OutTradeNo string `json:"combine_out_trade_no"` SceneInfo *SceneInfo `json:"scene_info,omitempty"` SubOrders []*CombineSubOrder `json:"sub_orders"` PayInfo struct { OpenID string `json:"openid,omitempty"` } `json:"combine_payer_info,omitempty"` TimeStart *Time `json:"time_start,omitempty"` TimeExpire *Time `json:"time_expire,omitempty"` NotifyURL string `json:"notify_url"` }
type CombinePayResult ¶ added in v1.2.0
type CombinePayResult struct { MchID string `json:"mchid,omitempty"` // 服务商mchid SubMchID string `json:"sub_mchid,omitempty"` // 子商户mchid TransactionID string `json:"transaction_id"` OutTradeNo string `json:"out_trade_no"` TradeType string `json:"trade_type"` // 交易类型 TradeState string `json:"trade_state"` // 交易类型 TradeStateDesc string `json:"trade_state_desc,omitempty"` // 交易状态描述 BankType string `json:"bank_type,omitempty"` // 银行类型 Attach string `json:"attach,omitempty"` SuccessTime *Time `json:"success_time,omitempty"` Amount struct { Total int64 `json:"total"` PayerTotal int64 `json:"payer_total"` Currency string `json:"currency,omitempty"` PayerCurrency string `json:"payer_currency"` } `json:"amount"` }
type CombineSubOrder ¶
type CombineSubOrder struct { MchID string `json:"mchid"` SubMchID string `json:"sub_mchid"` Description string `json:"description"` OutTradeNo string `json:"out_trade_no"` Attach string `json:"attach"` Amount struct { Total int64 `json:"total"` Currency string `json:"currency,omitempty"` } `json:"amount"` SettleInfo *SettleInfo `json:"settle_info,omitempty"` }
type EncryptData ¶ added in v1.2.0
type GoodsDetail ¶ added in v1.2.0
type IdCardInfo ¶
type IdCardInfo struct { IdCardCopy string `json:"id_card_copy"` // 身份证人像面照片 IdCardNational string `json:"id_card_national"` // 身份证国徽面照片 IdCardName string `json:"id_card_name"` // 身份证姓名 IdCardNumber string `json:"id_card_number"` // 身份证号码 CardPeriodBegin string `json:"card_period_begin"` // 身份证有效期开始时间 CardPeriodEnd string `json:"card_period_end"` // 身份证有效期结束时间 }
type MiniProgramInfo ¶
type ModifySettlementReq ¶
type ModifySettlementReq struct { SubMchid string `json:"sub_mchid"` // 特约商户号 AccountType string `json:"account_type"` // 账户类型 AccountBank string `json:"account_bank"` // 开户银行 BankAddressCode string `json:"bank_address_code"` // 开户银行省市编码 BankName string `json:"bank_name,omitempty"` // 开户银行全称(含支行) BankBranchId string `json:"bank_branch_id,omitempty"` // 开户银行联行号 AccountNumber string `json:"account_number"` // 银行账号 }
type OrganizationInfo ¶
type PayOrder ¶
type PayOrder struct { Type string `json:"-"` // isv模式,除了sub app 均为必须 SpAppID string `json:"sp_appid,omitempty"` // 服务商appid SpMchID string `json:"sp_mchid,omitempty"` // 服务商mchid SubAppID string `json:"sub_appid,omitempty"` // 子账户appid SubMchID string `json:"sub_mchid,omitempty"` // 子商户mchid // 非isv模式,必须 AppID string `json:"appid,omitempty"` // 公众号ID MchID string `json:"mchid,omitempty"` Description string `json:"description"` OutTradeNo string `json:"out_trade_no"` TimeExpire *Time `json:"time_expire,omitempty"` Attach string `json:"attach,omitempty"` NotifyURL string `json:"notify_url"` GoodsTag string `json:"goods_tag,omitempty"` ProfitSharing string `json:"profit_sharing,omitempty"` // 是否分账 Amount struct { Total int64 `json:"total"` Currency string `json:"currency,omitempty"` } `json:"amount"` Payer struct { OpenID string `json:"openid,omitempty"` SpOpenID string `json:"sp_openid,omitempty"` SubOpenID string `json:"sub_openid,omitempty"` } `json:"payer"` SettleInfo *SettleInfo `json:"settle_info,omitempty"` PayDetail *PayDetail `json:"detail,omitempty"` SceneInfo *SceneInfo `json:"scene_info,omitempty"` }
type PayResult ¶ added in v1.2.0
type PayResult struct { Type string `json:"-"` // isv模式,除了sub app 均为必须 SpAppID string `json:"sp_appid,omitempty"` // 服务商appid SpMchID string `json:"sp_mchid,omitempty"` // 服务商mchid SubAppID string `json:"sub_appid,omitempty"` // 子账户appid SubMchID string `json:"sub_mchid,omitempty"` // 子商户mchid // 合单支付模式 CombineAppID string `json:"combine_appid,omitempty"` // 公众号ID CombineMchID string `json:"combine_mchid,omitempty"` CombineOutTradeNo string `json:"combine_out_trade_no"` CombinePayResult []*CombinePayResult `json:"sub_orders"` CombinePayInfo struct { OpenID string `json:"openid,omitempty"` } `json:"combine_payer_info,omitempty"` // 非isv模式,必须 AppID string `json:"appid,omitempty"` // 公众号ID MchID string `json:"mchid,omitempty"` OutTradeNo string `json:"out_trade_no"` TransactionID string `json:"transaction_id"` TradeType string `json:"trade_type"` // 交易类型 TradeState string `json:"trade_state"` // 交易类型 TradeStateDesc string `json:"trade_state_desc,omitempty"` // 交易状态描述 BankType string `json:"bank_type,omitempty"` // 银行类型 Attach string `json:"attach,omitempty"` SuccessTime *Time `json:"success_time,omitempty"` Amount struct { Total int64 `json:"total"` PayerTotal int64 `json:"payer_total"` Currency string `json:"currency,omitempty"` PayerCurrency string `json:"payer_currency"` } `json:"amount"` Payer struct { OpenID string `json:"openid,omitempty"` SpOpenID string `json:"sp_openid,omitempty"` SubOpenID string `json:"sub_openid,omitempty"` } `json:"payer"` PromotionDetail *PromotionDetail `json:"promotion_detail,omitempty"` SceneInfo struct { DeviceID string `json:"device_id"` } `json:"scene_info,omitempty"` }
type PromotionDetail ¶ added in v1.2.0
type PromotionDetail struct { CouponID string `json:"coupon_id"` Name string `json:"name"` Scope string `json:"scope"` // GLOBAL:全场代金券 SINGLE:单品优惠 Type string `json:"type"` Amount int64 `json:"amount"` StockID string `json:"stock_id"` WechatpayContribute int64 `json:"wechatpay_contribute"` MerchantContribute int64 `json:"merchant_contribute"` OtherContribute int64 `json:"other_contribute"` Currency string `json:"currency,omitempty"` GoodsDetails []*GoodsDetail `json:"goods_detail,omitempty"` }
type QuerySettlementReply ¶
type QuerySettlementReply struct { AccountType string `json:"account_type"` // 账户类型 AccountBank string `json:"account_bank"` // 开户银行 BankName string `json:"bank_name"` // 开户银行全称(含支行) BankBranchId string `json:"bank_branch_id"` // 开户银行联行号 AccountNumber string `json:"account_number"` // 银行账号 VerifyResult string `json:"verify_result"` // 汇款验证结果 }
func QuerySettlement ¶
func QuerySettlement(cli *Client, subMchid string) (reply *QuerySettlementReply, err error)
查询结算账户API
type SettleInfo ¶
type SettleInfo struct { ProfitSharing bool `json:"profit_sharing"` // 是否分账 SubsidyAmount *int64 `json:"subsidy_amount,omitempty"` // 分账补差金额 }
用于电商收付通支付
type Time ¶ added in v1.1.91
func (Time) MarshalJSON ¶ added in v1.1.91
func (*Time) UnmarshalJSON ¶ added in v1.1.91
type UboInfo ¶
type UboInfo struct { IdType string `json:"id_type"` // 证件类型 IdCardCopy string `json:"id_card_copy,omitempty"` // 身份证人像面照片 IdCardNational string `json:"id_card_national,omitempty"` // 身份证国徽面照片 IdDocCopy string `json:"id_doc_copy,omitempty"` // 证件照片 Name string `json:"name"` // 受益人姓名 IdNumber string `json:"id_number"` // 证件号码 IdPeriodBegin string `json:"id_period_begin"` // 证件有效期开始时间 IdPeriodEnd string `json:"id_period_end"` // 证件有效期结束时间 }
type WeworkInfo ¶
Click to show internal directories.
Click to hide internal directories.