- 统一下单:client.UnifiedOrder()
- JSAPI - JSAPI支付(或小程序支付)
- NATIVE - Native支付
- APP - app支付
- MWEB - H5支付
- 提交付款码支付:client.Micropay()
- 查询订单:client.QueryOrder()
- 关闭订单:client.CloseOrder()
- 撤销订单:client.Reverse()
- 申请退款:client.Refund()
- 查询退款:client.QueryRefund()
- 下载对账单:client.DownloadBill()
- 下载资金账单:client.DownloadFundFlow()
- 拉取订单评价数据:client.BatchQueryComment()
- gopay.ParseNotifyResult() => 解析并返回微信支付异步通知的参数
- gopay.VerifyPayResultSign() => 微信支付异步通知的签名验证和返回参数验签后的Sign
- gopay.Code2Session() => 登录凭证校验:获取微信用户OpenId、UnionId、SessionKey
- gopay.GetAccessToken() => 获取小程序全局唯一后台接口调用凭据
- gopay.GetPaidUnionId() => 用户支付完成后,获取该用户的 UnionId,无需用户授权
- gopay.GetWeChatUserInfo() => 微信公众号:获取用户基本信息(UnionID机制)
- gopay.DecryptOpenDataToStruct() => 加密数据,解密到指定结构体
- 手机网站支付:client.AliPayTradeWapPay()
- APP支付:client.AliPayTradeAppPay()
- gopay.FormatPrivateKey() => 格式化应用私钥
- gopay.FormatAliPayPublicKey() => 格式化支付宝公钥
- gopay.ParseAliPayNotifyResult() => 解析并返回支付宝支付异步通知的参数
- gopay.VerifyAliPayResultSign() => 支付宝支付异步通知的签名验证和返回参数验签后的Sign
$ go get -u github.com/iGoogle-ink/gopay
- 未完成,有问题+微信
注意:具体参数根据请求的不同而不同,请参考微信官方文档的参数说明!
参考文档:微信支付文档
userIdRsp, err := gopay.Code2Session(appID, secretKey, "")
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("OpenID:", userIdRsp.Openid)
fmt.Println("UnionID:", userIdRsp.Unionid)
fmt.Println("SessionKey:", userIdRsp.SessionKey)
- 小程序支付所需要的参数,paySign由后端计算
- timeStamp
- nonceStr
- package
- signType
- paySign
官方文档说明微信小程序支付API
timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
packages := "prepay_id=" + wxRsp.PrepayId //此处的 wxRsp.PrepayId ,统一下单成功后得到
paySign := gopay.GetMiniPaySign("wxd678efh567hg6787", wxRsp.NonceStr, packages, gopay.SignType_MD5, timeStamp, "192006250b4c09247ec02edce69f6a2d")
//微信小程序支付需要的参数信息
fmt.Println("timeStamp:", timeStamp)
fmt.Println("nonceStr:", wxRsp.NonceStr)
fmt.Println("package:", packages)
fmt.Println("signType:", gopay.SignType_MD5)
fmt.Println("paySign:", paySign)
- 微信内H5支付所需要的参数,paySign由后端计算
- appId
- timeStamp
- nonceStr
- package
- signType
- paySign
官方文档说明微信内H5支付文档
timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
packages := "prepay_id=" + wxRsp.PrepayId //此处的 wxRsp.PrepayId ,统一下单成功后得到
paySign := gopay.GetH5PaySign("wxd678efh567hg6787", wxRsp.NonceStr, packages, gopay.SignType_MD5, timeStamp, "192006250b4c09247ec02edce69f6a2d")
//微信内H5支付需要的参数信息
fmt.Println("appId:","wxd678efh567hg6787")
fmt.Println("timeStamp:", timeStamp)
fmt.Println("nonceStr:", wxRsp.NonceStr)
fmt.Println("package:", packages)
fmt.Println("signType:", gopay.SignType_MD5)
fmt.Println("paySign:", paySign)
- APP支付所需要的参数,paySign由后端计算
- appid
- partnerid
- noncestr
- prepayid
- package
- timestamp
- sign
官方文档说明APP端调起支付的参数列表文档
timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
//注意:signType:此处签名方式,务必与统一下单时用的签名方式一致
//注意:package:参数因为是固定值,不需开发者再传入
sign := gopay.GetH5PaySign(appid, partnerid, wxRsp.NonceStr, prepayid, gopay.SignType_MD5, timeStamp, apiKey)
//APP支付需要的参数信息
fmt.Println("sign:", sign)
微信支付后的异步通知文档支付结果通知
//解析支付完成后的异步通知参数信息
//此处 c.Request() 为 *http.Request
notifyRsp, err := gopay.ParseNotifyResult(c.Request())
if err != nil {
fmt.Println("err:", err)
}
fmt.Println("notifyRsp:", notifyRsp)
//支付通知的签名验证和参数签名后的Sign
// apiKey:API秘钥值
// signType:签名类型 MD5 或 HMAC-SHA256(默认请填写 MD5)
// notifyRsp:利用 gopay.ParseNotifyResult() 得到的结构体
// 返回参数ok:是否验证通过
// 返回参数sign:根据参数计算的sign值,非微信返回参数中的Sign
ok, sign := gopay.VerifyPayResultSign("192006250b4c09247ec02edce69f6a2d", "MD5", notifyRsp)
log.Println("ok:", ok)
log.Println("sign:", sign)
拿小程序获取手机号为例
button按钮获取手机号码:button组件文档
微信解密算法文档:解密算法文档
data := "Kf3TdPbzEmhWMuPKtlKxIWDkijhn402w1bxoHL4kLdcKr6jT1jNcIhvDJfjXmJcgDWLjmBiIGJ5acUuSvxLws3WgAkERmtTuiCG10CKLsJiR+AXVk7B2TUQzsq88YVilDz/YAN3647REE7glGmeBPfvUmdbfDzhL9BzvEiuRhABuCYyTMz4iaM8hFjbLB1caaeoOlykYAFMWC5pZi9P8uw=="
iv := "Cds8j3VYoGvnTp1BrjXdJg=="
sessionKey := "lyY4HPQbaOYzZdG+JcYK9w=="
phone := new(gopay.WeChatUserPhone)
err := gopay.DecryptOpenDataToStruct(data, iv, sessionKey, phone)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println("PhoneNumber:", phone.PhoneNumber)
fmt.Println("PurePhoneNumber:", phone.PurePhoneNumber)
fmt.Println("CountryCode:", phone.CountryCode)
fmt.Println("Watermark:", phone.Watermark)
代码中return写法,由于本人用的Echo Web框架,有兴趣的可以尝试一下
rsp := new(gopay.WeChatNotifyResponse) //回复微信的数据
rsp.ReturnCode = "SUCCESS"
rsp.ReturnMsg = "OK"
return c.String(http.StatusOK, rsp.ToXmlString())
//初始化微信客户端
// appId:应用ID
// mchID:商户ID
// apiKey:API秘钥值
// isProd:是否是正式环境
client := gopay.NewWeChatClient("wxd678efh567hg6787", "1230000109", "192006250b4c09247ec02edce69f6a2d", false)
//初始化参数Map
body := make(gopay.BodyMap)
body.Set("nonce_str", gopay.GetRandomString(32))
body.Set("body", "测试支付")
number := gopay.GetRandomString(32)
log.Println("Number:", number)
body.Set("out_trade_no", number)
body.Set("total_fee", 1)
body.Set("spbill_create_ip", "127.0.0.1") //终端IP
body.Set("notify_url", "http://www.gopay.ink")
body.Set("trade_type", gopay.TradeType_JsApi)
body.Set("device_info", "WEB")
body.Set("sign_type", gopay.SignType_MD5)
//body.Set("scene_info", `{"h5_info": {"type":"Wap","wap_url": "http://www.gopay.ink","wap_name": "测试支付"}}`)
body.Set("openid", "o0Df70H2Q0fY8JXh1aFPIRyOBgu6")
//发起下单请求
wxRsp, err := client.UnifiedOrder(body)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("ReturnCode:", wxRsp.ReturnCode)
fmt.Println("ReturnMsg:", wxRsp.ReturnMsg)
fmt.Println("Appid:", wxRsp.Appid)
fmt.Println("MchId:", wxRsp.MchId)
fmt.Println("DeviceInfo:", wxRsp.DeviceInfo)
fmt.Println("NonceStr:", wxRsp.NonceStr)
fmt.Println("Sign:", wxRsp.Sign)
fmt.Println("ResultCode:", wxRsp.ResultCode)
fmt.Println("ErrCode:", wxRsp.ErrCode)
fmt.Println("ErrCodeDes:", wxRsp.ErrCodeDes)
fmt.Println("PrepayId:", wxRsp.PrepayId)
fmt.Println("TradeType:", wxRsp.TradeType)
fmt.Println("CodeUrl:", wxRsp.CodeUrl)
fmt.Println("MwebUrl:", wxRsp.MwebUrl)
//初始化微信客户端
// appId:应用ID
// mchID:商户ID
// apiKey:API秘钥值
// isProd:是否是正式环境
client := gopay.NewWeChatClient("wxd678efh567hg6787", "1230000109", "192006250b4c09247ec02edce69f6a2d", false)
//初始化参数Map
body := make(gopay.BodyMap)
body.Set("nonce_str", gopay.GetRandomString(32))
body.Set("body", "扫用户付款码支付")
number := gopay.GetRandomString(32)
log.Println("Number:", number)
body.Set("out_trade_no", number)
body.Set("total_fee", 1)
body.Set("spbill_create_ip", "127.0.0.1")
body.Set("notify_url", "http://www.gopay.ink")
body.Set("auth_code", "120061098828009406")
body.Set("sign_type", gopay.SignType_MD5)
//请求支付,成功后得到结果
wxRsp, err := client.Micropay(body)
if err != nil {
fmt.Println("Error:", err)
}
fmt.Println("Response:", wxRsp)
//初始化微信客户端
// appId:应用ID
// mchID:商户ID
// apiKey:API秘钥值
// isProd:是否是正式环境
client := gopay.NewWeChatClient("wxd678efh567hg6787", "1230000109", "192006250b4c09247ec02edce69f6a2d", false)
//初始化参数结构体
body := make(gopay.BodyMap)
body.Set("out_trade_no", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
body.Set("nonce_str", gopay.GetRandomString(32))
body.Set("sign_type", gopay.SignType_MD5)
s := gopay.GetRandomString(64)
fmt.Println("s:", s)
body.Set("out_refund_no", s)
body.Set("total_fee", 101)
body.Set("refund_fee", 101)
//请求申请退款(沙箱环境下,证书路径参数可传空)
// body:参数Body
// certFilePath:cert证书路径
// keyFilePath:Key证书路径
// pkcs12FilePath:p12证书路径
wxRsp, err := client.Refund(body, "", "", "")
if err != nil {
fmt.Println("Error:", err)
}
fmt.Println("Response:", wxRsp)
注意:具体请求参数根据请求的不同而不同,请参考支付宝官方文档的参数说明!
支付宝官方文档:官方文档
支付宝RSA秘钥生成文档:生成 RSA 密钥
支付宝在线调试:在线调试地址
沙箱环境使用说明:文档地址
支付宝支付后的异步通知验签文档支付结果通知
//解析支付完成后的异步通知参数信息
//此处 c.Request() 为 *http.Request
notifyRsp, err := gopay.ParseAliPayNotifyResult(c.Request())
if err != nil {
fmt.Println("gopay.ParseAliPayNotifyResult:", err)
return
}
fmt.Println("notifyRsp:", notifyRsp)
aliPayPublicKey := "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1wn1sU/8Q0rYLlZ6sq3enrPZw2ptp6FecHR2bBFLjJ+sKzepROd0bKddgj+Mr1ffr3Ej78mLdWV8IzLfpXUi945DkrQcOUWLY0MHhYVG2jSs/qzFfpzmtut2Cl2TozYpE84zom9ei06u2AXLMBkU6VpznZl+R4qIgnUfByt3Ix5b3h4Cl6gzXMAB1hJrrrCkq+WvWb3Fy0vmk/DUbJEz8i8mQPff2gsHBE1nMPvHVAMw1GMk9ImB4PxucVek4ZbUzVqxZXphaAgUXFK2FSFU+Q+q1SPvHbUsjtIyL+cLA6H/6ybFF9Ffp27Y14AHPw29+243/SpMisbGcj2KD+evBwIDAQAB"
//验签操作
// aliPayPublicKey:支付宝公钥
// notifyRsp:利用 gopay.ParseAliPayNotifyResult() 得到的结构体
// 返回参数ok:是否验证通过
// 返回参数err:错误信息
ok, err := gopay.VerifyAliPayResultSign(aliPayPublicKey, notifyRsp)
if err != nil {
log.Println("gopay.VerifyAliPayResultSign:", err)
return
}
fmt.Println("ok:", ok)
- 程序执行完后必须打印输出“success”(不包含引号)。如果商户反馈给支付宝的字符不是success这7个字符,支付宝服务器会不断重发通知,直到超过24小时22分钟。一般情况下,25小时以内完成8次通知(通知的间隔频率一般是:4m,10m,10m,1h,2h,6h,15h)
代码中return写法,由于本人用的Echo Web框架,有兴趣的可以尝试一下
return c.String(http.StatusOK, "success")
- 手机网站支付是通过服务端获取支付URL后,然后返回给客户端,请求URL地址即可打开支付页面
文档说明手机网站支付-请求参数说明
文档说明手机网站支付接口2.0
privateKey := "MIIEogIBAAKCAQEAy+CRzKw4krA2RzCDTqg5KJg92XkOY0RN3pW4sYInPqnGtHV7YDHu5nMuxY6un+dLfo91OFOEg+RI+WTOPoM4xJtsOaJwQ1lpjycoeLq1OyetGW5Q8wO+iLWJASaMQM/t/aXR/JHaguycJyqlHSlxANvKKs/tOHx9AhW3LqumaCwz71CDF/+70scYuZG/7wxSjmrbRBswxd1Sz9KHdcdjqT8pmieyPqnM24EKBexHDmQ0ySXvLJJy6eu1dJsPIz+ivX6HEfDXmSmJ71AZVqZyCI1MhK813R5E7XCv5NOtskTe3y8uiIhgGpZSdB77DOyPLcmVayzFVLAQ3AOBDmsY6wIDAQABAoIBAHjsNq31zAw9FcR9orQJlPVd7vlJEt6Pybvmg8hNESfanO+16rpwg2kOEkS8zxgqoJ1tSz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R7N6KU1kdoVWgN4BhXSwuRxmHMQfSY7q3HG3rDGz7mzXo1FVMr/uE4iDGm0IXY="
//初始化支付宝客户端
// appId:应用ID
// privateKey:应用秘钥
// isProd:是否是正式环境
client := gopay.NewAliPayClient("2016091200494382", privateKey, false)
//配置公共参数
client.SetCharset("utf-8").
SetSignType("RSA2").
//SetAppAuthToken("").
//SetReturnUrl("https://www.gopay.ink").
SetNotifyUrl("https://www.gopay.ink")
//请求参数
body := make(gopay.BodyMap)
body.Set("subject", "测试支付")
body.Set("out_trade_no", "GYWX201901301040355706100409")
body.Set("quit_url", "https://www.gopay.ink")
body.Set("total_amount", "10.00")
body.Set("product_code", "QUICK_WAP_WAY")
//手机网站支付请求
payUrl, err := client.AliPayTradeWapPay(body)
if err != nil {
log.Println("err:", err)
return
}
fmt.Println("payUrl:", payUrl)
- APP支付是通过服务端获取支付参数后,然后通过Android/iOS客户端的SDK调用支付功能
文档说明APP支付-请求参数说明
文档说明APP支付接口2.0
privateKey := "MIIEogIBAAKCAQEAy+CRzKw4krA2RzCDTqg5KJg92XkOY0RN3pW4sYInPqnGtHV7YDHu5nMuxY6un+dLfo91OFOEg+RI+WTOPoM4xJtsOaJwQ1lpjycoeLq1OyetGW5Q8wO+iLWJASaMQM/t/aXR/JHaguycJyqlHSlxANvKKs/tOHx9AhW3LqumaCwz71CDF/+70scYuZG/7wxSjmrbRBswxd1Sz9KHdcdjqT8pmieyPqnM24EKBexHDmQ0ySXvLJJy6eu1dJsPIz+ivX6HEfDXmSmJ71AZVqZyCI1MhK813R5E7XCv5NOtskTe3y8uiIhgGpZSdB77DOyPLcmVayzFVLAQ3AOBDmsY6wIDAQABAoIBAHjsNq31zAw9FcR9orQJlPVd7vlJEt6Pybvmg8hNESfanO+16rpwg2kOEkS8zxgqoJ1tSzJgXu23fgzl3Go5fHcoVDWPAhUAOFre9+M7onh2nPXDd6Hbq6v8OEmFapSaf2b9biHnBHq5Chk08v/r74l501w3PVVOiPqulJrK1oVb+0/YmC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isProd:是否是正式环境
client := gopay.NewAliPayClient("2016091200494382", privateKey, false)
//配置公共参数
client.SetCharset("utf-8").
SetSignType("RSA2").
//SetAppAuthToken("").
//SetReturnUrl("https://www.gopay.ink").
SetNotifyUrl("https://www.gopay.ink")
//请求参数
body := make(gopay.BodyMap)
body.Set("subject", "测试APP支付")
body.Set("out_trade_no", "GYWX201901301040355706100411")
body.Set("total_amount", "1.00")
//手机APP支付参数请求
payParam, err := client.AliPayTradeAppPay(body)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println("payParam:", payParam)
- 电脑网站支付是通过服务端获取支付URL后,然后返回给客户端,请求URL地址即可打开支付页面
文档说明电脑网站支付
文档说明统一收单下单并支付页面接口
privateKey := "MIIEogIBAAKCAQEAy+CRzKw4krA2RzCDTqg5KJg92XkOY0RN3pW4sYInPqnGtHV7YDHu5nMuxY6un+dLfo91OFOEg+RI+WTOPoM4xJtsOaJwQ1lpjycoeLq1OyetGW5Q8wO+iLWJASaMQM/t/aXR/JHaguycJyqlHSlxANvKKs/tOHx9AhW3LqumaCwz71CDF/+70scYuZG/7wxSjmrbRBswxd1Sz9KHdcdjqT8pmieyPqnM24EKBexHDmQ0ySXvLJJy6eu1dJsPIz+ivX6HEfDXmSmJ71AZVqZyCI1MhK813R5E7XCv5NOtskTe3y8uiIhgGpZSdB77DOyPLcmVayzFVLAQ3AOBDmsY6wIDAQABAoIBAHjsNq31zAw9FcR9orQJlPVd7vlJEt6Pybvmg8hNESfanO+16rpwg2kOEkS8zxgqoJ1tSzJgXu23fgzl3Go5fHcoVDWPAhUAOFre9+M7onh2nPXDd6Hbq6v8OEmFapSaf2b9biHnBHq5Chk08v/r74l501w3PVVOiPqulJrK1oVb+0/YmCvVFpGatBcNaefKUEcA+vekWPL7Yl46k6XeUvRfTwomCD6jpYLUhsAKqZiQJhMGoaLglZvkokQMF/4G78K7FbbVLMM1+JDh8zJ/DDVdY2vHREUcCGhl4mCVQtkzIbpxG++vFg7/g/fDI+PquG22hFILTDdtt2g2fV/4wmkCgYEA6goRQYSiM03y8Tt/M4u1Mm7OWYCksqAsU7rzQllHekIN3WjD41Xrjv6uklsX3sTG1syo7Jr9PGE1xQgjDEIyO8h/3lDQyLyycYnyUPGNNMX8ZjmGwcM51DQ/QfIrY/CXjnnW+MVpmNclAva3L33KXCWjw20VsROV1EA8LCL94BUCgYEA3wH4ANpzo7NqXf+2WlPPMuyRrF0QPIRGlFBNtaKFy0mvoclkREPmK7+N4NIGtMf5JNODS5HkFRgmU4YNdupA2I8lIYpD+TsIobZxGUKUkYzRZYZ1m1ttL69YYvCVz9Xosw/VoQ+RrW0scS5yUKqFMIUOV2R/Imi//c5TdKx6VP8CgYAnJ1ADugC4vI2sNdvt7618pnT3HEJxb8J6r4gKzYzbszlGlURQQAuMfKcP7RVtO1ZYkRyhmLxM4aZxNA9I+boVrlFWDAchzg+8VuunBwIslgLHx0/4EoUWLzd1/OGtco6oU1HXhI9J9pRGjqfO1iiIifN/ujwqx7AFNknayG/YkQKBgD6yNgA/ak12rovYzXKdp14Axn+39k2dPp6J6R8MnyLlB3yruwW6NSbNhtzTD1GZ+wCQepQvYvlPPc8zm+t3tl1r+Rtx3ORf5XBZc3iPkGdPOLubTssrrAnA+U9vph61W+OjqwLJ9sHUNK9pSHhHSIS4k6ycM2YAHyIC9NGTgB0PAoGAJjwd1DgMaQldtWnuXjvohPOo8cQudxXYcs6zVRbx6vtjKe2v7e+eK1SSVrR5qFV9AqxDfGwq8THenRa0LC3vNNplqostuehLhkWCKE7Y75vXMR7N6KU1kdoVWgN4BhXSwuRxmHMQfSY7q3HG3rDGz7mzXo1FVMr/uE4iDGm0IXY="
//初始化支付宝客户端
// appId:应用ID
// privateKey:应用秘钥
// isProd:是否是正式环境
client := gopay.NewAliPayClient("2016091200494382", privateKey, false)
//配置公共参数
client.SetCharset("utf-8").
SetSignType("RSA2").
//SetAppAuthToken("").
//SetReturnUrl("https://www.gopay.ink").
SetNotifyUrl("https://www.gopay.ink")
//请求参数
body := make(gopay.BodyMap)
body.Set("subject", "网站测试支付")
body.Set("out_trade_no", "GYWX201901301040355706100418")
body.Set("total_amount", "88.88")
body.Set("product_code", "FAST_INSTANT_TRADE_PAY")
//电脑网站支付请求
payUrl, err := client.AliPayTradePagePay(body)
if err != nil {
fmt.Println("err:", err)
return
}
fmt.Println("payUrl:", payUrl)
Copyright 2019 Jerry
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.