Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptAliPayOpenDataToStruct(encryptedData, secretKey string, beanPtr interface{}) (err error)
- func DecryptWeChatOpenDataToStruct(encryptedData, iv, sessionKey string, beanPtr interface{}) (err error)
- func Float32ToString(floatNum float32, prec ...int) (floatStr string)
- func Float64ToString(floatNum float64, prec ...int) (floatStr string)
- func FormatAliPayPublicKey(publicKey string) (pKey string)
- func FormatAliPayURLParam(body BodyMap) (urlParam string)
- func FormatPrivateKey(privateKey string) (pKey string)
- func GetAppPaySign(appid, partnerid, noncestr, prepayid, signType, timestamp, apiKey string) (paySign string)
- func GetCertSN(certPath string) (sn string, err error)
- func GetH5PaySign(appId, nonceStr, packages, signType, timeStamp, apiKey string) (paySign string)
- func GetMiniPaySign(appId, nonceStr, prepayId, signType, timeStamp, apiKey string) (paySign string)
- func GetRandomString(length int) string
- func GetWeChatParamSign(appId, mchId, apiKey string, bm BodyMap) (sign string)
- func GetWeChatSanBoxParamSign(appId, mchId, apiKey string, bm BodyMap) (sign string, err error)
- func Int2String(intNum int) (intStr string)
- func Int322String(intNum int32) (int32Str string)
- func Int642String(intNum int64) (int64Str string)
- func PKCS5UnPadding(origData []byte) (bs []byte)
- func PKCS7UnPadding(origData []byte) (bs []byte)
- func ParseDateTime(timeStr string) (datetime time.Time)
- func String2Float32(floatStr string) (floatNum float32)
- func String2Float64(floatStr string) (floatNum float64)
- func String2Int(intStr string) (intNum int)
- func String2Int32(intStr string) (int32Num int32)
- func String2Int64(intStr string) (int64Num int64)
- func VerifyAliPaySign(aliPayPublicKey string, bean interface{}) (ok bool, err error)
- func VerifyAliPaySyncSign(aliPayPublicKey, signData, sign string) (ok bool, err error)
- func VerifyWeChatSign(apiKey, signType string, bean interface{}) (ok bool, err error)
- type AccessToken
- type AliPayClient
- func (a *AliPayClient) AliPayFundTransToaccountTransfer(body BodyMap) (aliRsp *AliPayFundTransToaccountTransferResponse, err error)
- func (a *AliPayClient) AliPayOpenAuthTokenApp(body BodyMap) (aliRsp *AliPayOpenAuthTokenAppResponse, err error)
- func (a *AliPayClient) AliPaySystemOauthToken(body BodyMap) (aliRsp *AliPaySystemOauthTokenResponse, err error)
- func (a *AliPayClient) AliPayTradeAppPay(body BodyMap) (payParam string, err error)
- func (a *AliPayClient) AliPayTradeCancel(body BodyMap) (aliRsp *AliPayTradeCancelResponse, err error)
- func (a *AliPayClient) AliPayTradeClose(body BodyMap) (aliRsp *AliPayTradeCloseResponse, err error)
- func (a *AliPayClient) AliPayTradeCreate(body BodyMap) (aliRsp *AliPayTradeCreateResponse, err error)
- func (a *AliPayClient) AliPayTradeFastPayRefundQuery(body BodyMap) (aliRsp *AliPayTradeFastpayRefundQueryResponse, err error)
- func (a *AliPayClient) AliPayTradeOrderSettle(body BodyMap) (aliRsp *AliPayTradeOrderSettleResponse, err error)
- func (a *AliPayClient) AliPayTradeOrderinfoSync(body BodyMap)
- func (a *AliPayClient) AliPayTradePagePay(body BodyMap) (payUrl string, err error)
- func (a *AliPayClient) AliPayTradePageRefund(body BodyMap) (aliRsp *AliPayTradePageRefundResponse, err error)
- func (a *AliPayClient) AliPayTradePay(body BodyMap) (aliRsp *AliPayTradePayResponse, err error)
- func (a *AliPayClient) AliPayTradePrecreate(body BodyMap) (aliRsp *AliPayTradePrecreateResponse, err error)
- func (a *AliPayClient) AliPayTradeQuery(body BodyMap) (aliRsp *AliPayTradeQueryResponse, err error)
- func (a *AliPayClient) AliPayTradeRefund(body BodyMap) (aliRsp *AliPayTradeRefundResponse, err error)
- func (a *AliPayClient) AliPayTradeWapPay(body BodyMap) (payUrl string, err error)
- func (a *AliPayClient) AliPayUserCertifyOpenCertify(body BodyMap) (certifyUrl string, err error)
- func (a *AliPayClient) AliPayUserCertifyOpenInit(body BodyMap) (aliRsp *AliPayUserCertifyOpenInitResponse, err error)
- func (a *AliPayClient) AliPayUserCertifyOpenQuery(body BodyMap) (aliRsp *AliPayUserCertifyOpenQueryResponse, err error)
- func (a *AliPayClient) AliPayUserInfoShare() (aliRsp *AliPayUserInfoShareResponse, err error)
- func (a *AliPayClient) SetAliPayPublicCertSN(aliPayPublicCertSN string) (client *AliPayClient)
- func (a *AliPayClient) SetAliPayPublicCertSnByPath(aliPayPublicCertPath string) (client *AliPayClient, err error)
- func (a *AliPayClient) SetAliPayRootCertSN(aliPayRootCertSN string) (client *AliPayClient)
- func (a *AliPayClient) SetAliPayRootCertSnByPath(aliPayRootCertPath string) (client *AliPayClient, err error)
- func (a *AliPayClient) SetAppAuthToken(appAuthToken string) (client *AliPayClient)
- func (a *AliPayClient) SetAppCertSN(appCertSN string) (client *AliPayClient)
- func (a *AliPayClient) SetAppCertSnByPath(appCertPath string) (client *AliPayClient, err error)
- func (a *AliPayClient) SetAuthToken(authToken string) (client *AliPayClient)
- func (a *AliPayClient) SetCharset(charset string) (client *AliPayClient)
- func (a *AliPayClient) SetNotifyUrl(url string) (client *AliPayClient)
- func (a *AliPayClient) SetReturnUrl(url string) (client *AliPayClient)
- func (a *AliPayClient) SetSignType(signType string) (client *AliPayClient)
- func (a *AliPayClient) ZhimaCreditScoreGet(body BodyMap) (aliRsp *ZhimaCreditScoreGetResponse, err error)
- type AliPayFundTransToaccountTransferResponse
- type AliPayNotifyRequest
- type AliPayOpenAuthTokenAppResponse
- type AliPaySystemOauthTokenResponse
- type AliPayTradeCancelResponse
- type AliPayTradeCloseResponse
- type AliPayTradeCreateResponse
- type AliPayTradeFastpayRefundQueryResponse
- type AliPayTradeOrderSettleResponse
- type AliPayTradePageRefundResponse
- type AliPayTradePayResponse
- type AliPayTradePrecreateResponse
- type AliPayTradeQueryResponse
- type AliPayTradeRefundResponse
- type AliPayUserCertifyOpenCertifyResponse
- type AliPayUserCertifyOpenInitResponse
- type AliPayUserCertifyOpenQueryResponse
- type AliPayUserInfoShareResponse
- type AliPayUserPhone
- type AppWeChatLoginAccessToken
- type BodyMap
- func DecryptAliPayOpenDataToBodyMap(encryptedData, secretKey string) (bm BodyMap, err error)
- func DecryptWeChatOpenDataToBodyMap(encryptedData, iv, sessionKey string) (bm BodyMap, err error)
- func ParseAliPayNotifyResultToBodyMap(req *http.Request) (bm BodyMap, err error)
- func ParseWeChatNotifyResultToBodyMap(req *http.Request) (bm BodyMap, err error)
- func (bm BodyMap) EncodeAliPaySignParams() string
- func (bm BodyMap) EncodeWeChatSignParams(apiKey string) string
- func (bm BodyMap) Get(key string) string
- func (bm BodyMap) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)
- func (bm BodyMap) Remove(key string)
- func (bm BodyMap) Set(key string, value interface{})
- func (bm *BodyMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
- type Client
- func (c *Client) EndBytes() (res *http.Response, bs []byte, errs []error)
- func (c *Client) EndStruct(v interface{}) (res *http.Response, errs []error)
- func (c *Client) Get(url string) (client *Client)
- func (c *Client) Post(url string) (client *Client)
- func (c *Client) SendString(v string) (client *Client)
- func (c *Client) SendStruct(v interface{}) (client *Client)
- func (c *Client) SetTLSConfig(tlsCfg *tls.Config) (client *Client)
- func (c *Client) Type(typeStr string) (client *Client)
- type Code2SessionRsp
- type Country
- type OpenApiRoyaltyDetailInfoPojo
- type OpenIdByAuthCodeRsp
- type PaidUnionId
- type RefreshAppWeChatLoginAccessTokenRsp
- type RefundNotify
- type ReturnMessage
- type WeChatAppletUserInfo
- type WeChatClient
- func (w *WeChatClient) AddCertFileByte(certFile, keyFile, pkcs12File []byte)
- func (w *WeChatClient) AddCertFilePath(certFilePath, keyFilePath, pkcs12FilePath string) (err error)
- func (w *WeChatClient) BatchQueryComment(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp string, err error)
- func (w *WeChatClient) CloseOrder(body BodyMap) (wxRsp *WeChatCloseOrderResponse, err error)
- func (w *WeChatClient) DownloadBill(body BodyMap) (wxRsp string, err error)
- func (w *WeChatClient) DownloadFundFlow(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp string, err error)
- func (w *WeChatClient) EntrustPublic(body BodyMap) (bs []byte, err error)
- func (w *WeChatClient) Micropay(body BodyMap) (wxRsp *WeChatMicropayResponse, err error)
- func (w *WeChatClient) QueryOrder(body BodyMap) (wxRsp *WeChatQueryOrderResponse, err error)
- func (w *WeChatClient) QueryRefund(body BodyMap) (wxRsp *WeChatQueryRefundResponse, err error)
- func (w *WeChatClient) Refund(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp *WeChatRefundResponse, err error)
- func (w *WeChatClient) Reverse(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp *WeChatReverseResponse, err error)
- func (w *WeChatClient) SetCountry(country Country) (client *WeChatClient)
- func (w *WeChatClient) Transfer(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp *WeChatTransfersResponse, err error)
- func (w *WeChatClient) UnifiedOrder(body BodyMap) (wxRsp *WeChatUnifiedOrderResponse, err error)
- type WeChatCloseOrderResponse
- type WeChatMicropayResponse
- type WeChatNotifyRequest
- type WeChatNotifyResponse
- type WeChatQueryOrderResponse
- type WeChatQueryRefundResponse
- type WeChatRefundNotifyRequest
- type WeChatRefundResponse
- type WeChatReverseResponse
- type WeChatTransfersResponse
- type WeChatUnifiedOrderResponse
- type WeChatUserInfo
- type WeChatUserPhone
- type ZhimaCreditScoreGetResponse
Constants ¶
const ( TimeLayout string = "2006-01-02 15:04:05" DateLayout string = "2006-01-02" Version string = "1.4.6" // 境外国家地区 China Country = 1 // 中国国内 China2 Country = 2 // 中国国内(冗灾方案) SoutheastAsia Country = 3 // 东南亚 Other Country = 4 // 其他国家 // 支付类型 TradeType_Mini = "JSAPI" TradeType_JsApi = "JSAPI" TradeType_App = "APP" TradeType_H5 = "MWEB" TradeType_Native = "NATIVE" // 签名方式 SignType_MD5 = "MD5" SignType_HMAC_SHA256 = "HMAC-SHA256" )
const ( POST = "POST" GET = "GET" TypeJSON = "json" TypeXML = "xml" TypeUrlencoded = "urlencoded" TypeForm = "form" TypeFormData = "form-data" )
const ( SUCCESS = "SUCCESS" FAIL = "FAIL" OK = "OK" )
Variables ¶
var Types = map[string]string{ TypeJSON: "application/json", TypeXML: "application/xml", TypeForm: "application/x-www-form-urlencoded", TypeFormData: "application/x-www-form-urlencoded", TypeUrlencoded: "application/x-www-form-urlencoded", }
Functions ¶
func DecryptAliPayOpenDataToStruct ¶ added in v1.4.7
func DecryptAliPayOpenDataToStruct(encryptedData, secretKey string, beanPtr interface{}) (err error)
DecryptAliPayOpenDataToStruct 解密支付宝开放数据到 结构体
encryptedData:包括敏感数据在内的完整用户信息的加密数据 secretKey:AES密钥,支付宝管理平台配置 beanPtr:需要解析到的结构体指针 文档:https://docs.alipay.com/mini/introduce/aes 文档:https://docs.open.alipay.com/common/104567
func DecryptWeChatOpenDataToStruct ¶ added in v1.4.7
func DecryptWeChatOpenDataToStruct(encryptedData, iv, sessionKey string, beanPtr interface{}) (err error)
解密开放数据到结构体
encryptedData:包括敏感数据在内的完整用户信息的加密数据,小程序获取到 iv:加密算法的初始向量,小程序获取到 sessionKey:会话密钥,通过 gopay.Code2Session() 方法获取到 beanPtr:需要解析到的结构体指针,操作完后,声明的结构体会被赋值 文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html
func FormatAliPayPublicKey ¶ added in v1.1.1
FormatAliPayPublicKey 格式化 普通支付宝公钥
func FormatAliPayURLParam ¶ added in v1.1.1
格式化请求URL参数
func FormatPrivateKey ¶ added in v1.1.1
FormatPrivateKey 格式化 普通应用秘钥
func GetAppPaySign ¶ added in v1.1.0
func GetAppPaySign(appid, partnerid, noncestr, prepayid, signType, timestamp, apiKey string) (paySign string)
APP支付,统一下单获取支付参数后,再次计算APP支付所需要的的sign
appId:APPID partnerid:partnerid nonceStr:随即字符串 prepayId:统一下单成功后得到的值 signType:此处签名方式,务必与统一下单时用的签名方式一致 timeStamp:时间 ApiKey:API秘钥值 APP支付官方文档:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12
func GetCertSN ¶ added in v1.4.7
GetCertSN 获取证书序列号SN
certPath:X.509证书文件路径(appCertPublicKey.crt、alipayRootCert.crt、alipayCertPublicKey_RSA2) 返回 sn:证书序列号(app_cert_sn、alipay_root_cert_sn、alipay_cert_sn) 返回 err:error 信息
func GetH5PaySign ¶ added in v1.0.5
微信内H5支付,统一下单获取支付参数后,再次计算出微信内H5支付需要用的paySign
appId:APPID nonceStr:随即字符串 packages:统一下单成功后拼接得到的值 signType:签名类型 timeStamp:时间 ApiKey:API秘钥值 微信内H5支付官方文档:https://pay.weixin.qq.com/wiki/doc/api/external/jsapi.php?chapter=7_7&index=6
func GetMiniPaySign ¶
JSAPI支付,统一下单获取支付参数后,再次计算出小程序用的paySign
appId:APPID nonceStr:随即字符串 prepayId:统一下单成功后得到的值 signType:签名类型 timeStamp:时间 ApiKey:API秘钥值 微信小程序支付API:https://developers.weixin.qq.com/miniprogram/dev/api/open-api/payment/wx.requestPayment.html 微信小程序支付PaySign计算文档:https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=3
func GetWeChatParamSign ¶ added in v1.4.7
获取微信支付所需参数里的Sign值(通过支付参数计算Sign值)
注意:BodyMap中如无 sign_type 参数,默认赋值 sign_type 为 MD5 appId:应用ID mchId:商户ID ApiKey:API秘钥值 返回参数 sign:通过Appid、MchId、ApiKey和BodyMap中的参数计算出的Sign值
func GetWeChatSanBoxParamSign ¶ added in v1.4.7
获取微信支付沙箱环境所需参数里的Sign值(通过支付参数计算Sign值)
注意:沙箱环境默认 sign_type 为 MD5 appId:应用ID mchId:商户ID ApiKey:API秘钥值 返回参数 sign:通过Appid、MchId、ApiKey和BodyMap中的参数计算出的Sign值
func PKCS5UnPadding ¶ added in v1.4.7
解密填充模式(去除补全码) PKCS5UnPadding 解密时,需要在最后面去掉加密时添加的填充byte
func PKCS7UnPadding ¶ added in v1.0.7
解密填充模式(去除补全码) PKCS7UnPadding 解密时,需要在最后面去掉加密时添加的填充byte
func String2Float32 ¶ added in v1.4.7
字符串转Float32
func String2Float64 ¶ added in v1.4.7
字符串转Float64
func VerifyAliPaySign ¶ added in v1.4.7
VerifyAliPaySign 支付宝异步通知验签
注意:APP支付,手机网站支付,电脑网站支付 暂不支持同步返回验签 aliPayPublicKey:支付宝公钥 bean:此参数为异步通知解析的结构体或BodyMap:notifyReq 或 bm 返回参数ok:是否验签通过 返回参数err:错误信息 验签文档:https://docs.open.alipay.com/200/106120
func VerifyAliPaySyncSign ¶ added in v1.4.7
VerifyAliPaySyncSign 支付宝同步返回验签
注意:APP支付,手机网站支付,电脑网站支付 暂不支持同步返回验签 aliPayPublicKey:支付宝公钥 signData:待验签参数,aliRsp.SignData sign:待验签sign,aliRsp.Sign 返回参数ok:是否验签通过 返回参数err:错误信息 验签文档:https://docs.open.alipay.com/200/106120
func VerifyWeChatSign ¶ added in v1.4.7
微信同步返回参数验签或异步通知参数验签
ApiKey:API秘钥值 signType:签名类型(调用API方法时填写的类型) bean:微信同步返回的结构体 wxRsp 或 异步通知解析的结构体 notifyReq 返回参数ok:是否验签通过 返回参数err:错误信息
Types ¶
type AccessToken ¶ added in v1.0.7
type AccessToken struct { AccessToken string `json:"access_token,omitempty"` // 获取到的凭证 ExpiresIn int `json:"expires_in,omitempty"` // SessionKey超时时间(秒) Errcode int `json:"errcode,omitempty"` // 错误码 Errmsg string `json:"errmsg,omitempty"` // 错误信息 }
func GetWeChatAppletAccessToken ¶ added in v1.4.7
func GetWeChatAppletAccessToken(appId, appSecret string) (accessToken *AccessToken, err error)
获取微信小程序全局唯一后台接口调用凭据(AccessToken:157字符)
appId:APPID appSecret:AppSecret 获取access_token文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
type AliPayClient ¶ added in v1.4.7
type AliPayClient struct { AppId string PrivateKey string AppCertSN string AliPayPublicCertSN string AliPayRootCertSN string ReturnUrl string NotifyUrl string Charset string SignType string AppAuthToken string AuthToken string IsProd bool // contains filtered or unexported fields }
func NewAliPayClient ¶ added in v1.1.1
func NewAliPayClient(appId, privateKey string, isProd bool) (client *AliPayClient)
初始化支付宝客户端
注意:如果使用支付宝公钥证书验签,请设置 支付宝根证书SN(client.SetAlipayRootCertSN())、应用公钥证书SN(client.SetAppCertSN()) appId:应用ID PrivateKey:应用私钥 IsProd:是否是正式环境
func (*AliPayClient) AliPayFundTransToaccountTransfer ¶ added in v1.4.7
func (a *AliPayClient) AliPayFundTransToaccountTransfer(body BodyMap) (aliRsp *AliPayFundTransToaccountTransferResponse, err error)
alipay.fund.trans.toaccount.transfer(单笔转账到支付宝账户接口)
文档地址:https://docs.open.alipay.com/api_28/alipay.fund.trans.toaccount.transfer
func (*AliPayClient) AliPayOpenAuthTokenApp ¶ added in v1.4.7
func (a *AliPayClient) AliPayOpenAuthTokenApp(body BodyMap) (aliRsp *AliPayOpenAuthTokenAppResponse, err error)
alipay.open.auth.token.app(换取应用授权令牌)
文档地址:https://docs.open.alipay.com/api_9/alipay.open.auth.token.app
func (*AliPayClient) AliPaySystemOauthToken ¶ added in v1.4.7
func (a *AliPayClient) AliPaySystemOauthToken(body BodyMap) (aliRsp *AliPaySystemOauthTokenResponse, err error)
alipay.system.oauth.token(换取授权访问令牌)
文档地址:https://docs.open.alipay.com/api_9/alipay.system.oauth.token
func (*AliPayClient) AliPayTradeAppPay ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeAppPay(body BodyMap) (payParam string, err error)
alipay.trade.app.pay(app支付接口2.0)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.app.pay
func (*AliPayClient) AliPayTradeCancel ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeCancel(body BodyMap) (aliRsp *AliPayTradeCancelResponse, err error)
alipay.trade.cancel(统一收单交易撤销接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.cancel
func (*AliPayClient) AliPayTradeClose ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeClose(body BodyMap) (aliRsp *AliPayTradeCloseResponse, err error)
alipay.trade.close(统一收单交易关闭接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.close
func (*AliPayClient) AliPayTradeCreate ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeCreate(body BodyMap) (aliRsp *AliPayTradeCreateResponse, err error)
alipay.trade.create(统一收单交易创建接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.create
func (*AliPayClient) AliPayTradeFastPayRefundQuery ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeFastPayRefundQuery(body BodyMap) (aliRsp *AliPayTradeFastpayRefundQueryResponse, err error)
alipay.trade.fastpay.refund.query(统一收单交易退款查询)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query
func (*AliPayClient) AliPayTradeOrderSettle ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeOrderSettle(body BodyMap) (aliRsp *AliPayTradeOrderSettleResponse, err error)
alipay.trade.order.settle(统一收单交易结算接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.order.settle
func (*AliPayClient) AliPayTradeOrderinfoSync ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeOrderinfoSync(body BodyMap)
alipay.trade.orderinfo.sync(支付宝订单信息同步接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.orderinfo.sync
func (*AliPayClient) AliPayTradePagePay ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradePagePay(body BodyMap) (payUrl string, err error)
alipay.trade.page.pay(统一收单下单并支付页面接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.page.pay
func (*AliPayClient) AliPayTradePageRefund ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradePageRefund(body BodyMap) (aliRsp *AliPayTradePageRefundResponse, err error)
alipay.trade.refund(统一收单退款页面接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.page.refund
func (*AliPayClient) AliPayTradePay ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradePay(body BodyMap) (aliRsp *AliPayTradePayResponse, err error)
alipay.trade.pay(统一收单交易支付接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.pay
func (*AliPayClient) AliPayTradePrecreate ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradePrecreate(body BodyMap) (aliRsp *AliPayTradePrecreateResponse, err error)
alipay.trade.precreate(统一收单线下交易预创建)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.precreate
func (*AliPayClient) AliPayTradeQuery ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeQuery(body BodyMap) (aliRsp *AliPayTradeQueryResponse, err error)
alipay.trade.query(统一收单线下交易查询)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.query
func (*AliPayClient) AliPayTradeRefund ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeRefund(body BodyMap) (aliRsp *AliPayTradeRefundResponse, err error)
alipay.trade.refund(统一收单交易退款接口)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.refund
func (*AliPayClient) AliPayTradeWapPay ¶ added in v1.4.7
func (a *AliPayClient) AliPayTradeWapPay(body BodyMap) (payUrl string, err error)
alipay.trade.wap.pay(手机网站支付接口2.0)
文档地址:https://docs.open.alipay.com/api_1/alipay.trade.wap.pay
func (*AliPayClient) AliPayUserCertifyOpenCertify ¶ added in v1.4.7
func (a *AliPayClient) AliPayUserCertifyOpenCertify(body BodyMap) (certifyUrl string, err error)
alipay.user.certify.open.certify(身份认证开始认证)
API文档地址:https://docs.open.alipay.com/api_2/alipay.user.certify.open.certify 产品文档地址:https://docs.open.alipay.com/20181012100420932508/quickstart
func (*AliPayClient) AliPayUserCertifyOpenInit ¶ added in v1.4.7
func (a *AliPayClient) AliPayUserCertifyOpenInit(body BodyMap) (aliRsp *AliPayUserCertifyOpenInitResponse, err error)
alipay.user.certify.open.initialize(身份认证初始化服务)
文档地址:https://docs.open.alipay.com/api_2/alipay.user.certify.open.initialize
func (*AliPayClient) AliPayUserCertifyOpenQuery ¶ added in v1.4.7
func (a *AliPayClient) AliPayUserCertifyOpenQuery(body BodyMap) (aliRsp *AliPayUserCertifyOpenQueryResponse, err error)
alipay.user.certify.open.query(身份认证记录查询)
文档地址:https://docs.open.alipay.com/api_2/alipay.user.certify.open.query
func (*AliPayClient) AliPayUserInfoShare ¶ added in v1.4.7
func (a *AliPayClient) AliPayUserInfoShare() (aliRsp *AliPayUserInfoShareResponse, err error)
alipay.user.info.share(支付宝会员授权信息查询接口)
body:此接口无需body参数 文档地址:https://docs.open.alipay.com/api_2/alipay.user.info.share
func (*AliPayClient) SetAliPayPublicCertSN ¶ added in v1.4.7
func (a *AliPayClient) SetAliPayPublicCertSN(aliPayPublicCertSN string) (client *AliPayClient)
设置 支付宝公钥证书SN
aliPayPublicCertSN:支付宝公钥证书SN,通过 gopay.GetCertSN() 获取
func (*AliPayClient) SetAliPayPublicCertSnByPath ¶ added in v1.4.7
func (a *AliPayClient) SetAliPayPublicCertSnByPath(aliPayPublicCertPath string) (client *AliPayClient, err error)
设置 alipay_cert_sn 通过 支付宝公钥证书文件路径
aliPayPublicCertPath:支付宝公钥证书文件路径
func (*AliPayClient) SetAliPayRootCertSN ¶ added in v1.4.7
func (a *AliPayClient) SetAliPayRootCertSN(aliPayRootCertSN string) (client *AliPayClient)
设置 支付宝CA根证书SN
aliPayRootCertSN:支付宝CA根证书SN,通过 gopay.GetCertSN() 获取
func (*AliPayClient) SetAliPayRootCertSnByPath ¶ added in v1.4.7
func (a *AliPayClient) SetAliPayRootCertSnByPath(aliPayRootCertPath string) (client *AliPayClient, err error)
设置 alipay_root_cert_sn 通过支付宝CA根证书文件路径
aliPayRootCertPath:支付宝CA根证书文件路径
func (*AliPayClient) SetAppAuthToken ¶ added in v1.4.7
func (a *AliPayClient) SetAppAuthToken(appAuthToken string) (client *AliPayClient)
设置应用授权
func (*AliPayClient) SetAppCertSN ¶ added in v1.4.7
func (a *AliPayClient) SetAppCertSN(appCertSN string) (client *AliPayClient)
设置 应用公钥证书SN
appCertSN:应用公钥证书SN,通过 gopay.GetCertSN() 获取
func (*AliPayClient) SetAppCertSnByPath ¶ added in v1.4.7
func (a *AliPayClient) SetAppCertSnByPath(appCertPath string) (client *AliPayClient, err error)
设置 app_cert_sn 通过应用公钥证书路径
appCertPath:应用公钥证书路径
func (*AliPayClient) SetAuthToken ¶ added in v1.4.7
func (a *AliPayClient) SetAuthToken(authToken string) (client *AliPayClient)
设置用户信息授权
func (*AliPayClient) SetCharset ¶ added in v1.4.7
func (a *AliPayClient) SetCharset(charset string) (client *AliPayClient)
设置编码格式,如utf-8,gbk,gb2312等,默认推荐使用 utf-8
func (*AliPayClient) SetNotifyUrl ¶ added in v1.4.7
func (a *AliPayClient) SetNotifyUrl(url string) (client *AliPayClient)
设置支付宝服务器主动通知商户服务器里指定的页面http/https路径。
func (*AliPayClient) SetReturnUrl ¶ added in v1.4.7
func (a *AliPayClient) SetReturnUrl(url string) (client *AliPayClient)
设置支付后的ReturnUrl
func (*AliPayClient) SetSignType ¶ added in v1.4.7
func (a *AliPayClient) SetSignType(signType string) (client *AliPayClient)
设置签名算法类型,目前支持RSA2和RSA,默认推荐使用 RSA2
func (*AliPayClient) ZhimaCreditScoreGet ¶ added in v1.4.7
func (a *AliPayClient) ZhimaCreditScoreGet(body BodyMap) (aliRsp *ZhimaCreditScoreGetResponse, err error)
zhima.credit.score.get(芝麻分)
文档地址:https://docs.open.alipay.com/api_8/zhima.credit.score.get
type AliPayFundTransToaccountTransferResponse ¶ added in v1.4.7
type AliPayFundTransToaccountTransferResponse struct { Response *transToaccountTransferResponse `json:"alipay_fund_trans_toaccount_transfer_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayNotifyRequest ¶ added in v1.1.2
type AliPayNotifyRequest struct { NotifyTime string `json:"notify_time,omitempty"` NotifyType string `json:"notify_type,omitempty"` NotifyId string `json:"notify_id,omitempty"` AppId string `json:"app_id,omitempty"` Charset string `json:"charset,omitempty"` Version string `json:"version,omitempty"` SignType string `json:"sign_type,omitempty"` Sign string `json:"sign,omitempty"` AuthAppId string `json:"auth_app_id,omitempty"` TradeNo string `json:"trade_no,omitempty"` OutTradeNo string `json:"out_trade_no,omitempty"` OutBizNo string `json:"out_biz_no,omitempty"` BuyerId string `json:"buyer_id,omitempty"` BuyerLogonId string `json:"buyer_logon_id,omitempty"` SellerId string `json:"seller_id,omitempty"` SellerEmail string `json:"seller_email,omitempty"` TradeStatus string `json:"trade_status,omitempty"` TotalAmount string `json:"total_amount,omitempty"` ReceiptAmount string `json:"receipt_amount,omitempty"` InvoiceAmount string `json:"invoice_amount,omitempty"` BuyerPayAmount string `json:"buyer_pay_amount,omitempty"` PointAmount string `json:"point_amount,omitempty"` RefundFee string `json:"refund_fee,omitempty"` Subject string `json:"subject,omitempty"` Body string `json:"body,omitempty"` GmtCreate string `json:"gmt_create,omitempty"` GmtPayment string `json:"gmt_payment,omitempty"` GmtRefund string `json:"gmt_refund,omitempty"` GmtClose string `json:"gmt_close,omitempty"` FundBillList []*fundBillListInfo `json:"fund_bill_list,omitempty"` PassbackParams string `json:"passback_params,omitempty"` VoucherDetailList []*voucherDetailListInfo `json:"voucher_detail_list,omitempty"` Method string `json:"method,omitempty"` //电脑网站支付 支付宝请求 return_url 同步返回参数 Timestamp string `json:"timestamp,omitempty"` //电脑网站支付 支付宝请求 return_url 同步返回参数 }
func ParseAliPayNotifyResult ¶ added in v1.1.2
func ParseAliPayNotifyResult(req *http.Request) (notifyReq *AliPayNotifyRequest, err error)
解析支付宝支付异步通知的参数到Struct
req:*http.Request 返回参数notifyReq:Notify请求的参数 返回参数err:错误信息 文档:https://docs.open.alipay.com/203/105286/
type AliPayOpenAuthTokenAppResponse ¶ added in v1.4.7
type AliPayOpenAuthTokenAppResponse struct { Response *authTokenAppResponse `json:"alipay_open_auth_token_app_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPaySystemOauthTokenResponse ¶ added in v1.4.7
type AliPaySystemOauthTokenResponse struct { Response *oauthTokenInfo `json:"alipay_system_oauth_token_response,omitempty"` ErrorResponse *struct { Code string `json:"code,omitempty"` Msg string `json:"msg,omitempty"` SubCode string `json:"sub_code,omitempty"` SubMsg string `json:"sub_msg,omitempty"` } `json:"error_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
func AliPaySystemOauthToken ¶ added in v1.4.7
func AliPaySystemOauthToken(appId, privateKey, grantType, codeOrToken string) (rsp *AliPaySystemOauthTokenResponse, err error)
AliPaySystemOauthToken 换取授权访问令牌(默认使用utf-8,RSA2)
appId:应用ID PrivateKey:应用私钥 grantType:值为 authorization_code 时,代表用code换取;值为 refresh_token 时,代表用refresh_token换取,传空默认code换取 codeOrToken:支付宝授权码或refresh_token 文档:https://docs.open.alipay.com/api_9/alipay.system.oauth.token
type AliPayTradeCancelResponse ¶ added in v1.1.8
type AliPayTradeCancelResponse struct { Response *cancelResponse `json:"alipay_trade_cancel_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradeCloseResponse ¶ added in v1.1.8
type AliPayTradeCloseResponse struct { Response *closeResponse `json:"alipay_trade_close_response,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradeCreateResponse ¶ added in v1.1.8
type AliPayTradeCreateResponse struct { Response *createResponse `json:"alipay_trade_create_response,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradeFastpayRefundQueryResponse ¶ added in v1.4.7
type AliPayTradeFastpayRefundQueryResponse struct { Response *refundQueryResponse `json:"alipay_trade_fastpay_refund_query_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradeOrderSettleResponse ¶ added in v1.4.7
type AliPayTradeOrderSettleResponse struct { Response *orderSettleResponse `json:"alipay_trade_order_settle_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradePageRefundResponse ¶ added in v1.4.7
type AliPayTradePageRefundResponse struct { Response *pageRefundResponse `json:"alipay_trade_page_refund_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradePayResponse ¶ added in v1.1.8
type AliPayTradePayResponse struct { Response *payResponse `json:"alipay_trade_pay_response,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradePrecreateResponse ¶ added in v1.4.7
type AliPayTradePrecreateResponse struct { Response *precreateResponse `json:"alipay_trade_precreate_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradeQueryResponse ¶ added in v1.1.8
type AliPayTradeQueryResponse struct { Response *queryResponse `json:"alipay_trade_query_response,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayTradeRefundResponse ¶ added in v1.4.7
type AliPayTradeRefundResponse struct { Response *refundResponse `json:"alipay_trade_refund_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayUserCertifyOpenCertifyResponse ¶ added in v1.4.7
type AliPayUserCertifyOpenCertifyResponse struct { Response *userCertifyOpenCertifyResponse `json:"alipay_user_certify_open_certify_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayUserCertifyOpenInitResponse ¶ added in v1.4.7
type AliPayUserCertifyOpenInitResponse struct { Response *userCertifyOpenInitResponse `json:"alipay_user_certify_open_initialize_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayUserCertifyOpenQueryResponse ¶ added in v1.4.7
type AliPayUserCertifyOpenQueryResponse struct { Response *userCertifyOpenQueryResponse `json:"alipay_user_certify_open_query_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================
type AliPayUserInfoShareResponse ¶ added in v1.4.7
type AliPayUserInfoShareResponse struct {}
===================================================
type AliPayUserPhone ¶ added in v1.4.7
type AppWeChatLoginAccessToken ¶ added in v1.4.7
type AppWeChatLoginAccessToken struct { AccessToken string `json:"access_token,omitempty"` ExpiresIn int `json:"expires_in,omitempty"` Openid string `json:"openid,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` Scope string `json:"scope,omitempty"` Unionid string `json:"unionid,omitempty"` Errcode int `json:"errcode,omitempty"` // 错误码 Errmsg string `json:"errmsg,omitempty"` // 错误信息 }
App应用微信第三方登录,code换取access_token
func GetAppWeChatLoginAccessToken ¶ added in v1.4.7
func GetAppWeChatLoginAccessToken(appId, appSecret, code string) (accessToken *AppWeChatLoginAccessToken, err error)
App应用微信第三方登录,code换取access_token
appId:应用唯一标识,在微信开放平台提交应用审核通过后获得 appSecret:应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 code:App用户换取access_token的code
type BodyMap ¶
type BodyMap map[string]interface{}
func DecryptAliPayOpenDataToBodyMap ¶ added in v1.4.7
DecryptAliPayOpenDataToBodyMap 解密支付宝开放数据到 BodyMap
encryptedData:包括敏感数据在内的完整用户信息的加密数据 secretKey:AES密钥,支付宝管理平台配置 文档:https://docs.alipay.com/mini/introduce/aes 文档:https://docs.open.alipay.com/common/104567
func DecryptWeChatOpenDataToBodyMap ¶ added in v1.4.7
解密开放数据到 BodyMap
encryptedData:包括敏感数据在内的完整用户信息的加密数据,小程序获取到 iv:加密算法的初始向量,小程序获取到 sessionKey:会话密钥,通过 gopay.Code2Session() 方法获取到 文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html
func ParseAliPayNotifyResultToBodyMap ¶ added in v1.4.7
解析支付宝支付异步通知的参数到BodyMap
req:*http.Request 返回参数bm:Notify请求的参数 返回参数err:错误信息 文档:https://docs.open.alipay.com/203/105286/
func ParseWeChatNotifyResultToBodyMap ¶ added in v1.4.7
解析微信支付异步通知的结果到BodyMap
req:*http.Request 返回参数bm:Notify请求的参数 返回参数err:错误信息
func (BodyMap) EncodeAliPaySignParams ¶ added in v1.4.7
("bar=baz&foo=quux") sorted by key.
func (BodyMap) EncodeWeChatSignParams ¶ added in v1.4.7
("bar=baz&foo=quux") sorted by key.
func (BodyMap) MarshalXML ¶ added in v1.4.7
func (*BodyMap) UnmarshalXML ¶ added in v1.4.7
type Client ¶ added in v1.4.7
type Client struct { HttpClient *http.Client Transport *http.Transport Url string Method string RequestType string FormString string ContentType string UnmarshalType string Types map[string]string JsonByte []byte Errors []error // contains filtered or unexported fields }
func NewHttpClient ¶ added in v1.4.7
func NewHttpClient() (client *Client)
NewHttpClient , default tls.Config{InsecureSkipVerify: true}
func (*Client) SendString ¶ added in v1.4.7
func (*Client) SendStruct ¶ added in v1.4.7
func (*Client) SetTLSConfig ¶ added in v1.4.7
type Code2SessionRsp ¶ added in v1.0.6
type Code2SessionRsp struct { SessionKey string `json:"session_key,omitempty"` // 会话密钥 ExpiresIn int `json:"expires_in,omitempty"` // SessionKey超时时间(秒) Openid string `json:"openid,omitempty"` // 用户唯一标识 Unionid string `json:"unionid,omitempty"` // 用户在开放平台的唯一标识符 Errcode int `json:"errcode,omitempty"` // 错误码 Errmsg string `json:"errmsg,omitempty"` // 错误信息 }
func Code2Session ¶ added in v1.0.6
func Code2Session(appId, appSecret, wxCode string) (sessionRsp *Code2SessionRsp, err error)
获取微信小程序用户的OpenId、SessionKey、UnionId
appId:APPID appSecret:AppSecret wxCode:小程序调用wx.login 获取的code 文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html
type OpenApiRoyaltyDetailInfoPojo ¶ added in v1.4.7
type OpenApiRoyaltyDetailInfoPojo struct { RoyaltyType string `json:"royalty_type,omitempty"` TransOut string `json:"trans_out,omitempty"` TransOutType string `json:"trans_out_type,omitempty"` TransInType string `json:"trans_in_type,omitempty"` TransIn string `json:"trans_in"` Amount string `json:"amount,omitempty"` Desc string `json:"desc,omitempty"` }
type OpenIdByAuthCodeRsp ¶ added in v1.4.7
type OpenIdByAuthCodeRsp struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` Openid string `xml:"openid,omitempty" json:"openid,omitempty"` // 用户唯一标识 }
授权码查询openid 返回
func GetOpenIdByAuthCode ¶ added in v1.4.7
func GetOpenIdByAuthCode(appId, mchId, apiKey, authCode, nonceStr string) (openIdRsp *OpenIdByAuthCodeRsp, err error)
授权码查询openid(AccessToken:157字符)
appId:APPID mchId:商户号 ApiKey:apiKey authCode:用户授权码 nonceStr:随即字符串 文档:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9
type PaidUnionId ¶ added in v1.0.7
type PaidUnionId struct { Unionid string `json:"unionid,omitempty"` // 用户在开放平台的唯一标识符 Errcode int `json:"errcode,omitempty"` // 错误码 Errmsg string `json:"errmsg,omitempty"` // 错误信息 }
func GetWeChatAppletPaidUnionId ¶ added in v1.4.7
func GetWeChatAppletPaidUnionId(accessToken, openId, transactionId string) (unionId *PaidUnionId, err error)
微信小程序用户支付完成后,获取该用户的 UnionId,无需用户授权。
accessToken:接口调用凭据 openId:用户的OpenID transactionId:微信支付订单号 文档:https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.getPaidUnionId.html
type RefreshAppWeChatLoginAccessTokenRsp ¶ added in v1.4.7
type RefreshAppWeChatLoginAccessTokenRsp struct { AccessToken string `json:"access_token,omitempty"` ExpiresIn int `json:"expires_in,omitempty"` Openid string `json:"openid,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` Scope string `json:"scope,omitempty"` Errcode int `json:"errcode,omitempty"` // 错误码 Errmsg string `json:"errmsg,omitempty"` // 错误信息 }
刷新App应用微信第三方登录后,获取的 access_token
func RefreshAppWeChatLoginAccessToken ¶ added in v1.4.7
func RefreshAppWeChatLoginAccessToken(appId, refreshToken string) (accessToken *RefreshAppWeChatLoginAccessTokenRsp, err error)
刷新App应用微信第三方登录后,获取的 access_token
appId:应用唯一标识,在微信开放平台提交应用审核通过后获得 appSecret:应用密钥AppSecret,在微信开放平台提交应用审核通过后获得 code:App用户换取access_token的code
type RefundNotify ¶ added in v1.4.7
type RefundNotify struct { TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` RefundId string `xml:"refund_id,omitempty" json:"refund_id,omitempty"` OutRefundNo string `xml:"out_refund_no,omitempty" json:"out_refund_no,omitempty"` TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` RefundFee int `xml:"refund_fee,omitempty" json:"refund_fee,omitempty"` SettlementRefundFee int `xml:"settlement_refund_fee,omitempty" json:"settlement_refund_fee,omitempty"` RefundStatus string `xml:"refund_status,omitempty" json:"refund_status,omitempty"` SuccessTime string `xml:"success_time,omitempty" json:"success_time,omitempty"` RefundRecvAccout string `xml:"refund_recv_accout,omitempty" json:"refund_recv_accout,omitempty"` RefundAccount string `xml:"refund_account,omitempty" json:"refund_account,omitempty"` RefundRequestSource string `xml:"refund_request_source,omitempty" json:"refund_request_source,omitempty"` }
func DecryptRefundNotifyReqInfo ¶ added in v1.4.7
func DecryptRefundNotifyReqInfo(reqInfo, apiKey string) (refundNotify *RefundNotify, err error)
解密微信退款异步通知的加密数据
reqInfo:gopay.ParseWeChatRefundNotifyResult() 方法获取的加密数据 req_info apiKey:API秘钥值 返回参数refundNotify:RefundNotify请求的加密数据 返回参数err:错误信息 文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_16&index=10
type ReturnMessage ¶
type WeChatAppletUserInfo ¶ added in v1.4.7
type WeChatAppletUserInfo struct { OpenId string `json:"openId,omitempty"` NickName string `json:"nickName,omitempty"` Gender int `json:"gender,omitempty"` City string `json:"city,omitempty"` Province string `json:"province,omitempty"` Country string `json:"country,omitempty"` AvatarUrl string `json:"avatarUrl,omitempty"` UnionId string `json:"unionId,omitempty"` Watermark *watermarkInfo `json:"watermark,omitempty"` }
微信小程序解密后 用户信息结构体
type WeChatClient ¶ added in v1.4.7
type WeChatClient struct { AppId string MchId string ApiKey string BaseURL string CertFile []byte KeyFile []byte Pkcs12File []byte IsProd bool // contains filtered or unexported fields }
func NewWeChatClient ¶
func NewWeChatClient(appId, mchId, apiKey string, isProd bool) (client *WeChatClient)
初始化微信客户端
appId:应用ID mchId:商户ID ApiKey:API秘钥值 IsProd:是否是正式环境
func (*WeChatClient) AddCertFileByte ¶ added in v1.4.7
func (w *WeChatClient) AddCertFileByte(certFile, keyFile, pkcs12File []byte)
添加微信证书 Byte 数组
certFile:apiclient_cert.pem byte数组 keyFile:apiclient_key.pem byte数组 pkcs12File:apiclient_cert.p12 byte数组
func (*WeChatClient) AddCertFilePath ¶ added in v1.4.7
func (w *WeChatClient) AddCertFilePath(certFilePath, keyFilePath, pkcs12FilePath string) (err error)
添加微信证书 Path 路径
certFilePath:apiclient_cert.pem 路径 keyFilePath:apiclient_key.pem 路径 pkcs12FilePath:apiclient_cert.p12 路径 返回err
func (*WeChatClient) BatchQueryComment ¶ added in v1.4.7
func (w *WeChatClient) BatchQueryComment(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp string, err error)
拉取订单评价数据
注意:如已使用client.AddCertFilePath()或client.AddCertFileByte()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传空字符串 "",如方法需单独使用证书,则传证书Path 貌似不支持沙箱环境,因为沙箱环境默认需要用MD5签名,但是此接口仅支持HMAC-SHA256签名 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_17&index=11
func (*WeChatClient) CloseOrder ¶ added in v1.4.7
func (w *WeChatClient) CloseOrder(body BodyMap) (wxRsp *WeChatCloseOrderResponse, err error)
关闭订单
文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_3
func (*WeChatClient) DownloadBill ¶ added in v1.4.7
func (w *WeChatClient) DownloadBill(body BodyMap) (wxRsp string, err error)
下载对账单
文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6
func (*WeChatClient) DownloadFundFlow ¶ added in v1.4.7
func (w *WeChatClient) DownloadFundFlow(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp string, err error)
下载资金账单
注意:如已使用client.AddCertFilePath()或client.AddCertFileByte()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传空字符串 "",如方法需单独使用证书,则传证书Path 貌似不支持沙箱环境,因为沙箱环境默认需要用MD5签名,但是此接口仅支持HMAC-SHA256签名 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_18&index=7
func (*WeChatClient) EntrustPublic ¶ added in v1.4.7
func (w *WeChatClient) EntrustPublic(body BodyMap) (bs []byte, err error)
公众号纯签约(未完成)
文档地址:https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_1&index=1
func (*WeChatClient) Micropay ¶ added in v1.4.7
func (w *WeChatClient) Micropay(body BodyMap) (wxRsp *WeChatMicropayResponse, err error)
提交付款码支付
文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
func (*WeChatClient) QueryOrder ¶ added in v1.4.7
func (w *WeChatClient) QueryOrder(body BodyMap) (wxRsp *WeChatQueryOrderResponse, err error)
查询订单
文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
func (*WeChatClient) QueryRefund ¶ added in v1.4.7
func (w *WeChatClient) QueryRefund(body BodyMap) (wxRsp *WeChatQueryRefundResponse, err error)
查询退款
文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5
func (*WeChatClient) Refund ¶ added in v1.4.7
func (w *WeChatClient) Refund(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp *WeChatRefundResponse, err error)
申请退款
注意:如已使用client.AddCertFilePath()或client.AddCertFileByte()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传空字符串 "",如方法需单独使用证书,则传证书Path 文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
func (*WeChatClient) Reverse ¶ added in v1.4.7
func (w *WeChatClient) Reverse(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp *WeChatReverseResponse, err error)
撤销订单
注意:如已使用client.AddCertFilePath()或client.AddCertFileByte()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传空字符串 "",如方法需单独使用证书,则传证书Path 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3
func (*WeChatClient) SetCountry ¶ added in v1.4.7
func (w *WeChatClient) SetCountry(country Country) (client *WeChatClient)
设置支付国家(默认:中国国内)
根据支付地区情况设置国家 country:<China:中国国内,China2:中国国内(冗灾方案),SoutheastAsia:东南亚,Other:其他国家>
func (*WeChatClient) Transfer ¶ added in v1.4.7
func (w *WeChatClient) Transfer(body BodyMap, certFilePath, keyFilePath, pkcs12FilePath string) (wxRsp *WeChatTransfersResponse, err error)
企业向微信用户个人付款
注意:如已使用client.AddCertFilePath()或client.AddCertFileByte()添加过证书,参数certFilePath、keyFilePath、pkcs12FilePath全传空字符串 "",如方法需单独使用证书,则传证书Path 注意:此方法未支持沙箱环境,默认正式环境,转账请慎重 文档地址:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_1
func (*WeChatClient) UnifiedOrder ¶ added in v1.4.7
func (w *WeChatClient) UnifiedOrder(body BodyMap) (wxRsp *WeChatUnifiedOrderResponse, err error)
统一下单
文档地址:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1
type WeChatCloseOrderResponse ¶
type WeChatCloseOrderResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` }
type WeChatMicropayResponse ¶
type WeChatMicropayResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` Openid string `xml:"openid,omitempty" json:"openid,omitempty"` IsSubscribe string `xml:"is_subscribe,omitempty" json:"is_subscribe,omitempty"` TradeType string `xml:"trade_type,omitempty" json:"trade_type,omitempty"` BankType string `xml:"bank_type,omitempty" json:"bank_type,omitempty"` FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` CouponFee int `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"` CashFeeType string `xml:"cash_fee_type,omitempty" json:"cash_fee_type,omitempty"` CashFee int `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"` TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` Attach string `xml:"attach,omitempty" json:"attach,omitempty"` TimeEnd string `xml:"time_end,omitempty" json:"time_end,omitempty"` PromotionDetail string `xml:"promotion_detail,omitempty" json:"promotion_detail,omitempty"` }
type WeChatNotifyRequest ¶
type WeChatNotifyRequest struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` SignType string `xml:"sign_type,omitempty" json:"sign_type,omitempty"` Openid string `xml:"openid,omitempty" json:"openid,omitempty"` IsSubscribe string `xml:"is_subscribe,omitempty" json:"is_subscribe,omitempty"` TradeType string `xml:"trade_type,omitempty" json:"trade_type,omitempty"` BankType string `xml:"bank_type,omitempty" json:"bank_type,omitempty"` TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` CashFee int `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"` CashFeeType string `xml:"cash_fee_type,omitempty" json:"cash_fee_type,omitempty"` CouponFee int `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"` CouponCount int `xml:"coupon_count,omitempty" json:"coupon_count,omitempty"` CouponType0 string `xml:"coupon_type_0,omitempty" json:"coupon_type_0,omitempty"` CouponType1 string `xml:"coupon_type_1,omitempty" json:"coupon_type_1,omitempty"` CouponId0 string `xml:"coupon_id_0,omitempty" json:"coupon_id_0,omitempty"` CouponId1 string `xml:"coupon_id_1,omitempty" json:"coupon_id_1,omitempty"` CouponFee0 int `xml:"coupon_fee_0,omitempty" json:"coupon_fee_0,omitempty"` CouponFee1 int `xml:"coupon_fee_1,omitempty" json:"coupon_fee_1,omitempty"` TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` Attach string `xml:"attach,omitempty" json:"attach,omitempty"` TimeEnd string `xml:"time_end,omitempty" json:"time_end,omitempty"` }
func ParseWeChatNotifyResult ¶ added in v1.4.7
func ParseWeChatNotifyResult(req *http.Request) (notifyReq *WeChatNotifyRequest, err error)
解析微信支付异步通知的参数
req:*http.Request 返回参数notifyReq:Notify请求的参数 返回参数err:错误信息
type WeChatNotifyResponse ¶
type WeChatNotifyResponse struct { ReturnCode string `xml:"return_code"` ReturnMsg string `xml:"return_msg"` }
func (*WeChatNotifyResponse) ToXmlString ¶
func (w *WeChatNotifyResponse) ToXmlString() (xmlStr string)
返回数据给微信
type WeChatQueryOrderResponse ¶
type WeChatQueryOrderResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` Openid string `xml:"openid,omitempty" json:"openid,omitempty"` IsSubscribe string `xml:"is_subscribe,omitempty" json:"is_subscribe,omitempty"` TradeType string `xml:"trade_type,omitempty" json:"trade_type,omitempty"` TradeState string `xml:"trade_state,omitempty" json:"trade_state,omitempty"` BankType string `xml:"bank_type,omitempty" json:"bank_type,omitempty"` TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` CashFee int `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"` CashFeeType string `xml:"cash_fee_type,omitempty" json:"cash_fee_type,omitempty"` CouponFee int `xml:"coupon_fee,omitempty" json:"coupon_fee,omitempty"` CouponCount int `xml:"coupon_count,omitempty" json:"coupon_count,omitempty"` CouponType0 string `xml:"coupon_type_0,omitempty" json:"coupon_type_0,omitempty"` CouponType1 string `xml:"coupon_type_1,omitempty" json:"coupon_type_1,omitempty"` CouponId0 string `xml:"coupon_id_0,omitempty" json:"coupon_id_0,omitempty"` CouponId1 string `xml:"coupon_id_1,omitempty" json:"coupon_id_1,omitempty"` CouponFee0 int `xml:"coupon_fee_0,omitempty" json:"coupon_fee_0,omitempty"` CouponFee1 int `xml:"coupon_fee_1,omitempty" json:"coupon_fee_1,omitempty"` TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` Attach string `xml:"attach,omitempty" json:"attach,omitempty"` TimeEnd string `xml:"time_end,omitempty" json:"time_end,omitempty"` TradeStateDesc string `xml:"trade_state_desc,omitempty" json:"trade_state_desc,omitempty"` }
type WeChatQueryRefundResponse ¶
type WeChatQueryRefundResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` TotalRefundCount int `xml:"total_refund_count,omitempty" json:"total_refund_count,omitempty"` TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` CashFee int `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"` RefundCount int `xml:"refund_count,omitempty" json:"refund_count,omitempty"` OutRefundNo0 string `xml:"out_refund_no_0,omitempty" json:"out_refund_no_0,omitempty"` OutRefundNo1 string `xml:"out_refund_no_1,omitempty" json:"out_refund_no_1,omitempty"` RefundId0 string `xml:"refund_id_0,omitempty" json:"refund_id_0,omitempty"` RefundId1 string `xml:"refund_id_1,omitempty" json:"refund_id_1,omitempty"` RefundChannel0 string `xml:"refund_channel_0,omitempty" json:"refund_channel_0,omitempty"` RefundChannel1 string `xml:"refund_channel_1,omitempty" json:"refund_channel_1,omitempty"` RefundFee int `xml:"refund_fee,omitempty" json:"refund_fee,omitempty"` RefundFee0 int `xml:"refund_fee_0,omitempty" json:"refund_fee_0,omitempty"` RefundFee1 int `xml:"refund_fee_1,omitempty" json:"refund_fee_1,omitempty"` SettlementRefundFee0 int `xml:"settlement_refund_fee_0,omitempty" json:"settlement_refund_fee_0,omitempty"` SettlementRefundFee1 int `xml:"settlement_refund_fee_1,omitempty" json:"settlement_refund_fee_1,omitempty"` CouponType00 string `xml:"coupon_type_0_0,omitempty" json:"coupon_type_0_0,omitempty"` CouponType01 string `xml:"coupon_type_0_1,omitempty" json:"coupon_type_0_1,omitempty"` CouponType10 string `xml:"coupon_type_1_0,omitempty" json:"coupon_type_1_0,omitempty"` CouponType11 string `xml:"coupon_type_1_1,omitempty" json:"coupon_type_1_1,omitempty"` CouponRefundFee0 int `xml:"coupon_refund_fee_0,omitempty" json:"coupon_refund_fee_0,omitempty"` CouponRefundFee1 int `xml:"coupon_refund_fee_1,omitempty" json:"coupon_refund_fee_1,omitempty"` CouponRefundCount0 int `xml:"coupon_refund_count_0,omitempty" json:"coupon_refund_count_0,omitempty"` CouponRefundCount1 int `xml:"coupon_refund_count_1,omitempty" json:"coupon_refund_count_1,omitempty"` CouponRefundId00 string `xml:"coupon_refund_id_0_0,omitempty" json:"coupon_refund_id_0_0,omitempty"` CouponRefundId01 string `xml:"coupon_refund_id_0_1,omitempty" json:"coupon_refund_id_0_1,omitempty"` CouponRefundId10 string `xml:"coupon_refund_id_1_0,omitempty" json:"coupon_refund_id_1_0,omitempty"` CouponRefundId11 string `xml:"coupon_refund_id_1_1,omitempty" json:"coupon_refund_id_1_1,omitempty"` CouponRefundFee00 int `xml:"coupon_refund_fee_0_0,omitempty" json:"coupon_refund_fee_0_0,omitempty"` CouponRefundFee01 int `xml:"coupon_refund_fee_0_1,omitempty" json:"coupon_refund_fee_0_1,omitempty"` CouponRefundFee10 int `xml:"coupon_refund_fee_1_0,omitempty" json:"coupon_refund_fee_1_0,omitempty"` CouponRefundFee11 int `xml:"coupon_refund_fee_1_1,omitempty" json:"coupon_refund_fee_1_1,omitempty"` RefundStatus0 string `xml:"refund_status_0,omitempty" json:"refund_status_0,omitempty"` RefundStatus1 string `xml:"refund_status_1,omitempty" json:"refund_status_1,omitempty"` RefundAccount0 string `xml:"refund_account_0,omitempty" json:"refund_account_0,omitempty"` RefundAccount1 string `xml:"refund_account_1,omitempty" json:"refund_account_1,omitempty"` RefundRecvAccout0 string `xml:"refund_recv_accout_0,omitempty" json:"refund_recv_accout_0,omitempty"` RefundRecvAccout1 string `xml:"refund_recv_accout_1,omitempty" json:"refund_recv_accout_1,omitempty"` RefundSuccessTime0 string `xml:"refund_success_time_0,omitempty" json:"refund_success_time_0,omitempty"` RefundSuccessTime1 string `xml:"refund_success_time_1,omitempty" json:"refund_success_time_1,omitempty"` }
type WeChatRefundNotifyRequest ¶ added in v1.4.7
type WeChatRefundNotifyRequest struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` ReqInfo string `xml:"req_info,omitempty" json:"req_info,omitempty"` }
func ParseWeChatRefundNotifyResult ¶ added in v1.4.7
func ParseWeChatRefundNotifyResult(req *http.Request) (notifyReq *WeChatRefundNotifyRequest, err error)
解析微信退款异步通知的参数
req:*http.Request 返回参数notifyReq:Notify请求的参数 返回参数err:错误信息
type WeChatRefundResponse ¶
type WeChatRefundResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` TransactionId string `xml:"transaction_id,omitempty" json:"transaction_id,omitempty"` OutTradeNo string `xml:"out_trade_no,omitempty" json:"out_trade_no,omitempty"` OutRefundNo string `xml:"out_refund_no,omitempty" json:"out_refund_no,omitempty"` RefundId string `xml:"refund_id,omitempty" json:"refund_id,omitempty"` RefundFee int `xml:"refund_fee,omitempty" json:"refund_fee,omitempty"` SettlementRefundFee int `xml:"settlement_refund_fee,omitempty" json:"settlement_refund_fee,omitempty"` TotalFee int `xml:"total_fee,omitempty" json:"total_fee,omitempty"` SettlementTotalFee int `xml:"settlement_total_fee,omitempty" json:"settlement_total_fee,omitempty"` FeeType string `xml:"fee_type,omitempty" json:"fee_type,omitempty"` CashFee int `xml:"cash_fee,omitempty" json:"cash_fee,omitempty"` CashFeeType string `xml:"cash_fee_type,omitempty" json:"cash_fee_type,omitempty"` CashRefundFee int `xml:"cash_refund_fee,omitempty" json:"cash_refund_fee,omitempty"` CouponType0 string `xml:"coupon_type_0,omitempty" json:"coupon_type_0,omitempty"` CouponType1 string `xml:"coupon_type_1,omitempty" json:"coupon_type_1,omitempty"` CouponRefundFee int `xml:"coupon_refund_fee,omitempty" json:"coupon_refund_fee,omitempty"` CouponRefundFee0 int `xml:"coupon_refund_fee_0,omitempty" json:"coupon_refund_fee_0,omitempty"` CouponRefundFee1 int `xml:"coupon_refund_fee_1,omitempty" json:"coupon_refund_fee_1,omitempty"` CouponRefundCount int `xml:"coupon_refund_count,omitempty" json:"coupon_refund_count,omitempty"` CouponRefundId0 string `xml:"coupon_refund_id_0,omitempty" json:"coupon_refund_id_0,omitempty"` CouponRefundId1 string `xml:"coupon_refund_id_1,omitempty" json:"coupon_refund_id_1,omitempty"` }
type WeChatReverseResponse ¶
type WeChatReverseResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` Recall string `xml:"recall,omitempty" json:"recall,omitempty"` }
type WeChatTransfersResponse ¶ added in v1.4.7
type WeChatTransfersResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` MchAppid string `xml:"mch_appid,omitempty" json:"mch_appid,omitempty"` Mchid string `xml:"mchid,omitempty" json:"mchid,omitempty"` DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` PartnerTradeNo string `xml:"partner_trade_no,omitempty" json:"partner_trade_no,omitempty"` PaymentNo string `xml:"payment_no,omitempty" json:"payment_no,omitempty"` PaymentTime string `xml:"payment_time,omitempty" json:"payment_time,omitempty"` }
type WeChatUnifiedOrderResponse ¶
type WeChatUnifiedOrderResponse struct { ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"` ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"` Appid string `xml:"appid,omitempty" json:"appid,omitempty"` MchId string `xml:"mch_id,omitempty" json:"mch_id,omitempty"` DeviceInfo string `xml:"device_info,omitempty" json:"device_info,omitempty"` NonceStr string `xml:"nonce_str,omitempty" json:"nonce_str,omitempty"` Sign string `xml:"sign,omitempty" json:"sign,omitempty"` ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"` ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"` ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"` TradeType string `xml:"trade_type,omitempty" json:"trade_type,omitempty"` PrepayId string `xml:"prepay_id,omitempty" json:"prepay_id,omitempty"` CodeUrl string `xml:"code_url,omitempty" json:"code_url,omitempty"` MwebUrl string `xml:"mweb_url,omitempty" json:"mweb_url,omitempty"` }
type WeChatUserInfo ¶ added in v1.0.7
type WeChatUserInfo struct { Subscribe int `json:"subscribe,omitempty"` // 用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。 Openid string `json:"openid,omitempty"` // 用户唯一标识 Nickname string `json:"nickname,omitempty"` // 用户的昵称 Sex int `json:"sex,omitempty"` // 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知 Language string `json:"language,omitempty"` // 用户的语言,简体中文为zh_CN City string `json:"city,omitempty"` // 用户所在城市 Province string `json:"province,omitempty"` // 用户所在省份 Country string `json:"country,omitempty"` // 用户所在国家 Headimgurl string `json:"headimgurl,omitempty"` // 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。 SubscribeTime int `json:"subscribe_time,omitempty"` // 用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间 Unionid string `json:"unionid,omitempty"` // 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。 Remark string `json:"remark,omitempty"` // 公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注 Groupid int `json:"groupid,omitempty"` // 用户所在的分组ID(兼容旧的用户分组接口) TagidList []int `json:"tagid_list,omitempty"` // 用户被打上的标签ID列表 SubscribeScene string `json:"subscribe_scene,omitempty"` // 返回用户关注的渠道来源,ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENEPROFILE LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_OTHERS 其他 QrScene int `json:"qr_scene,omitempty"` // 二维码扫码场景(开发者自定义) QrSceneStr string `json:"qr_scene_str,omitempty"` // 二维码扫码场景描述(开发者自定义) Errcode int `json:"errcode,omitempty"` // 错误码 Errmsg string `json:"errmsg,omitempty"` // 错误信息 }
func GetWeChatUserInfo ¶ added in v1.0.7
func GetWeChatUserInfo(accessToken, openId string, lang ...string) (userInfo *WeChatUserInfo, err error)
获取用户基本信息(UnionID机制)
accessToken:接口调用凭据 openId:用户的OpenID lang:默认为 zh_CN ,可选填 zh_CN 简体,zh_TW 繁体,en 英语 获取用户基本信息(UnionID机制)文档:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839
type WeChatUserPhone ¶ added in v1.0.7
type WeChatUserPhone struct { PhoneNumber string `json:"phoneNumber,omitempty"` PurePhoneNumber string `json:"purePhoneNumber,omitempty"` CountryCode string `json:"countryCode,omitempty"` Watermark *watermarkInfo `json:"watermark,omitempty"` }
微信小程序解密后 用户手机号结构体
type ZhimaCreditScoreGetResponse ¶ added in v1.4.7
type ZhimaCreditScoreGetResponse struct { Response *scoreGetResponse `json:"zhima_credit_score_get_response,omitempty"` AliPayCertSn string `json:"alipay_cert_sn,omitempty"` SignData string `json:"-"` Sign string `json:"sign"` }
===================================================